Skip to content

Commit

Permalink
Better way of conditioning the sanitizer builds
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
infinity0 committed Sep 5, 2019
1 parent a24f636 commit 485697b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ pub fn std_cargo(builder: &Builder<'_>,
emscripten: false,
});
cargo.env("LLVM_CONFIG", llvm_config);
cargo.env("RUSTC_BUILD_SANITIZERS", "1");
}

cargo.arg("--features").arg(features)
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_asan/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use build_helper::sanitizer_lib_boilerplate;
use cmake::Config;

fn main() {
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
return;
}
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
build_helper::restore_library_path();

Expand Down
3 changes: 3 additions & 0 deletions src/librustc_lsan/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use build_helper::sanitizer_lib_boilerplate;
use cmake::Config;

fn main() {
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
return;
}
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
build_helper::restore_library_path();

Expand Down
3 changes: 3 additions & 0 deletions src/librustc_msan/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use build_helper::sanitizer_lib_boilerplate;
use cmake::Config;

fn main() {
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
return;
}
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
build_helper::restore_library_path();

Expand Down
3 changes: 3 additions & 0 deletions src/librustc_tsan/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use build_helper::sanitizer_lib_boilerplate;
use cmake::Config;

fn main() {
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
return;
}
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
build_helper::restore_library_path();

Expand Down

0 comments on commit 485697b

Please sign in to comment.