Skip to content

Fix empty target_config in apply_rust_config bootstrap #144126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,7 @@ mod snapshot {
#[test]
fn doc_core_no_std_target() {
let ctx = TestCtx::new();

insta::assert_snapshot!(
ctx.config("doc")
.path("core")
Expand All @@ -1646,6 +1647,7 @@ mod snapshot {
#[test]
fn doc_library_no_std_target() {
let ctx = TestCtx::new();

insta::assert_snapshot!(
ctx.config("doc")
.path("library")
Expand Down
3 changes: 1 addition & 2 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ impl Config {
config.rust_profile_use = flags_rust_profile_use;
config.rust_profile_generate = flags_rust_profile_generate;

config.apply_target_config(toml.target);
config.apply_rust_config(toml.rust, flags_warnings);

config.reproducible_artifacts = flags_reproducible_artifact;
Expand All @@ -967,8 +968,6 @@ impl Config {

config.apply_gcc_config(toml.gcc);

config.apply_target_config(toml.target);

match ccache {
Some(StringOrBool::String(ref s)) => config.ccache = Some(s.to_string()),
Some(StringOrBool::Bool(true)) => {
Expand Down
11 changes: 10 additions & 1 deletion src/bootstrap/src/core/config/toml/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,14 @@ pub(crate) fn validate_codegen_backends(backends: Vec<String>, section: &str) ->
}
backends
}
#[cfg(not(test))]
fn default_lld_opt_in_targets() -> &'static [&'static str] {
&["x86_64-unknown-linux-gnu"]
}
#[cfg(test)]
fn default_lld_opt_in_targets() -> &'static [&'static str] {
&[]
}

impl Config {
pub fn apply_rust_config(&mut self, toml_rust: Option<Rust>, warnings: Warnings) {
Expand Down Expand Up @@ -609,7 +617,8 @@ impl Config {
// thus, disabled
// - similarly, lld will not be built nor used by default when explicitly asked not to, e.g.
// when the config sets `rust.lld = false`
if self.host_target.triple == "x86_64-unknown-linux-gnu" && self.hosts == [self.host_target]
if default_lld_opt_in_targets().contains(&self.host_target.triple.to_string().as_str())
&& self.hosts == [self.host_target]
{
let no_llvm_config = self
.target_config
Expand Down
Loading