Skip to content

Commit 776b0ad

Browse files
committed
Fix incorrect NDEBUG handling in LLVM bindings
We currently compile our LLVM bindings using `-DNDEBUG` if debuginfo for LLVM is disabled. However, `NDEBUG` doesn't have any relation to debuginfo, it controls whether assertions are enabled. Rename the environment variable to `LLVM_ASSERTIONS` and drive it using the `llvm_assertions` option. Also drop the explicit `debug(false)` call, as cc already sets this up using the cargo `DEBUG` environment variable.
1 parent 0fdfb61 commit 776b0ad

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

compiler/rustc_llvm/build.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,8 @@ fn main() {
197197
cfg.define("LLVM_RUSTLLVM", None);
198198
}
199199

200-
if tracked_env_var_os("LLVM_NDEBUG").is_some() {
200+
if tracked_env_var_os("LLVM_ASSERTIONS").is_none() {
201201
cfg.define("NDEBUG", None);
202-
cfg.debug(false);
203202
}
204203

205204
rerun_if_changed_anything_in_dir(Path::new("llvm-wrapper"));

src/bootstrap/src/core/build_steps/compile.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1213,8 +1213,8 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
12131213
if builder.config.llvm_use_libcxx {
12141214
cargo.env("LLVM_USE_LIBCXX", "1");
12151215
}
1216-
if builder.config.llvm_optimize && !builder.config.llvm_release_debuginfo {
1217-
cargo.env("LLVM_NDEBUG", "1");
1216+
if builder.config.llvm_assertions {
1217+
cargo.env("LLVM_ASSERTIONS", "1");
12181218
}
12191219
}
12201220

0 commit comments

Comments
 (0)