File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ fn main() -> io::Result<()> {
2424 println ! ( "cargo::rerun-if-changed=cxx" ) ;
2525 println ! ( "cargo::rerun-if-changed=src/apf_fuzz.cpp" ) ;
2626
27+ emit_shorthands ( ) ;
28+
2729 // NOTE(eddyb) `rustc_apfloat`'s own `build.rs` validated the version string.
2830 let ( _, llvm_commit_hash) = env ! ( "CARGO_PKG_VERSION" ) . split_once ( "+llvm-" ) . unwrap ( ) ;
2931 assert_eq ! ( llvm_commit_hash. len( ) , 12 ) ;
@@ -143,3 +145,19 @@ fn main() -> io::Result<()> {
143145
144146 Ok ( ( ) )
145147}
148+
149+ /// Convenient versions of repeated configuration.
150+ fn emit_shorthands ( ) {
151+ let target_arch = env:: var ( "CARGO_CFG_TARGET_ARCH" ) . unwrap ( ) ;
152+ let target_features = env:: var ( "CARGO_CFG_TARGET_FEATURE" )
153+ . map ( |feats| feats. split ( ',' ) . map ( ToOwned :: to_owned) . collect :: < Vec < _ > > ( ) )
154+ . unwrap_or_default ( ) ;
155+
156+ // Emit a config
157+ println ! ( "cargo::rustc-check-cfg=cfg(x86_sse2)" ) ;
158+ if ( target_arch == "x86_64" || target_arch == "x86" )
159+ && target_features. iter ( ) . any ( |feat| feat == "sse2" )
160+ {
161+ println ! ( "cargo::rustc-cfg=x86_sse2" ) ;
162+ }
163+ }
You can’t perform that action at this time.
0 commit comments