Skip to content

Commit

Permalink
Rollup merge of rust-lang#64166 - infinity0:master, r=alexcrichton
Browse files Browse the repository at this point in the history
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.

This PR or similar will be necessary in order to work correctly with rust-lang/compiler-builtins#296
  • Loading branch information
Centril authored Sep 6, 2019
2 parents e618135 + 485697b commit 8bbd71b
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 8bbd71b

Please sign in to comment.