CFI: Fix LTO for #![no_builtins] crates with CFI#156024
CFI: Fix LTO for #![no_builtins] crates with CFI#156024rcvalle wants to merge 1 commit intorust-lang:mainfrom
#![no_builtins] crates with CFI#156024Conversation
|
r? @jieyouxu rustbot has assigned @jieyouxu. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
Fixes LTO for `#![no_builtins]` crates with CFI enabled by using rustc's `EmitObj::Bitcode` path (and emitting LLVM bitcode in the `.o` for linker-based LTO).
58c916f to
02987f4
Compare
|
The job Click to see the possible cause of the failure (guessed by this bot) |
| // | ||
| // Therefore, with `-Clinker-plugin-lto` and `-Zsanitizer=cfi`, a | ||
| // `#![no_builtins]` crate must still use rustc's `EmitObj::Bitcode` | ||
| // path (and emit LLVM bitcode in the `.o` for linker-based LTO). |
There was a problem hiding this comment.
The reason we don't use LTO for compiler-builtins is that doing so breaks the weak linkage that compiler-builtins uses. We use a legacy interface for implementing LTO that treats weak and strong symbols identically. We tried to make compiler-builtins participate in LTO before in #113923, but this resulted in the regression #118609.
In any case just emitting bitcode is not enough. You also need to updated ignored_for_lto:
rust/compiler/rustc_codegen_ssa/src/back/link.rs
Lines 1406 to 1422 in 0469a92
Fixes LTO for
#![no_builtins]crates with CFI enabled by using rustc'sEmitObj::Bitcodepath (and emitting LLVM bitcode in the.ofor linker-based LTO).In addition to adding a specific regression test for #142284, it also adds a test that verifies that the examples in rust-cfi-examples build with
-Zbuild-stdto prevent other future regressions.