Skip to content

Commit c724ebf

Browse files
committed
bootstrap: add std_features config to rust section
1 parent 7b18b3e commit c724ebf

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

src/bootstrap/src/core/config/config.rs

+9
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ pub struct Config {
287287
pub rust_profile_generate: Option<String>,
288288
pub rust_lto: RustcLto,
289289
pub rust_validate_mir_opts: Option<u32>,
290+
pub rust_std_features: Option<Vec<String>>,
290291
pub llvm_profile_use: Option<String>,
291292
pub llvm_profile_generate: bool,
292293
pub llvm_libunwind_default: Option<LlvmLibunwind>,
@@ -1141,6 +1142,7 @@ define_config! {
11411142
download_rustc: Option<StringOrBool> = "download-rustc",
11421143
lto: Option<String> = "lto",
11431144
validate_mir_opts: Option<u32> = "validate-mir-opts",
1145+
std_features: Option<Vec<String>> = "std_features"
11441146
}
11451147
}
11461148

@@ -1621,6 +1623,7 @@ impl Config {
16211623
let mut optimize = None;
16221624
let mut omit_git_hash = None;
16231625
let mut lld_enabled = None;
1626+
let mut std_features = None;
16241627

16251628
let mut is_user_configured_rust_channel = false;
16261629

@@ -1679,6 +1682,7 @@ impl Config {
16791682
stack_protector,
16801683
strip,
16811684
lld_mode,
1685+
std_features: std_features_toml,
16821686
} = rust;
16831687

16841688
is_user_configured_rust_channel = channel.is_some();
@@ -1698,6 +1702,7 @@ impl Config {
16981702
debuginfo_level_tools = debuginfo_level_tools_toml;
16991703
debuginfo_level_tests = debuginfo_level_tests_toml;
17001704
lld_enabled = lld_enabled_toml;
1705+
std_features = std_features_toml;
17011706

17021707
optimize = optimize_toml;
17031708
omit_git_hash = omit_git_hash_toml;
@@ -2103,6 +2108,9 @@ impl Config {
21032108
);
21042109
}
21052110

2111+
// std_features chosen during bootstrap
2112+
config.rust_std_features = std_features.unwrap_or_default();
2113+
21062114
let default = debug == Some(true);
21072115
config.rust_debug_assertions = debug_assertions.unwrap_or(default);
21082116
config.rust_debug_assertions_std =
@@ -2949,6 +2957,7 @@ fn check_incompatible_options_for_ci_rustc(
29492957
download_rustc: _,
29502958
validate_mir_opts: _,
29512959
frame_pointers: _,
2960+
std_features: _,
29522961
} = ci_rust_config;
29532962

29542963
// There are two kinds of checks for CI rustc incompatible options:

src/bootstrap/src/lib.rs

+18-8
Original file line numberDiff line numberDiff line change
@@ -655,27 +655,37 @@ impl Build {
655655
}
656656

657657
/// Gets the space-separated set of activated features for the standard
658-
/// library.
658+
/// library. This can be configured with the `std_features` key in config.toml.
659659
fn std_features(&self, target: TargetSelection) -> String {
660-
let mut features = " panic-unwind".to_string();
660+
let mut features = if let Some(features) = &self.config.rust_std_features {
661+
features.iter().map(|s| s.as_ref()).collect::<Vec<&str>>()
662+
} else {
663+
vec![]
664+
};
665+
666+
if !features.contains(&"panic-unwind") {
667+
features.push("panic-unwind");
668+
}
661669

662670
match self.config.llvm_libunwind(target) {
663-
LlvmLibunwind::InTree => features.push_str(" llvm-libunwind"),
664-
LlvmLibunwind::System => features.push_str(" system-llvm-libunwind"),
671+
LlvmLibunwind::InTree => features.push("llvm-libunwind"),
672+
LlvmLibunwind::System => features.push("system-llvm-libunwind"),
665673
LlvmLibunwind::No => {}
666674
}
667675
if self.config.backtrace {
668-
features.push_str(" backtrace");
676+
features.push("backtrace");
669677
}
670678
if self.config.profiler_enabled(target) {
671-
features.push_str(" profiler");
679+
features.push("profiler");
672680
}
673681
// Generate memcpy, etc. FIXME: Remove this once compiler-builtins
674682
// automatically detects this target.
675683
if target.contains("zkvm") {
676-
features.push_str(" compiler-builtins-mem");
684+
features.push("compiler-builtins-mem");
677685
}
678-
features
686+
687+
// remove duplicates
688+
features.into_iter().collect::<HashSet<_>>().into_iter().collect::<Vec<_>>().join(" ")
679689
}
680690

681691
/// Gets the space-separated set of activated features for the compiler.

0 commit comments

Comments
 (0)