]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Auto merge of #98162 - nextsilicon:support_lto_embed_bitcode, r=davidtwco
authorbors <bors@rust-lang.org>
Thu, 21 Jul 2022 10:13:59 +0000 (10:13 +0000)
committerbors <bors@rust-lang.org>
Thu, 21 Jul 2022 10:13:59 +0000 (10:13 +0000)
commit74f600b990240556c9a355c5d03293a10934bd1b
tree4b12cbd785b255a340b0ff57ec22d9e49af78a5c
parentceeb5ade201e4181c6d5df2ba96ae5fb2193aadc
parent724c91234dd49b88d70ebead406d09105695c3e5
Auto merge of #98162 - nextsilicon:support_lto_embed_bitcode, r=davidtwco

Allow to disable thinLTO buffer to support lto-embed-bitcode lld feature

Hello
This change is to fix issue (https://github.com/rust-lang/rust/issues/84395) in which passing "-lto-embed-bitcode=optimized" to lld when linking rust code via linker-plugin-lto doesn't produce the expected result.

Instead of emitting a single unified module into a llvmbc section of the linked elf, it emits multiple submodules.
This is caused because rustc emits the BC modules after running llvm `createWriteThinLTOBitcodePass` pass.
Which in turn triggers a thinLTO linkage and causes the said issue.

This patch allows via compiler flag (-Cemit-thin-lto=<bool>) to select between running `createWriteThinLTOBitcodePass` and `createBitcodeWriterPass`.
Note this pattern of selecting between those 2 passes is common inside of LLVM code.
The default is to match the old behavior.
compiler/rustc_codegen_llvm/src/back/lto.rs
compiler/rustc_codegen_llvm/src/llvm/ffi.rs
compiler/rustc_interface/src/tests.rs
compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
compiler/rustc_session/src/options.rs
src/test/rustdoc-ui/z-help.stdout