From e8df637c619c749a52aead3fb6b8f73ed3ed17d6 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Wed, 3 Jul 2024 13:44:02 +0200 Subject: [PATCH 1/3] library/std/build.rs: "powerpc64le" is not a target_arch The target_arch of `powerpc64le` is `powerpc64`, so `powerpc64le` can be removed from a match arm in build.rs related to f16. You can check available `target_arch`:s with: $ rustc +nightly -Zunstable-options --print all-target-specs-json \ | grep powerpc | grep arch | sort | uniq "arch": "powerpc", "arch": "powerpc64", --- library/std/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/build.rs b/library/std/build.rs index 55388648a14..eaffad5b131 100644 --- a/library/std/build.rs +++ b/library/std/build.rs @@ -99,7 +99,7 @@ fn main() { // the compiler-builtins update. ("x86" | "x86_64", _) => false, // Missing `__gnu_h2f_ieee` and `__gnu_f2h_ieee` - ("powerpc" | "powerpc64" | "powerpc64le", _) => false, + ("powerpc" | "powerpc64", _) => false, // Missing `__extendhfsf` and `__truncsfhf` ("riscv32" | "riscv64", _) => false, // Most OSs are missing `__extendhfsf` and `__truncsfhf` From 310d4efca2a36363a236788077bbd1a7a06c4db1 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Mon, 1 Jul 2024 11:27:54 +0200 Subject: [PATCH 2/3] std: Set has_reliable_f16 to false for MIPS targets in build.rs To avoid this linker error: $ sudo apt install libc6-mips-cross gcc-mips-linux-gnu $ CC_mips_unknown_linux_gnu=mips-linux-gnu-gcc \ CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \ ./x test library/std --target mips-unknown-linux-gnu undefined reference to `__gnu_f2h_ieee' You get the same linker error also with mipsel, mips64 and mips64el toolchains. --- library/std/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/std/build.rs b/library/std/build.rs index eaffad5b131..c542ba81eed 100644 --- a/library/std/build.rs +++ b/library/std/build.rs @@ -100,6 +100,8 @@ fn main() { ("x86" | "x86_64", _) => false, // Missing `__gnu_h2f_ieee` and `__gnu_f2h_ieee` ("powerpc" | "powerpc64", _) => false, + // Missing `__gnu_h2f_ieee` and `__gnu_f2h_ieee` + ("mips" | "mips32r6" | "mips64" | "mips64r6", _) => false, // Missing `__extendhfsf` and `__truncsfhf` ("riscv32" | "riscv64", _) => false, // Most OSs are missing `__extendhfsf` and `__truncsfhf` From 6f9ec578cb5143b97d96a8399edf698398d3d2bb Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Mon, 1 Jul 2024 17:37:00 +0200 Subject: [PATCH 3/3] core: Limit four f16 doctests to x86_64 linux These tests have link errors on many platforms, so limit them to only x86_64 linux for now. There are many other f16 non-doctests, so we don't need to run these particular ones widely. --- library/core/src/num/f16.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs index 3c58b0af9c2..e74300d6c2f 100644 --- a/library/core/src/num/f16.rs +++ b/library/core/src/num/f16.rs @@ -507,8 +507,8 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # // FIXME(f16_f128): remove when `extendhfsf2` and `truncsfhf2` are available - /// # #[cfg(target_os = "linux")] { + /// # // FIXME(f16_f128): extendhfsf2, truncsfhf2, __gnu_h2f_ieee, __gnu_f2h_ieee missing for many platforms + /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { /// /// let x = 2.0_f16; /// let abs_difference = (x.recip() - (1.0 / x)).abs(); @@ -528,8 +528,8 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # // FIXME(f16_f128): remove when `extendhfsf2` and `truncsfhf2` are available - /// # #[cfg(target_os = "linux")] { + /// # // FIXME(f16_f128): extendhfsf2, truncsfhf2, __gnu_h2f_ieee, __gnu_f2h_ieee missing for many platforms + /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { /// /// let angle = std::f16::consts::PI; /// @@ -551,8 +551,8 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # // FIXME(f16_f128): remove when `extendhfsf2` and `truncsfhf2` are available - /// # #[cfg(target_os = "linux")] { + /// # // FIXME(f16_f128): extendhfsf2, truncsfhf2, __gnu_h2f_ieee, __gnu_f2h_ieee missing for many platforms + /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { /// /// let angle = 180.0f16; /// @@ -870,6 +870,8 @@ impl f16 { /// /// ``` /// #![feature(f16)] + /// # // FIXME(f16_f128): extendhfsf2, truncsfhf2, __gnu_h2f_ieee, __gnu_f2h_ieee missing for many platforms + /// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] { /// /// struct GoodBoy { /// name: &'static str, @@ -897,6 +899,7 @@ impl f16 { /// .zip([-5.0, 0.1, 10.0, 99.0, f16::INFINITY, f16::NAN].iter()) /// .for_each(|(a, b)| assert_eq!(a.to_bits(), b.to_bits())) /// } + /// # } /// ``` #[inline] #[must_use]