From 223b98f2ff27683a849e15b3a2c9d58bc0dfd0ab Mon Sep 17 00:00:00 2001 From: Yuyi Wang Date: Mon, 19 May 2025 16:27:04 +0800 Subject: [PATCH] Fix build.rs to support cross-compiling to cygwin (#11512) 2719ae4 adds a special cfg for cygwin to avoid annoying warnings. As cygwin target is usually cross-compiled, cfg! is not enough to detect the correct target. This PR uses CARGO_CFG_TARGET_OS env var instead. --- build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index f86dab569..1a0f0d5f0 100644 --- a/build.rs +++ b/build.rs @@ -143,9 +143,9 @@ fn detect_apple(_: &Target) -> Result> { Ok(cfg!(any(target_os = "ios", target_os = "macos"))) } -#[allow(unexpected_cfgs)] fn detect_cygwin(_: &Target) -> Result> { - Ok(cfg!(target_os = "cygwin")) + // Cygwin target is usually cross-compiled. + Ok(std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "cygwin") } /// Detect if we're being compiled for a BSD-derived OS, allowing targeting code conditionally with