@@ -6,6 +6,7 @@ use std::env;
66#[ allow( dead_code) ]
77pub struct Target {
88 pub triple : String ,
9+ pub triple_split : Vec < String > ,
910 pub opt_level : String ,
1011 pub cargo_features : Vec < String > ,
1112 pub os : String ,
@@ -19,6 +20,8 @@ pub struct Target {
1920
2021impl Target {
2122 pub fn from_env ( ) -> Self {
23+ let triple = env:: var ( "TARGET" ) . unwrap ( ) ;
24+ let triple_split = triple. split ( '-' ) . map ( ToOwned :: to_owned) . collect ( ) ;
2225 let little_endian = match env:: var ( "CARGO_CFG_TARGET_ENDIAN" ) . unwrap ( ) . as_str ( ) {
2326 "little" => true ,
2427 "big" => false ,
@@ -30,7 +33,8 @@ impl Target {
3033 . collect ( ) ;
3134
3235 Self {
33- triple : env:: var ( "TARGET" ) . unwrap ( ) ,
36+ triple,
37+ triple_split,
3438 os : env:: var ( "CARGO_CFG_TARGET_OS" ) . unwrap ( ) ,
3539 opt_level : env:: var ( "OPT_LEVEL" ) . unwrap ( ) ,
3640 cargo_features,
@@ -56,6 +60,22 @@ impl Target {
5660 }
5761}
5862
63+ pub fn configure_aliases ( target : & Target ) {
64+ // To compile intrinsics.rs for thumb targets, where there is no libc
65+ println ! ( "cargo::rustc-check-cfg=cfg(thumb)" ) ;
66+ if target. triple_split [ 0 ] . starts_with ( "thumb" ) {
67+ println ! ( "cargo:rustc-cfg=thumb" )
68+ }
69+
70+ // compiler-rt `cfg`s away some intrinsics for thumbv6m and thumbv8m.base because
71+ // these targets do not have full Thumb-2 support but only original Thumb-1.
72+ // We have to cfg our code accordingly.
73+ println ! ( "cargo::rustc-check-cfg=cfg(thumb_1)" ) ;
74+ if target. triple_split [ 0 ] == "thumbv6m" || target. triple_split [ 0 ] == "thumbv8m.base" {
75+ println ! ( "cargo:rustc-cfg=thumb_1" )
76+ }
77+ }
78+
5979/// Configure whether or not `f16` and `f128` support should be enabled.
6080pub fn configure_f16_f128 ( target : & Target ) {
6181 // Set whether or not `f16` and `f128` are supported at a basic level by LLVM. This only means
0 commit comments