Skip to content

Commit 07ac02a

Browse files
committed
add default_lld_opt_in_targets method and modified test accordingly
1 parent c52d25b commit 07ac02a

File tree

2 files changed

+32
-49
lines changed

2 files changed

+32
-49
lines changed

src/bootstrap/src/core/builder/tests.rs

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,59 +1631,33 @@ mod snapshot {
16311631
#[test]
16321632
fn doc_core_no_std_target() {
16331633
let ctx = TestCtx::new();
1634-
if host_target() == "x86_64-unknown-linux-gnu" {
1635-
insta::assert_snapshot!(
1636-
ctx.config("doc")
1637-
.path("core")
1638-
.override_target_no_std(&host_target())
1639-
.render_steps(), @r"
1640-
[build] llvm <host>
1641-
[build] rustc 0 <host> -> rustc 1 <host>
1642-
[build] rustc 0 <host> -> LldWrapper 1 <host>
1643-
[build] rustdoc 0 <host>
1644-
[doc] std 1 <host> crates=[core]
1645-
");
1646-
} else {
1647-
insta::assert_snapshot!(
1648-
ctx.config("doc")
1649-
.path("core")
1650-
.override_target_no_std(&host_target())
1651-
.render_steps(), @r"
1652-
[build] llvm <host>
1653-
[build] rustc 0 <host> -> rustc 1 <host>
1654-
[build] rustdoc 0 <host>
1655-
[doc] std 1 <host> crates=[core]
1656-
");
1657-
}
1634+
1635+
insta::assert_snapshot!(
1636+
ctx.config("doc")
1637+
.path("core")
1638+
.override_target_no_std(&host_target())
1639+
.render_steps(), @r"
1640+
[build] llvm <host>
1641+
[build] rustc 0 <host> -> rustc 1 <host>
1642+
[build] rustdoc 0 <host>
1643+
[doc] std 1 <host> crates=[core]
1644+
");
16581645
}
16591646

16601647
#[test]
16611648
fn doc_library_no_std_target() {
16621649
let ctx = TestCtx::new();
1663-
if host_target() == "x86_64-unknown-linux-gnu" {
1664-
insta::assert_snapshot!(
1665-
ctx.config("doc")
1666-
.path("library")
1667-
.override_target_no_std(&host_target())
1668-
.render_steps(), @r"
1669-
[build] llvm <host>
1670-
[build] rustc 0 <host> -> rustc 1 <host>
1671-
[build] rustc 0 <host> -> LldWrapper 1 <host>
1672-
[build] rustdoc 0 <host>
1673-
[doc] std 1 <host> crates=[alloc,core]
1674-
");
1675-
} else {
1676-
insta::assert_snapshot!(
1677-
ctx.config("doc")
1678-
.path("library")
1679-
.override_target_no_std(&host_target())
1680-
.render_steps(), @r"
1681-
[build] llvm <host>
1682-
[build] rustc 0 <host> -> rustc 1 <host>
1683-
[build] rustdoc 0 <host>
1684-
[doc] std 1 <host> crates=[alloc,core]
1685-
");
1686-
}
1650+
1651+
insta::assert_snapshot!(
1652+
ctx.config("doc")
1653+
.path("library")
1654+
.override_target_no_std(&host_target())
1655+
.render_steps(), @r"
1656+
[build] llvm <host>
1657+
[build] rustc 0 <host> -> rustc 1 <host>
1658+
[build] rustdoc 0 <host>
1659+
[doc] std 1 <host> crates=[alloc,core]
1660+
");
16871661
}
16881662

16891663
#[test]

src/bootstrap/src/core/config/toml/rust.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,14 @@ pub(crate) fn validate_codegen_backends(backends: Vec<String>, section: &str) ->
409409
}
410410
backends
411411
}
412+
#[cfg(not(test))]
413+
fn default_lld_opt_in_targets() -> &'static [&'static str] {
414+
&["x86_64-unknown-linux-gnu"]
415+
}
416+
#[cfg(test)]
417+
fn default_lld_opt_in_targets() -> &'static [&'static str] {
418+
&[]
419+
}
412420

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

0 commit comments

Comments
 (0)