CFI: Make lto and linker-plugin-lto work the same for compiler_builtins#145368
CFI: Make lto and linker-plugin-lto work the same for compiler_builtins#145368bors merged 1 commit intorust-lang:masterfrom
lto and linker-plugin-lto work the same for compiler_builtins#145368Conversation
|
Some changes occurred in compiler/rustc_codegen_ssa |
|
r? dianqk |
|
I know there are some concerns with #118609, but it feels to me that this is the right fix (instead of avoiding indirect branches in the compiler_builtins crate). Optionally, we could enable it only when CFI is enabled for now and test it for some time for regressions. |
bb54ba9 to
e3090b9
Compare
This comment has been minimized.
This comment has been minimized.
|
As I mentioned at #142323 (comment), # Cargo.toml
[profile.release]
lto = "fat"
codegen-units = 1The output of There should be a log like |
|
Sorry, I should've described it better. The This fix ensures that |
Fix rust-lang#142284 by ensuring that `#![no_builtins]` crates can still emit bitcode when proper (i.e., non-rustc) LTO (i.e., -Clinker-plugin-lto) is used.
e3090b9 to
cf8753e
Compare
This comment was marked as spam.
This comment was marked as spam.
|
@bors r+ |
Rollup of 6 pull requests Successful merges: - #142472 (Add new `doc(attribute = "...")` attribute) - #145368 (CFI: Make `lto` and `linker-plugin-lto` work the same for `compiler_builtins`) - #145853 (Improve error messages around invalid literals in attribute arguments) - #145920 (bootstrap: Explicitly mark the end of a failed test's captured output) - #145937 (add doc-hidden to exports in attribute prelude) - #145965 (Move exporting of profiler and sanitizer symbols to the LLVM backend) r? `@ghost` `@rustbot` modify labels: rollup
Revert "Make `lto` and `linker-plugin-lto` work the same for `compiler_builtins` This reverts commit cf8753e (PR rust-lang#145368) and fix the regressions reported at rust-lang#145981 and rust-lang#146109.
Revert "Make `lto` and `linker-plugin-lto` work the same for `compiler_builtins` This reverts commit cf8753e4f9c3597f04cd5d3aa261e4561d5378a6 (PR rust-lang/rust#145368) and fix the regressions reported at rust-lang/rust#145981, rust-lang/rust#146109, and rust-lang/rust#146145.
Revert "Make `lto` and `linker-plugin-lto` work the same for `compiler_builtins` This reverts commit cf8753e4f9c3597f04cd5d3aa261e4561d5378a6 (PR rust-lang/rust#145368) and fix the regressions reported at rust-lang/rust#145981, rust-lang/rust#146109, and rust-lang/rust#146145.
Revert "Make `lto` and `linker-plugin-lto` work the same for `compiler_builtins` This reverts commit cf8753e4f9c3597f04cd5d3aa261e4561d5378a6 (PR rust-lang/rust#145368) and fix the regressions reported at rust-lang/rust#145981, rust-lang/rust#146109, and rust-lang/rust#146145.
Revert "Make `lto` and `linker-plugin-lto` work the same for `compiler_builtins` This reverts commit cf8753e (PR rust-lang#145368) and fix the regressions reported at rust-lang#145981, rust-lang#146109, and rust-lang#146145.
Revert "Make `lto` and `linker-plugin-lto` work the same for `compiler_builtins` This reverts commit cf8753e (PR rust-lang#145368) and fix the regressions reported at rust-lang#145981, rust-lang#146109, and rust-lang#146145.
Revert "Make `lto` and `linker-plugin-lto` work the same for `compiler_builtins` This reverts commit cf8753e4f9c3597f04cd5d3aa261e4561d5378a6 (PR rust-lang/rust#145368) and fix the regressions reported at rust-lang/rust#145981, rust-lang/rust#146109, and rust-lang/rust#146145.
Add a test for rust-lang/rust#146133. `cargo +nightly-2025-08-29 test --test build-std -- lto` can reproduce the regression. This is not a bug from Cargo, but it requires `-Zbuild-std` in most use cases. The test case is from rust-lang/rust#146109. The point is that when rustc is invoked with -Clto=fat or -Clto=thin, it should perform LTO with ALL bitcodes. However, rust-lang/rust#145368 emits bitcodes for compiler_builtins but excludes it from LTO participation. As a result, the compiler_builtins bitcodes library is passed to the linker, but the linkers, such as the GNU ld or older versions of LLD, are unable to process bitcodes.
Revert "Make `lto` and `linker-plugin-lto` work the same for `compiler_builtins` This reverts commit cf8753e4f9c3597f04cd5d3aa261e4561d5378a6 (PR rust-lang/rust#145368) and fix the regressions reported at rust-lang/rust#145981, rust-lang/rust#146109, and rust-lang/rust#146145.
Revert "Make `lto` and `linker-plugin-lto` work the same for `compiler_builtins` This reverts commit cf8753e4f9c3597f04cd5d3aa261e4561d5378a6 (PR rust-lang/rust#145368) and fix the regressions reported at rust-lang/rust#145981, rust-lang/rust#146109, and rust-lang/rust#146145.
Fix #142284 by ensuring that
#![no_builtins]crates can still emit bitcode when proper (i.e., non-rustc) LTO (i.e., -Clinker-plugin-lto) is used.