about summary refs log tree commit diff
path: root/library
diff options
context:
space:
mode:
authorTrevor Gross <tmgross@umich.edu>2025-03-04 17:36:27 -0500
committerTrevor Gross <t.gross35@gmail.com>2025-03-04 18:05:02 -0500
commit968a7d0b7cdc071e866711a28466ae94e7c2b166 (patch)
tree5618b8db1d4339f50baf471c557ff4af74840e47 /library
parent340d3d4bd7b804e976c5196da26c2af60e6267c1 (diff)
downloadrust-968a7d0b7cdc071e866711a28466ae94e7c2b166.tar.gz
rust-968a7d0b7cdc071e866711a28466ae94e7c2b166.zip
Add a test config for __gnu_h2f_ieee and __gnu_f2h_ieee
Some targets do not provide these symbols since they always use
__extendhfsf and __truncsfhf. Add a configuration option for this.
Diffstat (limited to 'library')
-rw-r--r--library/compiler-builtins/testcrate/Cargo.toml3
-rw-r--r--library/compiler-builtins/testcrate/build.rs18
-rw-r--r--library/compiler-builtins/testcrate/tests/conv.rs4
3 files changed, 21 insertions, 4 deletions
diff --git a/library/compiler-builtins/testcrate/Cargo.toml b/library/compiler-builtins/testcrate/Cargo.toml
index 91e2f668fc7..e06864846fd 100644
--- a/library/compiler-builtins/testcrate/Cargo.toml
+++ b/library/compiler-builtins/testcrate/Cargo.toml
@@ -44,8 +44,9 @@ no-sys-f128 = ["no-sys-f128-int-convert", "no-sys-f16-f128-convert"]
 no-sys-f128-int-convert = []
 no-sys-f16-f128-convert = []
 no-sys-f16-f64-convert = []
+no-sys-f16-gnu-convert = []
 # Skip tests that rely on f16 symbols being available on the system
-no-sys-f16 = ["no-sys-f16-f64-convert"]
+no-sys-f16 = ["no-sys-f16-f64-convert", "no-sys-f16-gnu-convert"]
 
 # Enable report generation without bringing in more dependencies by default
 benchmarking-reports = ["criterion/plotters", "criterion/html_reports"]
diff --git a/library/compiler-builtins/testcrate/build.rs b/library/compiler-builtins/testcrate/build.rs
index 427fa799b8c..171c1d52114 100644
--- a/library/compiler-builtins/testcrate/build.rs
+++ b/library/compiler-builtins/testcrate/build.rs
@@ -12,6 +12,7 @@ enum Feature {
     NoSysF16,
     NoSysF16F64Convert,
     NoSysF16F128Convert,
+    NoSysF16GnuConvert,
 }
 
 impl Feature {
@@ -19,9 +20,15 @@ impl Feature {
         match self {
             Self::NoSysF128 => [Self::NoSysF128IntConvert, Self::NoSysF16F128Convert].as_slice(),
             Self::NoSysF128IntConvert => [].as_slice(),
-            Self::NoSysF16 => [Self::NoSysF16F64Convert, Self::NoSysF16F128Convert].as_slice(),
+            Self::NoSysF16 => [
+                Self::NoSysF16F64Convert,
+                Self::NoSysF16F128Convert,
+                Feature::NoSysF16GnuConvert,
+            ]
+            .as_slice(),
             Self::NoSysF16F64Convert => [].as_slice(),
             Self::NoSysF16F128Convert => [].as_slice(),
+            Self::NoSysF16GnuConvert => [].as_slice(),
         }
     }
 }
@@ -84,6 +91,11 @@ fn main() {
         features.insert(Feature::NoSysF16F64Convert);
     }
 
+    // These platforms do not have `__gnu_f2h_ieee` or `__gnu_h2f_ieee`.
+    if false {
+        features.insert(Feature::NoSysF16GnuConvert);
+    }
+
     // Add implied features. Collection is required for borrows.
     features.extend(
         features
@@ -108,6 +120,10 @@ fn main() {
                 "no-sys-f16-f128-convert",
                 "using apfloat fallback for f16 <-> f128 conversions",
             ),
+            Feature::NoSysF16GnuConvert => (
+                "no-sys-f16-gnu-convert",
+                "using apfloat fallback for __gnu f16",
+            ),
             Feature::NoSysF16 => ("no-sys-f16", "using apfloat fallback for f16"),
         };
         println!("cargo:warning={warning}");
diff --git a/library/compiler-builtins/testcrate/tests/conv.rs b/library/compiler-builtins/testcrate/tests/conv.rs
index 7f33d27cce0..f94aaf17402 100644
--- a/library/compiler-builtins/testcrate/tests/conv.rs
+++ b/library/compiler-builtins/testcrate/tests/conv.rs
@@ -310,7 +310,7 @@ mod extend {
     f_to_f! {
         extend,
         f16 => f32, Half => Single, __extendhfsf2, not(feature = "no-sys-f16");
-        f16 => f32, Half => Single, __gnu_h2f_ieee, not(feature = "no-sys-f16");
+        f16 => f32, Half => Single, __gnu_h2f_ieee, not(feature = "no-sys-f16-gnu-convert");
         f16 => f64, Half => Double, __extendhfdf2, not(feature = "no-sys-f16-f64-convert");
         f16 => f128, Half => Quad, __extendhftf2, not(feature = "no-sys-f16-f128-convert");
         f32 => f128, Single => Quad, __extendsftf2, not(feature = "no-sys-f128");
@@ -340,7 +340,7 @@ mod trunc {
     f_to_f! {
         trunc,
         f32 => f16, Single => Half, __truncsfhf2, not(feature = "no-sys-f16");
-        f32 => f16, Single => Half, __gnu_f2h_ieee, not(feature = "no-sys-f16");
+        f32 => f16, Single => Half, __gnu_f2h_ieee, not(feature = "no-sys-f16-gnu-convert");
         f64 => f16, Double => Half, __truncdfhf2, not(feature = "no-sys-f16-f64-convert");
         f128 => f16, Quad => Half, __trunctfhf2, not(feature = "no-sys-f16-f128-convert");
         f128 => f32, Quad => Single, __trunctfsf2, not(feature = "no-sys-f128");