2016-12-29 22:28:11 -06:00
|
|
|
use std::env;
|
2017-04-17 15:22:16 -05:00
|
|
|
use build_helper::sanitizer_lib_boilerplate;
|
2016-12-29 22:28:11 -06:00
|
|
|
|
|
|
|
use cmake::Config;
|
|
|
|
|
|
|
|
fn main() {
|
2019-09-13 22:59:46 -05:00
|
|
|
println!("cargo:rerun-if-env-changed=RUSTC_BUILD_SANITIZERS");
|
2019-09-05 02:14:09 -05:00
|
|
|
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
|
|
|
|
return;
|
|
|
|
}
|
2016-12-29 22:28:11 -06:00
|
|
|
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
|
2019-01-21 18:47:57 -06:00
|
|
|
build_helper::restore_library_path();
|
|
|
|
|
2018-07-18 09:34:54 -05:00
|
|
|
let (native, target) = match sanitizer_lib_boilerplate("asan") {
|
2017-03-03 11:11:04 -06:00
|
|
|
Ok(native) => native,
|
|
|
|
_ => return,
|
|
|
|
};
|
2017-03-02 17:15:56 -06:00
|
|
|
|
|
|
|
Config::new(&native.src_dir)
|
2016-12-29 22:28:11 -06:00
|
|
|
.define("COMPILER_RT_BUILD_SANITIZERS", "ON")
|
|
|
|
.define("COMPILER_RT_BUILD_BUILTINS", "OFF")
|
|
|
|
.define("COMPILER_RT_BUILD_XRAY", "OFF")
|
|
|
|
.define("LLVM_CONFIG_PATH", llvm_config)
|
2017-03-02 17:15:56 -06:00
|
|
|
.out_dir(&native.out_dir)
|
2018-07-18 09:34:54 -05:00
|
|
|
.build_target(&target)
|
2016-12-29 22:28:11 -06:00
|
|
|
.build();
|
2018-09-29 14:37:12 -05:00
|
|
|
native.fixup_sanitizer_lib_name("asan");
|
2016-12-29 22:28:11 -06:00
|
|
|
}
|
2017-06-30 12:35:00 -05:00
|
|
|
println!("cargo:rerun-if-env-changed=LLVM_CONFIG");
|
2016-12-29 22:28:11 -06:00
|
|
|
}
|