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