summaryrefslogtreecommitdiffstats
path: root/vendor/psm/build.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
commit5363f350887b1e5b5dd21a86f88c8af9d7fea6da (patch)
tree35ca005eb6e0e9a1ba3bb5dbc033209ad445dc17 /vendor/psm/build.rs
parentAdding debian version 1.66.0+dfsg1-1. (diff)
downloadrustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.tar.xz
rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/psm/build.rs')
-rw-r--r--vendor/psm/build.rs41
1 files changed, 22 insertions, 19 deletions
diff --git a/vendor/psm/build.rs b/vendor/psm/build.rs
index 01a13bf71..9d40212eb 100644
--- a/vendor/psm/build.rs
+++ b/vendor/psm/build.rs
@@ -12,14 +12,14 @@ fn find_assembly(
// is not supported in Windows. For x86_64 the implementation actually works locally,
// but failed tests in CI (???). Might want to have a feature for experimental support
// here.
- ("x86", _, "windows", "msvc") => {
+ ("x86", _, "windows", _) => {
if masm {
Some(("src/arch/x86_msvc.asm", false))
} else {
Some(("src/arch/x86_windows_gnu.s", false))
}
}
- ("x86_64", _, "windows", "msvc") => {
+ ("x86_64", _, "windows", _) => {
if masm {
Some(("src/arch/x86_64_msvc.asm", false))
} else {
@@ -27,21 +27,21 @@ fn find_assembly(
}
}
("arm", _, "windows", "msvc") => Some(("src/arch/arm_armasm.asm", false)),
- ("aarch64", _, "windows", "msvc") => {
+ ("aarch64", _, "windows", _) => {
if masm {
Some(("src/arch/aarch64_armasm.asm", false))
} else {
Some(("src/arch/aarch_aapcs64.s", false))
}
}
- ("x86", _, "windows", _) => Some(("src/arch/x86_windows_gnu.s", false)),
- ("x86_64", _, "windows", _) => Some(("src/arch/x86_64_windows_gnu.s", false)),
("x86", _, _, _) => Some(("src/arch/x86.s", true)),
("x86_64", _, _, _) => Some(("src/arch/x86_64.s", true)),
("arm", _, _, _) => Some(("src/arch/arm_aapcs.s", true)),
("aarch64", _, _, _) => Some(("src/arch/aarch_aapcs64.s", true)),
("powerpc", _, _, _) => Some(("src/arch/powerpc32.s", true)),
+ ("powerpc64", _, _, "musl") => Some(("src/arch/powerpc64_openpower.s", true)),
("powerpc64", "little", _, _) => Some(("src/arch/powerpc64_openpower.s", true)),
+ ("powerpc64", _, "aix", _) => Some(("src/arch/powerpc64_aix.s", true)),
("powerpc64", _, _, _) => Some(("src/arch/powerpc64.s", true)),
("s390x", _, _, _) => Some(("src/arch/zseries_linux.s", true)),
("mips", _, _, _) => Some(("src/arch/mips_eabi.s", true)),
@@ -51,29 +51,32 @@ fn find_assembly(
("riscv32", _, _, _) => Some(("src/arch/riscv.s", true)),
("riscv64", _, _, _) => Some(("src/arch/riscv64.s", true)),
("wasm32", _, _, _) => Some(("src/arch/wasm32.o", true)),
+ ("loongarch64", _, _, _) => Some(("src/arch/loongarch64.s", true)),
_ => None,
}
}
fn main() {
- let arch = ::std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
- let env = ::std::env::var("CARGO_CFG_TARGET_ENV").unwrap();
- let os = ::std::env::var("CARGO_CFG_TARGET_OS").unwrap();
- let endian = ::std::env::var("CARGO_CFG_TARGET_ENDIAN").unwrap();
+ use std::env::var;
- // We are only assembling a single file and any flags in the environment probably
- // don't apply in this case, so we don't want to use them. Unfortunately, cc
- // doesn't provide a way to clear/ignore flags set from the environment, so
- // we manually remove them instead
- for key in
- std::env::vars().filter_map(|(k, _)| if k.contains("CFLAGS") { Some(k) } else { None })
- {
- std::env::remove_var(key);
- }
+ let arch = var("CARGO_CFG_TARGET_ARCH").unwrap();
+ let env = var("CARGO_CFG_TARGET_ENV").unwrap();
+ let os = var("CARGO_CFG_TARGET_OS").unwrap();
+ let endian = var("CARGO_CFG_TARGET_ENDIAN").unwrap();
let mut cfg = cc::Build::new();
+
let msvc = cfg.get_compiler().is_like_msvc();
- let asm = if let Some((asm, canswitch)) = find_assembly(&arch, &endian, &os, &env, msvc) {
+ // If we're targeting msvc, either via regular MS toolchain or clang-cl, we
+ // will _usually_ want to use the regular Microsoft assembler if it exists,
+ // which is done for us within cc, however it _probably_ won't exist if
+ // we're in a cross-compilation context pm a platform that can't natively
+ // run Windows executables, so in that case we instead use the the equivalent
+ // GAS assembly file instead. This logic can be removed once LLVM natively
+ // supports compiling MASM, but that is not stable yet
+ let masm = msvc && var("HOST").expect("HOST env not set").contains("windows");
+
+ let asm = if let Some((asm, canswitch)) = find_assembly(&arch, &endian, &os, &env, masm) {
println!("cargo:rustc-cfg=asm");
if canswitch {
println!("cargo:rustc-cfg=switchable_stack")