@@ -85,6 +85,11 @@ fn main() {
85
85
println ! ( "cargo:rustc-check-cfg=cfg(reliable_f16)" ) ;
86
86
println ! ( "cargo:rustc-check-cfg=cfg(reliable_f128)" ) ;
87
87
88
+ // This is a step beyond only having the types and basic functions available. Math functions
89
+ // aren't consistently available or correct.
90
+ println ! ( "cargo:rustc-check-cfg=cfg(reliable_f16_math)" ) ;
91
+ println ! ( "cargo:rustc-check-cfg=cfg(reliable_f128_math)" ) ;
92
+
88
93
let has_reliable_f16 = match ( target_arch. as_str ( ) , target_os. as_str ( ) ) {
89
94
// Selection failure until recent LLVM <https://github.com/llvm/llvm-project/issues/93894>
90
95
// FIXME(llvm19): can probably be removed at the version bump
@@ -128,10 +133,42 @@ fn main() {
128
133
_ => false ,
129
134
} ;
130
135
136
+ // These are currently empty, but will fill up as some platforms move from completely
137
+ // unreliable to reliable basics but unreliable math.
138
+
139
+ // LLVM is currenlty adding missing routines, <https://github.com/llvm/llvm-project/issues/93566>
140
+ let has_reliable_f16_math = has_reliable_f16
141
+ && match ( target_arch. as_str ( ) , target_os. as_str ( ) ) {
142
+ // Currently nothing special. Hooray!
143
+ // This will change as platforms gain better better support for standard ops but math
144
+ // lags behind.
145
+ _ => true ,
146
+ } ;
147
+
148
+ let has_reliable_f128_math = has_reliable_f128
149
+ && match ( target_arch. as_str ( ) , target_os. as_str ( ) ) {
150
+ // LLVM lowers `fp128` math to `long double` symbols even on platforms where
151
+ // `long double` is not IEEE binary128. See
152
+ // <https://github.com/llvm/llvm-project/issues/44744>.
153
+ //
154
+ // This rules out anything that doesn't have `long double` = `binary128`; <= 32 bits
155
+ // (ld is `f64`), anything other than Linux (Windows and MacOS use ``f64`), and `x86`
156
+ // (ld is 80-bit extended precision).
157
+ ( "x86_64" , _) => false ,
158
+ ( _, "linux" ) if target_pointer_width == 64 => true ,
159
+ _ => false ,
160
+ } ;
161
+
131
162
if has_reliable_f16 {
132
163
println ! ( "cargo:rustc-cfg=reliable_f16" ) ;
133
164
}
134
165
if has_reliable_f128 {
135
166
println ! ( "cargo:rustc-cfg=reliable_f128" ) ;
136
167
}
168
+ if has_reliable_f16_math {
169
+ println ! ( "cargo:rustc-cfg=reliable_f16_math" ) ;
170
+ }
171
+ if has_reliable_f128_math {
172
+ println ! ( "cargo:rustc-cfg=reliable_f128_math" ) ;
173
+ }
137
174
}
0 commit comments