Skip to content

Commit dbb64c2

Browse files
committed
Use CARGO_CFG_TARGET_FEATURE to detect CRT linkage on MSVC
Replace the CARGO_FEATURE_CRT_STATIC feature flag check with CARGO_CFG_TARGET_FEATURE to correctly detect crt-static when set via rustflags rather than as a crate feature.
1 parent e6a88b3 commit dbb64c2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

build.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,10 @@ fn print_link_flags() {
804804
if target_env == "msvc" {
805805
// On Windows, including libcpmt[d]/msvcprt[d] explicitly links the C++
806806
// standard library, which libc++ needs for exception_ptr internals.
807-
if env::var("CARGO_FEATURE_CRT_STATIC").is_ok() {
807+
let crt_static = env::var("CARGO_CFG_TARGET_FEATURE")
808+
.unwrap_or_default()
809+
.contains("crt-static");
810+
if crt_static {
808811
println!("cargo:rustc-link-lib=libcpmt");
809812
} else {
810813
println!("cargo:rustc-link-lib=dylib=msvcprt");

0 commit comments

Comments
 (0)