Skip to content

Commit 7139d45

Browse files
committed
Optimize the build.rs program.
Avoid doing feature tests for features that won't be needed. This significantly speeds up the speed of the build script.
1 parent dcb29c5 commit 7139d45

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

build.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ fn main() {
1111
// the rustc version.
1212
println!("cargo:rerun-if-changed=build.rs");
1313

14-
use_feature_or_nothing("vec_into_raw_parts");
15-
use_feature_or_nothing("toowned_clone_into");
1614
use_feature_or_nothing("rustc_attrs");
17-
use_feature_or_nothing("specialization");
18-
use_feature_or_nothing("slice_internals");
19-
use_feature_or_nothing("const_raw_ptr_deref");
15+
16+
// Features only used in no-std configurations.
17+
#[cfg(not(feature = "std"))]
18+
{
19+
use_feature_or_nothing("vec_into_raw_parts");
20+
use_feature_or_nothing("toowned_clone_into");
21+
use_feature_or_nothing("specialization");
22+
use_feature_or_nothing("slice_internals");
23+
use_feature_or_nothing("const_raw_ptr_deref");
24+
}
2025

2126
let arch = var("CARGO_CFG_TARGET_ARCH").unwrap();
2227
let asm_name = format!("{}/{}.s", OUTLINE_PATH, arch);
@@ -34,10 +39,7 @@ fn main() {
3439
use_feature("libc");
3540
} else {
3641
use_feature("linux_raw");
37-
3842
use_feature_or_nothing("core_intrinsics");
39-
use_feature_or_nothing("doc_cfg");
40-
4143
use_feature_or_else("asm", || {
4244
link_in_librustix_outline(&arch, &asm_name);
4345
});

0 commit comments

Comments
 (0)