[PATCH] D116995: [gold] Ignore bitcode from sections inside object files
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 18 00:19:55 PDT 2022
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.
In D116995#3481661 <https://reviews.llvm.org/D116995#3481661>, @jyknight wrote:
> -fembed-bitcode was originally added by Apple to enable them to recompile
> 3rd-party-developers' software with a newer compiler, or for new CPU
> targets, without the source code. It uses the normal non-LTO optimization
> pipeline, and emits bitcode corresponding to the binary object also
> emitted.
>
> For LTO bitcode generation, we use a different pass manager configuration.
>
> That said, various other people seem to have had various other ideas about
> how things should work over time. So, I couldn't say conclusively that
> nobody will complain if we have gold not try to parse these sections...but
> it seems potentially reasonable to me.
I agree. I think for Mach-O the section is for LTO use. For ELF there are two usage:
- lld/LLVMgold.so: the section should be ignored. This patch makes LLVMgold.so behavior match lld, therefore LGTM.
- llgo (https://reviews.llvm.org/D4371): it places the bitcode for LTO into a special section `.llvmbc`.
================
Comment at: llvm/docs/ReleaseNotes.rst:170
+* The LLVM gold plugin will now ignore bitcode from the .llvmbc section of ELF
+ files when doing LTO. https://github.com/llvm/llvm-project/issues/47216
----------------
================
Comment at: llvm/tools/gold/gold-plugin.cpp:540
+ // Only use bitcode files for LTO. InputFile::create() will load bitcode
+ // from special sections within a binary object, this bitcode is typically
+ // generated by -fembed-bitcode and is not meant for LTO use.
----------------
special sections => .llvmbc
Be specific.
================
Comment at: llvm/tools/gold/gold-plugin.cpp:541
+ // from special sections within a binary object, this bitcode is typically
+ // generated by -fembed-bitcode and is not meant for LTO use.
+ if (identify_magic(BufferRef.getBuffer()) != file_magic::bitcode) {
----------------
"not meant for LTO use " when using LLVMgold.so.
For llgo(?) it was for LTO use: https://reviews.llvm.org/D4371
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116995/new/
https://reviews.llvm.org/D116995
More information about the llvm-commits
mailing list