0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-12-26 00:59:28 -05:00

Add crate feature that controls whether custom libcxx is used (#924)

The `use_custom_libcxx` feature is enabled by default. When this feature
is disabled, the crate will link with the system libcxx instead.
This commit is contained in:
Arthur Silva 2022-03-16 16:20:09 +01:00 committed by GitHub
parent 0c43be27a1
commit 43893f726d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View file

@ -75,6 +75,10 @@ exclude = [
"!v8/tools/testrunner/utils/dump_build_config.py",
]
[features]
default = ["use_custom_libcxx"]
use_custom_libcxx = []
[dependencies]
lazy_static = "1.4.0"
libc = "0.2.93"

View file

@ -109,6 +109,10 @@ fn build_v8() {
vec!["is_debug=false".to_string()]
};
if cfg!(not(feature = "use_custom_libcxx")) {
gn_args.push("use_custom_libcxx=false".to_string());
}
if !is_debug() {
gn_args.push("v8_enable_handle_zapping=false".to_string());
}
@ -398,6 +402,28 @@ fn download_static_lib_binaries() {
fn print_link_flags() {
println!("cargo:rustc-link-lib=static=rusty_v8");
let should_dyn_link_libcxx = cfg!(not(feature = "use_custom_libcxx"))
|| env::var("GN_ARGS").map_or(false, |gn_args| {
gn_args
.split_whitespace()
.any(|ba| ba == "use_custom_libcxx=false")
});
if should_dyn_link_libcxx {
// Based on https://github.com/alexcrichton/cc-rs/blob/fba7feded71ee4f63cfe885673ead6d7b4f2f454/src/lib.rs#L2462
let target = env::var("TARGET").unwrap();
if target.contains("apple")
|| target.contains("freebsd")
|| target.contains("openbsd")
{
println!("cargo:rustc-link-lib=dylib=c++");
} else if target.contains("linux") {
println!("cargo:rustc-link-lib=dylib=stdc++");
} else if target.contains("android") {
println!("cargo:rustc-link-lib=dylib=c++_shared");
}
}
if cfg!(target_os = "windows") {
println!("cargo:rustc-link-lib=dylib=winmm");
println!("cargo:rustc-link-lib=dylib=dbghelp");