@@ -2,41 +2,46 @@ use std::env;
22
33fn main ( ) {
44 println ! ( "cargo:rerun-if-changed=build.rs" ) ;
5- let target = env:: var ( "TARGET" ) . expect ( "TARGET was not set" ) ;
6- if target. contains ( "linux" )
7- || target. contains ( "netbsd" )
8- || target. contains ( "dragonfly" )
9- || target. contains ( "openbsd" )
10- || target. contains ( "freebsd" )
11- || target. contains ( "solaris" )
12- || target. contains ( "illumos" )
13- || target. contains ( "apple-darwin" )
14- || target. contains ( "apple-ios" )
15- || target. contains ( "apple-tvos" )
16- || target. contains ( "apple-watchos" )
17- || target. contains ( "uwp" )
18- || target. contains ( "windows" )
19- || target. contains ( "fuchsia" )
20- || ( target. contains ( "sgx" ) && target. contains ( "fortanix" ) )
21- || target. contains ( "hermit" )
22- || target. contains ( "l4re" )
23- || target. contains ( "redox" )
24- || target. contains ( "haiku" )
25- || target. contains ( "vxworks" )
26- || target. contains ( "wasm32" )
27- || target. contains ( "wasm64" )
28- || target. contains ( "espidf" )
29- || target. contains ( "solid" )
30- || target. contains ( "nintendo-3ds" )
31- || target. contains ( "vita" )
32- || target. contains ( "aix" )
33- || target. contains ( "nto" )
34- || target. contains ( "xous" )
35- || target. contains ( "hurd" )
36- || target. contains ( "uefi" )
37- || target. contains ( "teeos" )
38- || target. contains ( "zkvm" )
39- // See src/bootstrap/synthetic_targets.rs
5+ let target_arch = env:: var ( "CARGO_CFG_TARGET_ARCH" ) . expect ( "CARGO_CFG_TARGET_ARCH was not set" ) ;
6+ let target_os = env:: var ( "CARGO_CFG_TARGET_OS" ) . expect ( "CARGO_CFG_TARGET_OS was not set" ) ;
7+ let target_vendor =
8+ env:: var ( "CARGO_CFG_TARGET_VENDOR" ) . expect ( "CARGO_CFG_TARGET_VENDOR was not set" ) ;
9+ let target_env = env:: var ( "CARGO_CFG_TARGET_ENV" ) . expect ( "CARGO_CFG_TARGET_ENV was not set" ) ;
10+
11+ if target_os == "linux"
12+ || target_os == "netbsd"
13+ || target_os == "dragonfly"
14+ || target_os == "openbsd"
15+ || target_os == "freebsd"
16+ || target_os == "solaris"
17+ || target_os == "illumos"
18+ || target_os == "macos"
19+ || target_os == "ios"
20+ || target_os == "tvos"
21+ || target_os == "watchos"
22+ || target_os == "windows"
23+ || target_os == "fuchsia"
24+ || ( target_vendor == "fortranix" && target_env == "sgx" )
25+ || target_os == "hermit"
26+ || target_os == "l4re"
27+ || target_os == "redox"
28+ || target_os == "haiku"
29+ || target_os == "vxworks"
30+ || target_arch == "wasm32"
31+ || target_arch == "wasm64"
32+ || target_os == "espidf"
33+ || target_os. starts_with ( "solid" )
34+ || ( target_vendor == "nintendo" && target_env == "newlib" )
35+ || target_os == "vita"
36+ || target_os == "aix"
37+ || target_os == "nto"
38+ || target_os == "xous"
39+ || target_os == "hurd"
40+ || target_os == "uefi"
41+ || target_os == "teeos"
42+ || target_os == "zvkm"
43+
44+ // See src/bootstrap/src/core/build_steps/synthetic_targets.rs
4045 || env:: var ( "RUSTC_BOOTSTRAP_SYNTHETIC_TARGET" ) . is_ok ( )
4146 {
4247 // These platforms don't have any special requirements.
@@ -48,7 +53,7 @@ fn main() {
4853 // - mipsel-sony-psp
4954 // - nvptx64-nvidia-cuda
5055 // - arch=avr
51- // - JSON targets
56+ // - JSON targets not describing an excluded target above.
5257 // - Any new targets that have not been explicitly added above.
5358 println ! ( "cargo:rustc-cfg=feature=\" restricted-std\" " ) ;
5459 }
0 commit comments