Skip to content

Commit dda6d2c

Browse files
committed
Add env var to select c++ std lib
1 parent 20e57c5 commit dda6d2c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

build.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,19 @@ fn main() {
88

99
println!("cargo:rustc-link-search=native={}", custom_lib_dir);
1010
println!("cargo:rustc-link-lib=static={}", custom_lib_name);
11-
/* FIXME: this is assuming a C++ fuzzer, but should be customizable */
12-
println!("cargo:rustc-link-lib=stdc++");
11+
12+
// Allow user to specify use of LLVM or GCC C++ stdlib, or none.
13+
// "cargo:rustc-link-lib=stdc++" is used by default for
14+
// backward-compatibility.
15+
// Note: google/oss-fuzz uses LLVM C++ stdlib as of 15 Jan 2020
16+
if let Ok(std_cxx_flag) = ::std::env::var("CUSTOM_LIBFUZZER_STD_CXX") {
17+
match std_cxx_flag.as_str() {
18+
"c++" => println!("cargo:rustc-link-lib=c++"),
19+
"stdc++" => println!("cargo:rustc-link-lib=stdc++"),
20+
"none" => (),
21+
_ => println!("cargo:rustc-link-lib=stdc++"),
22+
}
23+
}
1324
} else {
1425
let mut build = cc::Build::new();
1526
let sources = ::std::fs::read_dir("libfuzzer")

0 commit comments

Comments
 (0)