Skip to content

Commit 6bce50f

Browse files
authored
Rollup merge of #63621 - jgalenson:dndebug, r=alexcrichton
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. r? @alexcrichton
2 parents a053bae + 1916036 commit 6bce50f

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
@@ -790,6 +790,9 @@ pub fn build_codegen_backend(builder: &Builder<'_>,
790790
if builder.config.llvm_use_libcxx {
791791
cargo.env("LLVM_USE_LIBCXX", "1");
792792
}
793+
if builder.config.llvm_optimize && !builder.config.llvm_release_debuginfo {
794+
cargo.env("LLVM_NDEBUG", "1");
795+
}
793796
}
794797
_ => panic!("unknown backend: {}", backend),
795798
}

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)