From 4d3a01a2e38d6cb743f72cf6ff6baae3f324b6a7 Mon Sep 17 00:00:00 2001 From: Dennis Duda Date: Thu, 4 Jan 2024 17:37:27 +0100 Subject: [PATCH 1/2] Relax the build target checks in windows-targets sub-crates This allows e.g. x86_64-win7-windows-msvc and other alternative vendors to link. --- crates/targets/aarch64_msvc/build.rs | 6 ++++-- crates/targets/i686_msvc/build.rs | 6 ++++-- crates/targets/x86_64_msvc/build.rs | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/targets/aarch64_msvc/build.rs b/crates/targets/aarch64_msvc/build.rs index 243d23c4f9..e1cd062f3f 100644 --- a/crates/targets/aarch64_msvc/build.rs +++ b/crates/targets/aarch64_msvc/build.rs @@ -1,6 +1,8 @@ fn main() { - let target = std::env::var("TARGET").unwrap(); - if target != "aarch64-pc-windows-msvc" && target != "aarch64-uwp-windows-msvc" { + let family = std::env::var("CARGO_CFG_TARGET_FAMILY").unwrap(); + let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + let env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap(); + if family != "windows" || arch != "aarch64" || env != "msvc" { return; } diff --git a/crates/targets/i686_msvc/build.rs b/crates/targets/i686_msvc/build.rs index 53892bff6b..0c00b792eb 100644 --- a/crates/targets/i686_msvc/build.rs +++ b/crates/targets/i686_msvc/build.rs @@ -1,6 +1,8 @@ fn main() { - let target = std::env::var("TARGET").unwrap(); - if target != "i686-pc-windows-msvc" && target != "i686-uwp-windows-msvc" { + let family = std::env::var("CARGO_CFG_TARGET_FAMILY").unwrap(); + let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + let env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap(); + if family != "windows" || arch != "x86" || env != "msvc" { return; } diff --git a/crates/targets/x86_64_msvc/build.rs b/crates/targets/x86_64_msvc/build.rs index c51c8caa81..ae819b9759 100644 --- a/crates/targets/x86_64_msvc/build.rs +++ b/crates/targets/x86_64_msvc/build.rs @@ -1,6 +1,8 @@ fn main() { - let target = std::env::var("TARGET").unwrap(); - if target != "x86_64-pc-windows-msvc" && target != "x86_64-uwp-windows-msvc" { + let family = std::env::var("CARGO_CFG_TARGET_FAMILY").unwrap(); + let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + let env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap(); + if family != "windows" || arch != "x86_64" || env != "msvc" { return; } From 01b0ae05ce5a44c966c7731ba02ff94051b5f773 Mon Sep 17 00:00:00 2001 From: Dennis Duda Date: Thu, 4 Jan 2024 19:10:45 +0100 Subject: [PATCH 2/2] Relax the build target checks for gnu and gnullvm targets as well --- crates/targets/aarch64_gnullvm/build.rs | 5 ++++- crates/targets/i686_gnu/build.rs | 6 ++++-- crates/targets/x86_64_gnu/build.rs | 5 ++++- crates/targets/x86_64_gnullvm/build.rs | 5 ++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/crates/targets/aarch64_gnullvm/build.rs b/crates/targets/aarch64_gnullvm/build.rs index 8c8f98f5ec..f6ba3ec3ff 100644 --- a/crates/targets/aarch64_gnullvm/build.rs +++ b/crates/targets/aarch64_gnullvm/build.rs @@ -1,6 +1,9 @@ fn main() { + let family = std::env::var("CARGO_CFG_TARGET_FAMILY").unwrap(); + let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + let env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap(); let target = std::env::var("TARGET").unwrap(); - if target != "aarch64-pc-windows-gnullvm" { + if family != "windows" || arch != "aarch64" || env != "gnu" || !target.ends_with("-gnullvm") { return; } diff --git a/crates/targets/i686_gnu/build.rs b/crates/targets/i686_gnu/build.rs index 9dbe7e5406..d10600d9d7 100644 --- a/crates/targets/i686_gnu/build.rs +++ b/crates/targets/i686_gnu/build.rs @@ -1,6 +1,8 @@ fn main() { - let target = std::env::var("TARGET").unwrap(); - if target != "i686-pc-windows-gnu" && target != "i686-uwp-windows-gnu" { + let family = std::env::var("CARGO_CFG_TARGET_FAMILY").unwrap(); + let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + let env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap(); + if family != "windows" || arch != "x86" || env != "gnu" { return; } diff --git a/crates/targets/x86_64_gnu/build.rs b/crates/targets/x86_64_gnu/build.rs index 7612e7935d..ea4f74aa4d 100644 --- a/crates/targets/x86_64_gnu/build.rs +++ b/crates/targets/x86_64_gnu/build.rs @@ -1,6 +1,9 @@ fn main() { + let family = std::env::var("CARGO_CFG_TARGET_FAMILY").unwrap(); + let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + let env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap(); let target = std::env::var("TARGET").unwrap(); - if target != "x86_64-pc-windows-gnu" && target != "x86_64-uwp-windows-gnu" { + if family != "windows" || arch != "x86_64" || env != "gnu" || !target.ends_with("-gnu") { return; } diff --git a/crates/targets/x86_64_gnullvm/build.rs b/crates/targets/x86_64_gnullvm/build.rs index ea83354fad..15b80b8d98 100644 --- a/crates/targets/x86_64_gnullvm/build.rs +++ b/crates/targets/x86_64_gnullvm/build.rs @@ -1,6 +1,9 @@ fn main() { + let family = std::env::var("CARGO_CFG_TARGET_FAMILY").unwrap(); + let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + let env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap(); let target = std::env::var("TARGET").unwrap(); - if target != "x86_64-pc-windows-gnullvm" { + if family != "windows" || arch != "x86_64" || env != "gnu" || !target.ends_with("-gnullvm") { return; }