Skip to content

Commit b66678b

Browse files
authored
Fix LTO Detection in LLVM Intrinsic Build (#36)
Fixes #33 This PR fixes LTO detection in the LLVM intrinsic build script. It turns out that around Rust 1.55, `cargo` stopped propagating `RUSTFLAGS` environment variable to the build script invocation (and even actively removing it). It is replaced with `CARGO_ENCODED_RUSTFLAGS` which is meant to more accurately set the actual `rustc` flags that are being used. Turning this on yields an immediate improvement in benchmarks: ``` U256::add time: [15.726 ns 15.764 ns 15.808 ns] change: [-34.507% -34.304% -34.099%] (p = 0.00 < 0.05) Performance has improved. ```
1 parent 1cd9388 commit b66678b

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

intrinsics/build/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ fn main() -> Result<(), Box<dyn Error>> {
5050
let mut build = Build::new();
5151
build.compiler(&clang).file(intrinsics_ir_path).opt_level(3);
5252

53-
let linker_plugin_lto =
54-
matches!(env::var("RUSTFLAGS"), Ok(flags) if flags.contains("-Clinker-plugin-lto"));
53+
let linker_plugin_lto = matches!(env::var("CARGO_ENCODED_RUSTFLAGS"), Ok(flags) if flags.contains("-Clinker-plugin-lto"));
5554
if linker_plugin_lto {
5655
build.flag("-flto=thin");
5756
}

0 commit comments

Comments
 (0)