@@ -7,6 +7,10 @@ fn main() {
7
7
let target_vendor =
8
8
env:: var ( "CARGO_CFG_TARGET_VENDOR" ) . expect ( "CARGO_CFG_TARGET_VENDOR was not set" ) ;
9
9
let target_env = env:: var ( "CARGO_CFG_TARGET_ENV" ) . expect ( "CARGO_CFG_TARGET_ENV was not set" ) ;
10
+ let target_pointer_width: u32 = env:: var ( "CARGO_CFG_TARGET_POINTER_WIDTH" )
11
+ . expect ( "CARGO_CFG_TARGET_POINTER_WIDTH was not set" )
12
+ . parse ( )
13
+ . unwrap ( ) ;
10
14
11
15
println ! ( "cargo:rustc-check-cfg=cfg(netbsd10)" ) ;
12
16
if target_os == "netbsd" && env:: var ( "RUSTC_STD_NETBSD10" ) . is_ok ( ) {
@@ -70,4 +74,62 @@ fn main() {
70
74
println ! ( "cargo:rustc-cfg=backtrace_in_libstd" ) ;
71
75
72
76
println ! ( "cargo:rustc-env=STD_ENV_ARCH={}" , env:: var( "CARGO_CFG_TARGET_ARCH" ) . unwrap( ) ) ;
77
+
78
+ // Emit these on platforms that have no known ABI bugs, LLVM selection bugs, lowering bugs,
79
+ // missing symbols, or other problems, to determine when tests get run.
80
+ // If more broken platforms are found, please update the tracking issue at
81
+ // <https://github.com/rust-lang/rust/issues/116909>
82
+ //
83
+ // Some of these match arms are redundant; the goal is to separate reasons that the type is
84
+ // unreliable, even when multiple reasons might fail the same platform.
85
+ println ! ( "cargo:rustc-check-cfg=cfg(reliable_f16)" ) ;
86
+ println ! ( "cargo:rustc-check-cfg=cfg(reliable_f128)" ) ;
87
+
88
+ let has_reliable_f16 = match ( target_arch. as_str ( ) , target_os. as_str ( ) ) {
89
+ // Selection failure until recent LLVM <https://github.com/llvm/llvm-project/issues/93894>
90
+ // FIXME(llvm19): can probably be removed at the version bump
91
+ ( "loongarch64" , _) => false ,
92
+ // Selection failure <https://github.com/llvm/llvm-project/issues/50374>
93
+ ( "s390x" , _) => false ,
94
+ // Unsupported <https://github.com/llvm/llvm-project/issues/94434>
95
+ ( "arm64ec" , _) => false ,
96
+ // MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
97
+ ( "x86" , "windows" ) => false ,
98
+ // x86 has ABI bugs that show up with optimizations. This should be partially fixed with
99
+ // the compiler-builtins update. <https://github.com/rust-lang/rust/issues/123885>
100
+ ( "x86" | "x86_64" , _) => false ,
101
+ // Missing `__gnu_h2f_ieee` and `__gnu_f2h_ieee`
102
+ ( "powerpc" | "powerpc64" | "powerpc64le" , _) => false ,
103
+ // Missing `__extendhfsf` and `__truncsfhf`
104
+ ( "riscv32" | "riscv64" , _) => false ,
105
+ // Most OSs are missing `__extendhfsf` and `__truncsfhf`
106
+ ( _, "linux" | "macos" ) => true ,
107
+ // Almost all OSs besides Linux and MacOS are missing symbols until compiler-builtins can
108
+ // be updated. <https://github.com/rust-lang/rust/pull/125016> will get some of these, the
109
+ // next CB update should get the rest.
110
+ _ => false ,
111
+ } ;
112
+
113
+ let has_reliable_f128 = match ( target_arch. as_str ( ) , target_os. as_str ( ) ) {
114
+ // Unsupported <https://github.com/llvm/llvm-project/issues/94434>
115
+ ( "arm64ec" , _) => false ,
116
+ // ABI and precision bugs <https://github.com/rust-lang/rust/issues/125109>
117
+ // <https://github.com/rust-lang/rust/issues/125102>
118
+ ( "powerpc" | "powerpc64" , _) => false ,
119
+ // Selection bug <https://github.com/llvm/llvm-project/issues/95471>
120
+ ( "nvptx64" , _) => false ,
121
+ // ABI unsupported <https://github.com/llvm/llvm-project/issues/41838>
122
+ ( "sparc" , _) => false ,
123
+ // 64-bit Linux is about the only platform to have f128 symbols by default
124
+ ( _, "linux" ) if target_pointer_width == 64 => true ,
125
+ // Same as for f16, except MacOS is also missing f128 symbols.
126
+ _ => false ,
127
+ } ;
128
+
129
+ if has_reliable_f16 {
130
+ println ! ( "cargo:rustc-cfg=reliable_f16" ) ;
131
+ }
132
+ if has_reliable_f128 {
133
+ println ! ( "cargo:rustc-cfg=reliable_f128" ) ;
134
+ }
73
135
}
0 commit comments