Skip to content

Commit bb71a34

Browse files
committed
bootstrap: add std_features config to rust section
1 parent 5fe0e40 commit bb71a34

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

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

Lines changed: 9 additions & 0 deletions
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

@@ -1634,6 +1636,7 @@ impl Config {
16341636
let mut optimize = None;
16351637
let mut omit_git_hash = None;
16361638
let mut lld_enabled = None;
1639+
let mut std_features = None;
16371640

16381641
let mut is_user_configured_rust_channel = false;
16391642

@@ -1692,6 +1695,7 @@ impl Config {
16921695
stack_protector,
16931696
strip,
16941697
lld_mode,
1698+
std_features: std_features_toml,
16951699
} = rust;
16961700

16971701
is_user_configured_rust_channel = channel.is_some();
@@ -1711,6 +1715,7 @@ impl Config {
17111715
debuginfo_level_tools = debuginfo_level_tools_toml;
17121716
debuginfo_level_tests = debuginfo_level_tests_toml;
17131717
lld_enabled = lld_enabled_toml;
1718+
std_features = std_features_toml;
17141719

17151720
optimize = optimize_toml;
17161721
omit_git_hash = omit_git_hash_toml;
@@ -2091,6 +2096,9 @@ impl Config {
20912096
);
20922097
}
20932098

2099+
// std_features chosen during bootstrap
2100+
config.rust_std_features = std_features;
2101+
20942102
let default = debug == Some(true);
20952103
config.rust_debug_assertions = debug_assertions.unwrap_or(default);
20962104
config.rust_debug_assertions_std =
@@ -3029,6 +3037,7 @@ fn check_incompatible_options_for_ci_rustc(
30293037
download_rustc: _,
30303038
validate_mir_opts: _,
30313039
frame_pointers: _,
3040+
std_features: _,
30323041
} = ci_rust_config;
30333042

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

src/bootstrap/src/lib.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -662,27 +662,37 @@ impl Build {
662662
}
663663

664664
/// Gets the space-separated set of activated features for the standard
665-
/// library.
665+
/// library. This can be configured with the `std_features` key in config.toml.
666666
fn std_features(&self, target: TargetSelection) -> String {
667-
let mut features = " panic-unwind".to_string();
667+
let mut features = if let Some(features) = &self.config.rust_std_features {
668+
features.iter().map(|s| s.as_ref()).collect::<Vec<&str>>()
669+
} else {
670+
vec![]
671+
};
672+
673+
if !features.contains(&"panic-unwind") {
674+
features.push("panic-unwind");
675+
}
668676

669677
match self.config.llvm_libunwind(target) {
670-
LlvmLibunwind::InTree => features.push_str(" llvm-libunwind"),
671-
LlvmLibunwind::System => features.push_str(" system-llvm-libunwind"),
678+
LlvmLibunwind::InTree => features.push("llvm-libunwind"),
679+
LlvmLibunwind::System => features.push("system-llvm-libunwind"),
672680
LlvmLibunwind::No => {}
673681
}
674682
if self.config.backtrace {
675-
features.push_str(" backtrace");
683+
features.push("backtrace");
676684
}
677685
if self.config.profiler_enabled(target) {
678-
features.push_str(" profiler");
686+
features.push("profiler");
679687
}
680688
// Generate memcpy, etc. FIXME: Remove this once compiler-builtins
681689
// automatically detects this target.
682690
if target.contains("zkvm") {
683-
features.push_str(" compiler-builtins-mem");
691+
features.push("compiler-builtins-mem");
684692
}
685-
features
693+
694+
// remove duplicates
695+
features.into_iter().collect::<HashSet<_>>().into_iter().collect::<Vec<_>>().join(" ")
686696
}
687697

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

0 commit comments

Comments
 (0)