[rust] Tell Cargo to link cpp runtime library

https://boringssl-review.googlesource.com/c/boringssl/+/66288
allowed C++ runtime in libssl. The build script of bssl-sys crate
should indicate that the crate requires a C++ runtime. Use
libc++ on MacOS and libstdc++ on other unix like systems by
default. Introduce a new environment variable to configure C++
runtime to use.

Change-Id: Ib445955012126080dd03ad7b650287ea9dde10b0
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/67147
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
fips-20240407
Kenichi Ishibashi 8 months ago committed by Boringssl LUCI CQ
parent ee4c2a38a0
commit 54c956b2e6
  1. 21
      rust/bssl-sys/build.rs

@ -78,6 +78,23 @@ fn get_bssl_build_dir() -> PathBuf {
return Path::new(&crate_dir).join("../../build");
}
fn get_cpp_runtime_lib() -> Option<String> {
println!("cargo:rerun-if-env-changed=BORINGSSL_RUST_CPPLIB");
if let Ok(cpp_lib) = env::var("BORINGSSL_RUST_CPPLIB") {
return Some(cpp_lib);
}
if env::var_os("CARGO_CFG_UNIX").is_some() {
match env::var("CARGO_CFG_TARGET_OS").unwrap().as_ref() {
"macos" => Some("c++".into()),
_ => Some("stdc++".into()),
}
} else {
None
}
}
fn main() {
let bssl_build_dir = get_bssl_build_dir();
let bssl_sys_build_dir = bssl_build_dir.join("rust/bssl-sys");
@ -106,5 +123,9 @@ fn main() {
);
println!("cargo:rustc-link-lib=static=rust_wrapper");
if let Some(cpp_lib) = get_cpp_runtime_lib() {
println!("cargo:rustc-link-lib={}", cpp_lib);
}
println!("cargo:conf={}", OSSL_CONF_DEFINES.join(","));
}

Loading…
Cancel
Save