Skip to content

Commit 485697b

Browse files
committed
Better way of conditioning the sanitizer builds
Previously the build would take the presence of the LLVM_CONFIG envvar to mean that the sanitizers should be built, but this is a common envvar that could be set for reasons unrelated to the rustc sanitizers. This commit adds a new envvar RUSTC_BUILD_SANITIZERS and uses it instead.
1 parent a24f636 commit 485697b

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

src/bootstrap/compile.rs

+1
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ pub fn std_cargo(builder: &Builder<'_>,
212212
emscripten: false,
213213
});
214214
cargo.env("LLVM_CONFIG", llvm_config);
215+
cargo.env("RUSTC_BUILD_SANITIZERS", "1");
215216
}
216217

217218
cargo.arg("--features").arg(features)

src/librustc_asan/build.rs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use build_helper::sanitizer_lib_boilerplate;
44
use cmake::Config;
55

66
fn main() {
7+
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
8+
return;
9+
}
710
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
811
build_helper::restore_library_path();
912

src/librustc_lsan/build.rs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use build_helper::sanitizer_lib_boilerplate;
44
use cmake::Config;
55

66
fn main() {
7+
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
8+
return;
9+
}
710
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
811
build_helper::restore_library_path();
912

src/librustc_msan/build.rs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use build_helper::sanitizer_lib_boilerplate;
44
use cmake::Config;
55

66
fn main() {
7+
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
8+
return;
9+
}
710
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
811
build_helper::restore_library_path();
912

src/librustc_tsan/build.rs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ use build_helper::sanitizer_lib_boilerplate;
44
use cmake::Config;
55

66
fn main() {
7+
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
8+
return;
9+
}
710
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
811
build_helper::restore_library_path();
912

0 commit comments

Comments
 (0)