@@ -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
@@ -130,10 +135,42 @@ fn main() {
130
135
_ => false ,
131
136
} ;
132
137
138
+ // These are currently empty, but will fill up as some platforms move from completely
139
+ // unreliable to reliable basics but unreliable math.
140
+
141
+ // LLVM is currenlty adding missing routines, <https://github.com/llvm/llvm-project/issues/93566>
142
+ let has_reliable_f16_math = has_reliable_f16
143
+ && match ( target_arch. as_str ( ) , target_os. as_str ( ) ) {
144
+ // Currently nothing special. Hooray!
145
+ // This will change as platforms gain better better support for standard ops but math
146
+ // lags behind.
147
+ _ => true ,
148
+ } ;
149
+
150
+ let has_reliable_f128_math = has_reliable_f128
151
+ && match ( target_arch. as_str ( ) , target_os. as_str ( ) ) {
152
+ // LLVM lowers `fp128` math to `long double` symbols even on platforms where
153
+ // `long double` is not IEEE binary128. See
154
+ // <https://github.com/llvm/llvm-project/issues/44744>.
155
+ //
156
+ // This rules out anything that doesn't have `long double` = `binary128`; <= 32 bits
157
+ // (ld is `f64`), anything other than Linux (Windows and MacOS use `f64`), and `x86`
158
+ // (ld is 80-bit extended precision).
159
+ ( "x86_64" , _) => false ,
160
+ ( _, "linux" ) if target_pointer_width == 64 => true ,
161
+ _ => false ,
162
+ } ;
163
+
133
164
if has_reliable_f16 {
134
165
println ! ( "cargo:rustc-cfg=reliable_f16" ) ;
135
166
}
136
167
if has_reliable_f128 {
137
168
println ! ( "cargo:rustc-cfg=reliable_f128" ) ;
138
169
}
170
+ if has_reliable_f16_math {
171
+ println ! ( "cargo:rustc-cfg=reliable_f16_math" ) ;
172
+ }
173
+ if has_reliable_f128_math {
174
+ println ! ( "cargo:rustc-cfg=reliable_f128_math" ) ;
175
+ }
139
176
}
0 commit comments