1
- use std:: { collections:: HashSet , env } ;
1
+ use std:: collections:: HashSet ;
2
2
3
3
/// Features to enable
4
4
#[ derive( Debug , PartialEq , Eq , Hash ) ]
@@ -9,35 +9,39 @@ enum Feature {
9
9
NoSysF16F128Convert ,
10
10
}
11
11
12
+ mod builtins_configure {
13
+ include ! ( "../configure.rs" ) ;
14
+ }
15
+
12
16
fn main ( ) {
13
- let target = env :: var ( "TARGET" ) . unwrap ( ) ;
17
+ let target = builtins_configure :: Target :: from_env ( ) ;
14
18
let mut features = HashSet :: new ( ) ;
15
19
16
20
// These platforms do not have f128 symbols available in their system libraries, so
17
21
// skip related tests.
18
- if target. starts_with ( "arm-" )
19
- || target. contains ( "apple-darwin" )
20
- || target. contains ( "windows- msvc")
22
+ if target. arch == "arm"
23
+ || target. vendor == "apple"
24
+ || target. env == " msvc"
21
25
// GCC and LLVM disagree on the ABI of `f16` and `f128` with MinGW. See
22
26
// <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>.
23
- || target. contains ( "windows- gnu" )
27
+ || ( target. os == "windows" && target . env == " gnu")
24
28
// FIXME(llvm): There is an ABI incompatibility between GCC and Clang on 32-bit x86.
25
29
// See <https://github.com/llvm/llvm-project/issues/77401>.
26
- || target. starts_with ( "i686" )
30
+ || target. arch == "i686"
27
31
// 32-bit PowerPC and 64-bit LE gets code generated that Qemu cannot handle. See
28
32
// <https://github.com/rust-lang/compiler-builtins/pull/606#issuecomment-2105635926>.
29
- || target. starts_with ( "powerpc-" )
30
- || target. starts_with ( "powerpc64le-" )
33
+ || target. arch == "powerpc"
34
+ || target. arch == "powerpc64le"
31
35
// FIXME: We get different results from the builtin functions. See
32
36
// <https://github.com/rust-lang/compiler-builtins/pull/606#issuecomment-2105657287>.
33
- || target. starts_with ( "powerpc64-" )
37
+ || target. arch == "powerpc64"
34
38
{
35
39
features. insert ( Feature :: NoSysF128 ) ;
36
40
features. insert ( Feature :: NoSysF128IntConvert ) ;
37
41
features. insert ( Feature :: NoSysF16F128Convert ) ;
38
42
}
39
43
40
- if target. starts_with ( "i586" ) || target. starts_with ( "i686" ) {
44
+ if target. arch == "i586" || target. arch == "i686" {
41
45
// 32-bit x86 does not have `__fixunstfti`/`__fixtfti` but does have everything else
42
46
features. insert ( Feature :: NoSysF128IntConvert ) ;
43
47
// FIXME: 32-bit x86 has a bug in `f128 -> f16` system libraries
@@ -46,17 +50,18 @@ fn main() {
46
50
47
51
// These platforms do not have f16 symbols available in their system libraries, so
48
52
// skip related tests. Most of these are missing `f16 <-> f32` conversion routines.
49
- if ( target. starts_with ( "aarch64-" ) && target. contains ( "linux" ) )
50
- || target. starts_with ( "arm" )
51
- || target. starts_with ( "powerpc-" )
52
- || target. starts_with ( "powerpc64-" )
53
- || target. starts_with ( "powerpc64le-" )
54
- || target. starts_with ( "i586-" )
55
- || target. contains ( "windows-" )
53
+ if ( target. arch == "aarch64" && target. os == "linux" )
54
+ || target. arch == "arm"
55
+ || target. arch == "powerpc"
56
+ || target. arch == "powerpc64le"
57
+ || target. arch == "powerpc64le"
58
+ || target. arch == "i586"
59
+ || target. os == "windows"
56
60
// Linking says "error: function signature mismatch: __extendhfsf2" and seems to
57
61
// think the signature is either `(i32) -> f32` or `(f32) -> f32`. See
58
62
// <https://github.com/llvm/llvm-project/issues/96438>.
59
- || target. starts_with ( "wasm" )
63
+ || target. arch == "wasm32"
64
+ || target. arch == "wasm64"
60
65
{
61
66
features. insert ( Feature :: NoSysF16 ) ;
62
67
features. insert ( Feature :: NoSysF16F128Convert ) ;
@@ -78,4 +83,6 @@ fn main() {
78
83
println ! ( "cargo:warning={warning}" ) ;
79
84
println ! ( "cargo:rustc-cfg=feature=\" {name}\" " ) ;
80
85
}
86
+
87
+ builtins_configure:: configure_f16_f128 ( & target) ;
81
88
}
0 commit comments