Joseph via llvm-dev
2020-Aug-15 13:53 UTC
[llvm-dev] Adding bitcode to an existing MachO object file
This is a silly question, but I am in a situation where I need to build x86 and arm assembly sources for some sources while the rest will be built with C. I do know that just adding `-fembed-bitcode` to a C sources would embed bitcode, but doing the same for the assembly files will not do that (at least, it will add the 1-byte `_LLVM,__asm` section, but not the `__LLVM,__bitcode` section). Furthermore, I do need the final output to contain bitcode for all files used. So, my question is if it is possible to add the `__LLVM,__bitcode` section later to the MachO object file. I tried to archive the bitcode using `xar` and run `llvm-objcopy main.o --add-section=__LLVM,__bitcode=main.xar main2.o`, but it failed with an `unsupported load command`. This seems to be the case for all usages of `llvm-objcopy` with MachO files. Cheers and thanks -- Joseph -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200815/2d88c9cc/attachment.html>
Shoaib Meenai via llvm-dev
2020-Aug-15 18:44 UTC
[llvm-dev] Adding bitcode to an existing MachO object file
What version of llvm-objcopy are you using? I know it’s had many fixes for Mach-O recently. If you’re running into a bug with the latest llvm-objcopy (from the master branch), it’d be great if you could file a bug on bugs.llvm.org with your input file (if possible). From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Joseph via llvm-dev <llvm-dev at lists.llvm.org> Reply-To: Joseph <cybercheesecake2 at gmail.com> Date: Saturday, August 15, 2020 at 6:53 AM To: llvm-dev <llvm-dev at lists.llvm.org> Subject: [llvm-dev] Adding bitcode to an existing MachO object file This is a silly question, but I am in a situation where I need to build x86 and arm assembly sources for some sources while the rest will be built with C. I do know that just adding `-fembed-bitcode` to a C sources would embed bitcode, but doing the same for the assembly files will not do that (at least, it will add the 1-byte `_LLVM,__asm` section, but not the `__LLVM,__bitcode` section). Furthermore, I do need the final output to contain bitcode for all files used. So, my question is if it is possible to add the `__LLVM,__bitcode` section later to the MachO object file. I tried to archive the bitcode using `xar` and run `llvm-objcopy main.o --add-section=__LLVM,__bitcode=main.xar main2.o`, but it failed with an `unsupported load command`. This seems to be the case for all usages of `llvm-objcopy` with MachO files. Cheers and thanks -- Joseph -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200815/2792362f/attachment.html>
Joseph via llvm-dev
2020-Aug-15 20:15 UTC
[llvm-dev] Adding bitcode to an existing MachO object file
Many thanks for your comment! I was using the one from Brew (llvm 10, I believe). I'll build master and run it from there and report back tomorrow On Sat, 15 Aug 2020, 20:45 Shoaib Meenai, <smeenai at fb.com> wrote:> What version of llvm-objcopy are you using? I know it’s had many fixes for > Mach-O recently. If you’re running into a bug with the latest llvm-objcopy > (from the master branch), it’d be great if you could file a bug on > bugs.llvm.org with your input file (if possible). > > > > *From: *llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Joseph > via llvm-dev <llvm-dev at lists.llvm.org> > *Reply-To: *Joseph <cybercheesecake2 at gmail.com> > *Date: *Saturday, August 15, 2020 at 6:53 AM > *To: *llvm-dev <llvm-dev at lists.llvm.org> > *Subject: *[llvm-dev] Adding bitcode to an existing MachO object file > > > > This is a silly question, but I am in a situation where I need to build > x86 and arm assembly sources for some sources while the rest will be built > with C. I do know that just adding `-fembed-bitcode` to a C sources would > embed bitcode, but doing the same for the assembly files will not do that > (at least, it will add the 1-byte `_LLVM,__asm` section, but not the > `__LLVM,__bitcode` section). Furthermore, I do need the final output to > contain bitcode for all files used. > > So, my question is if it is possible to add the `__LLVM,__bitcode` section > later to the MachO object file. I tried to archive the bitcode using `xar` > and run `llvm-objcopy main.o --add-section=__LLVM,__bitcode=main.xar > main2.o`, but it failed with an `unsupported load command`. This seems to > be the case for all usages of `llvm-objcopy` with MachO files. > > Cheers and thanks > > -- Joseph >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200815/2e67a3a2/attachment.html>
Apparently Analagous Threads
- Difference when compiling human readable IR vs bitcode with clang frontend
- [RFC] Embedding Bitcode in Object Files
- Difference when compiling human readable IR vs bitcode with clang frontend
- [cfe-dev] [RFC] Embedding Bitcode in Object Files
- [RFC] Embedded bitcode and related upstream (Part II)