Skip to content

Commit 1916036

Browse files
committed
Modify librustc_llvm to pass -DNDEBUG while compiling.
Currently, librustc_llvm builds are not reproducible because the LLVM files it compiles use the debug version of llvm_unreachable, which uses __FILE__. To fix this, we propagate NDEBUG from bootstrap if applicable and use it when compiling librustc_llvm.
1 parent c01be67 commit 1916036

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/bootstrap/compile.rs

+3
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,9 @@ pub fn build_codegen_backend(builder: &Builder<'_>,
795795
if builder.config.llvm_use_libcxx {
796796
cargo.env("LLVM_USE_LIBCXX", "1");
797797
}
798+
if builder.config.llvm_optimize && !builder.config.llvm_release_debuginfo {
799+
cargo.env("LLVM_NDEBUG", "1");
800+
}
798801
}
799802
_ => panic!("unknown backend: {}", backend),
800803
}

src/librustc_llvm/build.rs

+4
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ fn main() {
151151
cfg.define("LLVM_RUSTLLVM", None);
152152
}
153153

154+
if env::var_os("LLVM_NDEBUG").is_some() {
155+
cfg.define("NDEBUG", None);
156+
}
157+
154158
build_helper::rerun_if_changed_anything_in_dir(Path::new("../rustllvm"));
155159
cfg.file("../rustllvm/PassWrapper.cpp")
156160
.file("../rustllvm/RustWrapper.cpp")

0 commit comments

Comments
 (0)