Skip to content

Commit 53e0313

Browse files
committed
Auto merge of #117684 - lqd:mcp510-crater, r=<try>
crater: test enabling MCP510 Tests pass at stage1 and 2 with the `x86_64-unknown-linux-gnu` target switched. CI passes in #113382 with most `x86_64-unknown-linux-gnu` builders enabled. Bootstrap and the perf collector work. The crater queue is about to be empty, so it's a good time to do another run with this linker configuration and see if anything changed since the previous run. Surely, some bug-for-bug bfd compatibility differences will remain, but it will good to check with the latest lld anyways. Note for anyone looking at this PR coming from the crater queue: this is intended to be a low-priority run. If it hasn't started and you need your run started before this one, go ahead and bump your own priority above this. r? `@ghost`
2 parents 9bd71af + d267f40 commit 53e0313

File tree

6 files changed

+49
-2
lines changed

6 files changed

+49
-2
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,12 @@ impl LinkSelfContainedDefault {
625625
_ => "crt-objects-fallback",
626626
}
627627
}
628+
629+
/// Creates a `LinkSelfContained` enabling the self-contained linker for target specs (the
630+
/// equivalent of `-Clink-self-contained=+linker` on the CLI).
631+
pub fn with_linker() -> LinkSelfContainedDefault {
632+
LinkSelfContainedDefault::WithComponents(LinkSelfContainedComponents::LINKER)
633+
}
628634
}
629635

630636
bitflags::bitflags! {

compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ pub fn target() -> Target {
1616
| SanitizerSet::THREAD;
1717
base.supports_xray = true;
1818

19+
#[cfg(rust_lld)]
20+
{
21+
base.linker_flavor = LinkerFlavor::Gnu(Cc::Yes, Lld::Yes);
22+
base.link_self_contained = crate::spec::LinkSelfContainedDefault::with_linker();
23+
}
24+
1925
Target {
2026
llvm_target: "x86_64-unknown-linux-gnu".into(),
2127
pointer_width: 64,

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,10 @@ pub fn rustc_cargo_env(
10341034
cargo.rustflag("--cfg=parallel_compiler");
10351035
cargo.rustdocflag("--cfg=parallel_compiler");
10361036
}
1037+
if builder.config.lld_enabled {
1038+
cargo.rustflag("--cfg=rust_lld");
1039+
cargo.rustdocflag("--cfg=rust_lld");
1040+
}
10371041
if builder.config.rust_verify_llvm_ir {
10381042
cargo.env("RUSTC_VERIFY_LLVM_IR", "1");
10391043
}

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,7 @@ impl Config {
13721372
let mut debuginfo_level_tests = None;
13731373
let mut optimize = None;
13741374
let mut omit_git_hash = None;
1375+
let mut lld_enabled = None;
13751376

13761377
if let Some(rust) = toml.rust {
13771378
set(&mut config.channel, rust.channel);
@@ -1404,6 +1405,7 @@ impl Config {
14041405
debuginfo_level_std = rust.debuginfo_level_std;
14051406
debuginfo_level_tools = rust.debuginfo_level_tools;
14061407
debuginfo_level_tests = rust.debuginfo_level_tests;
1408+
lld_enabled = rust.lld;
14071409

14081410
config.rust_split_debuginfo = rust
14091411
.split_debuginfo
@@ -1428,7 +1430,6 @@ impl Config {
14281430
config.incremental = true;
14291431
}
14301432
set(&mut config.use_lld, rust.use_lld);
1431-
set(&mut config.lld_enabled, rust.lld);
14321433
set(&mut config.llvm_tools_enabled, rust.llvm_tools);
14331434
config.rustc_parallel = rust
14341435
.parallel_compiler
@@ -1665,6 +1666,26 @@ impl Config {
16651666
config.llvm_plugins = llvm_plugins.unwrap_or(false);
16661667
config.rust_optimize = optimize.unwrap_or(RustOptimize::Bool(true));
16671668

1669+
// `x86_64-unknown-linux-gnu` now uses the self-contained linker, so we have to build
1670+
// our internal lld by default:
1671+
// - when building our in-tree llvm (the target has not set an `llvm-config`), we're able to
1672+
// build rust-lld as well
1673+
// - when using an external llvm that's downloaded from CI, rust-lld is also packaged there
1674+
// - otherwise, we're using an external llvm and lld is not available and thus, disabled
1675+
// - similarly, it's not built or used by this target when asked not to (when the config
1676+
// sets `rust.lld = false`)
1677+
if config.build.triple == "x86_64-unknown-linux-gnu" && config.hosts == &[config.build] {
1678+
let no_llvm_config = config
1679+
.target_config
1680+
.get(&config.build)
1681+
.is_some_and(|target_config| target_config.llvm_config.is_none());
1682+
let enable_lld = config.llvm_from_ci || no_llvm_config;
1683+
// Prefer the config setting in case an explicit opt-out is needed.
1684+
config.lld_enabled = lld_enabled.unwrap_or(enable_lld);
1685+
} else {
1686+
set(&mut config.lld_enabled, lld_enabled);
1687+
}
1688+
16681689
let default = debug == Some(true);
16691690
config.rust_debug_assertions = debug_assertions.unwrap_or(default);
16701691
config.rust_debug_assertions_std =

src/bootstrap/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[
117117
// Needed to avoid the need to copy windows.lib into the sysroot.
118118
(Some(Mode::Rustc), "windows_raw_dylib", None),
119119
(Some(Mode::ToolRustc), "windows_raw_dylib", None),
120+
// If rustc wants to use rust-lld as the default linker in a target spec.
121+
(Some(Mode::Rustc), "rust_lld", None),
122+
(Some(Mode::ToolRustc), "rust_lld", None),
123+
(Some(Mode::Codegen), "rust_lld", None),
120124
];
121125

122126
/// A structure representing a Rust compiler.

src/ci/docker/host-x86_64/dist-x86_64-linux/build-gcc.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ set -ex
33

44
source shared.sh
55

6-
GCC=8.5.0
6+
# Note: in the future when bumping to version 10.1.0, also take care of the sed block below.
7+
GCC=9.5.0
78

89
curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.xz | xzcat | tar xf -
910
cd gcc-$GCC
@@ -22,6 +23,11 @@ cd gcc-$GCC
2223
# latter host is presented to `wget`! Therefore, we choose to download from the insecure HTTP server
2324
# instead here.
2425
#
26+
# Note: in version 10.1.0, the URL used in `download_prerequisites` has changed from using FTP to
27+
# using HTTP. When bumping to that gcc version, we can likely remove the sed replacement below, or
28+
# the expression will need to be updated. That new URL is available at:
29+
# https://github.com/gcc-mirror/gcc/blob/6e6e3f144a33ae504149dc992453b4f6dea12fdb/contrib/download_prerequisites#L35
30+
#
2531
sed -i'' 's|ftp://gcc\.gnu\.org/|https://gcc.gnu.org/|g' ./contrib/download_prerequisites
2632

2733
./contrib/download_prerequisites

0 commit comments

Comments
 (0)