Skip to content

Commit a51d878

Browse files
authored
mozjs_sys: Honor the CXXSTDLIB environment variable (#615)
`CXXSTDLIB` is an environment variable used by `cc` and many other crates which lets developers to choose a standard C++ library of their choice. Make use of that variable in mozjs_sys's build.rs as well. One of the use cases is supporting Linux distributions which use LLVM instead of GCC as the main toolchain (e.g. Chimera, Gentoo musl-llvm profile, OpenMandriva). Signed-off-by: Michal Rostecki <[email protected]>
1 parent 3805c67 commit a51d878

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

mozjs-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mozjs_sys"
33
description = "System crate for the Mozilla SpiderMonkey JavaScript engine."
44
repository.workspace = true
5-
version = "0.137.0-2"
5+
version = "0.137.0-3"
66
authors = ["Mozilla"]
77
links = "mozjs"
88
license.workspace = true

mozjs-sys/build.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,15 @@ fn link_static_lib_binaries(build_dir: &Path) {
386386
println!("cargo:rustc-link-lib=user32");
387387
println!("cargo:rustc-link-lib=Dbghelp");
388388
println!("cargo:rustc-link-lib=advapi32");
389-
if target.contains("gnu") {
390-
println!("cargo:rustc-link-lib=stdc++");
391-
}
389+
}
390+
if let Some(cxxstdlib) = env::var("CXXSTDLIB").ok() {
391+
println!("cargo:rustc-link-lib={cxxstdlib}");
392392
} else if target.contains("apple") || target.contains("freebsd") || target.contains("ohos") {
393393
println!("cargo:rustc-link-lib=c++");
394-
} else {
394+
} else if target.contains("windows") && target.contains("gnu") {
395395
println!("cargo:rustc-link-lib=stdc++");
396+
} else if !target.contains("windows") {
397+
println!("cargo:rustc-link-lib=stdc++")
396398
}
397399
}
398400

0 commit comments

Comments
 (0)