@@ -14,12 +14,9 @@ fn main() {
1414 configure_check_cfg ( ) ;
1515 configure_f16_f128 ( & target) ;
1616
17- println ! ( "cargo:compiler-rt={}" , cwd . join ( "compiler-rt" ) . display ( ) ) ;
17+ configure_libm ( & target ) ;
1818
19- // Activate libm's unstable features to make full use of Nightly.
20- println ! ( "cargo::rustc-check-cfg=cfg(feature, values(\" unstable\" , \" force-soft-floats\" ))" ) ;
21- println ! ( "cargo:rustc-cfg=feature=\" unstable\" " ) ;
22- println ! ( "cargo:rustc-cfg=feature=\" force-soft-floats\" " ) ;
19+ println ! ( "cargo:compiler-rt={}" , cwd. join( "compiler-rt" ) . display( ) ) ;
2320
2421 // Emscripten's runtime includes all the builtins
2522 if target. os == "emscripten" {
@@ -104,6 +101,46 @@ fn main() {
104101 }
105102}
106103
104+ /// Run configuration for `libm` since it is included directly.
105+ ///
106+ /// Much of this is copied from `libm/configure.rs`.
107+ fn configure_libm ( target : & Target ) {
108+ println ! ( "cargo:rustc-cfg=intrinsics_enabled" ) ;
109+ println ! ( "cargo:rustc-cfg=arch_enabled" ) ;
110+ println ! ( "cargo:rustc-cfg=optimizations_enabled" ) ;
111+
112+ // Always use intrinsics
113+ println ! ( "cargo:rustc-cfg=intrinsics_enabled" ) ;
114+
115+ if cfg ! ( feature = "no-asm" ) {
116+ println ! ( "cargo:rustc-cfg=feature=\" force-soft-floats\" " ) ;
117+ } else {
118+ println ! ( "cargo:rustc-cfg=arch_enabled" ) ;
119+ }
120+
121+ println ! ( "cargo:rustc-check-cfg=cfg(optimizations_enabled)" ) ;
122+ if target. opt_level >= 2 {
123+ println ! ( "cargo:rustc-cfg=optimizations_enabled" ) ;
124+ }
125+
126+ // Config shorthands
127+ println ! ( "cargo:rustc-check-cfg=cfg(x86_no_sse)" ) ;
128+ if target. arch == "x86" && !target. features . iter ( ) . any ( |f| f == "sse" ) {
129+ // Shorthand to detect i586 targets
130+ println ! ( "cargo:rustc-cfg=x86_no_sse" ) ;
131+ }
132+
133+ println ! (
134+ "cargo:rustc-env=CFG_CARGO_FEATURES={:?}" ,
135+ target. cargo_features
136+ ) ;
137+ println ! ( "cargo:rustc-env=CFG_OPT_LEVEL={}" , target. opt_level) ;
138+ println ! ( "cargo:rustc-env=CFG_TARGET_FEATURES={:?}" , target. features) ;
139+
140+ // Activate libm's unstable features to make full use of Nightly.
141+ println ! ( "cargo:rustc-cfg=feature=\" unstable-intrinsics\" " ) ;
142+ }
143+
107144fn aarch64_symbol ( ordering : Ordering ) -> & ' static str {
108145 match ordering {
109146 Ordering :: Relaxed => "relax" ,
0 commit comments