Skip to content

Commit b563595

Browse files
committed
linker: Remove -Zgcc-ld option
It is subsumed by `-Clinker-flavor=*-lld-cc -Clink-self-contained=+linker` options now
1 parent 1516ca1 commit b563595

File tree

11 files changed

+27
-68
lines changed

11 files changed

+27
-68
lines changed

compiler/rustc_codegen_ssa/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,6 @@ codegen_ssa_multiple_main_functions = entry symbol `main` declared multiple time
168168
169169
codegen_ssa_no_natvis_directory = error enumerating natvis directory: {$error}
170170
171-
codegen_ssa_option_gcc_only = option `-Z gcc-ld` is used even though linker flavor is not gcc
172-
173171
codegen_ssa_processing_dymutil_failed = processing debug info with `dsymutil` failed: {$status}
174172
.note = {$output}
175173

compiler/rustc_codegen_ssa/src/back/link.rs

+7-16
Original file line numberDiff line numberDiff line change
@@ -2964,31 +2964,22 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result<String, errors::AppleSdkRootErro
29642964
}
29652965
}
29662966

2967-
/// When using the linker flavors opting in to `lld`, or the unstable `-Zgcc-ld=lld` flag, add the
2968-
/// necessary paths and arguments to invoke it:
2967+
/// When using the linker flavors opting in to `lld`, add the necessary paths and arguments to
2968+
/// invoke it:
29692969
/// - when the self-contained linker flag is active: the build of `lld` distributed with rustc,
29702970
/// - or any `lld` available to `cc`.
29712971
fn add_lld_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
2972-
let unstable_use_lld = sess.opts.unstable_opts.gcc_ld.is_some();
2973-
debug!("add_lld_args requested, flavor: '{flavor:?}', `-Zgcc-ld=lld`: {unstable_use_lld}");
2974-
2975-
// Sanity check: using the old unstable `-Zgcc-ld=lld` option requires a `cc`-using flavor.
2976-
let flavor_uses_cc = flavor.uses_cc();
2977-
if unstable_use_lld && !flavor_uses_cc {
2978-
sess.emit_fatal(errors::OptionGccOnly);
2979-
}
2972+
debug!("add_lld_args requested, flavor: '{flavor:?}'");
29802973

29812974
// If the flavor doesn't use a C/C++ compiler to invoke the linker, or doesn't opt in to `lld`,
29822975
// we don't need to do anything.
2983-
let use_lld = flavor.uses_lld() || unstable_use_lld;
2984-
if !flavor_uses_cc || !use_lld {
2976+
if !(flavor.uses_cc() && flavor.uses_lld()) {
29852977
return;
29862978
}
29872979

29882980
// 1. Implement the "self-contained" part of this feature by adding rustc distribution
29892981
// directories to the tool's search path.
2990-
let self_contained_linker = sess.opts.cg.link_self_contained.linker() || unstable_use_lld;
2991-
if self_contained_linker {
2982+
if sess.opts.cg.link_self_contained.linker() {
29922983
for path in sess.get_tools_search_paths(false) {
29932984
cmd.arg({
29942985
let mut arg = OsString::from("-B");
@@ -3012,13 +3003,13 @@ fn add_lld_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
30123003
// shown in issue #101653 and the discussion in PR #101792.
30133004
//
30143005
// It could be required in some cases of cross-compiling with
3015-
// `-Zgcc-ld=lld`, but this is generally unspecified, and we don't know
3006+
// LLD, but this is generally unspecified, and we don't know
30163007
// which specific versions of clang, macOS SDK, host and target OS
30173008
// combinations impact us here.
30183009
//
30193010
// So we do a simple first-approximation until we know more of what the
30203011
// Apple targets require (and which would be handled prior to hitting this
3021-
// `-Zgcc-ld=lld` codepath anyway), but the expectation is that until then
3012+
// LLD codepath anyway), but the expectation is that until then
30223013
// this should be manually passed if needed. We specify the target when
30233014
// targeting a different linker flavor on macOS, and that's also always
30243015
// the case when targeting WASM.

compiler/rustc_codegen_ssa/src/errors.rs

-4
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,6 @@ pub struct RlibArchiveBuildFailure {
489489
pub error: Error,
490490
}
491491

492-
#[derive(Diagnostic)]
493-
#[diag(codegen_ssa_option_gcc_only)]
494-
pub struct OptionGccOnly;
495-
496492
#[derive(Diagnostic)]
497493
pub enum ExtractBundledLibsError<'a> {
498494
#[diag(codegen_ssa_extract_bundled_libs_open_file)]

compiler/rustc_session/src/config.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -3167,9 +3167,9 @@ impl PpMode {
31673167
pub(crate) mod dep_tracking {
31683168
use super::{
31693169
BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, DebugInfoCompression,
3170-
ErrorOutputType, InstrumentCoverage, InstrumentXRay, LdImpl, LinkerPluginLto,
3171-
LocationDetail, LtoCli, OomStrategy, OptLevel, OutFileName, OutputType, OutputTypes,
3172-
Passes, ResolveDocLinks, SourceFileHashAlgorithm, SplitDwarfKind, SwitchWithOptPath,
3170+
ErrorOutputType, InstrumentCoverage, InstrumentXRay, LinkerPluginLto, LocationDetail,
3171+
LtoCli, OomStrategy, OptLevel, OutFileName, OutputType, OutputTypes, Passes,
3172+
ResolveDocLinks, SourceFileHashAlgorithm, SplitDwarfKind, SwitchWithOptPath,
31733173
SymbolManglingVersion, TraitSolver, TrimmedDefPaths,
31743174
};
31753175
use crate::lint;
@@ -3266,7 +3266,6 @@ pub(crate) mod dep_tracking {
32663266
SymbolManglingVersion,
32673267
SourceFileHashAlgorithm,
32683268
TrimmedDefPaths,
3269-
Option<LdImpl>,
32703269
OutFileName,
32713270
OutputType,
32723271
RealFileName,

compiler/rustc_session/src/options.rs

-16
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ mod desc {
412412
"one of supported split-debuginfo modes (`off`, `packed`, or `unpacked`)";
413413
pub const parse_split_dwarf_kind: &str =
414414
"one of supported split dwarf modes (`split` or `single`)";
415-
pub const parse_gcc_ld: &str = "one of: no value, `lld`";
416415
pub const parse_link_self_contained: &str = "one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) \
417416
components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw`";
418417
pub const parse_stack_protector: &str =
@@ -1202,15 +1201,6 @@ mod parse {
12021201
true
12031202
}
12041203

1205-
pub(crate) fn parse_gcc_ld(slot: &mut Option<LdImpl>, v: Option<&str>) -> bool {
1206-
match v {
1207-
None => *slot = None,
1208-
Some("lld") => *slot = Some(LdImpl::Lld),
1209-
_ => return false,
1210-
}
1211-
true
1212-
}
1213-
12141204
pub(crate) fn parse_stack_protector(slot: &mut StackProtector, v: Option<&str>) -> bool {
12151205
match v.and_then(|s| StackProtector::from_str(s).ok()) {
12161206
Some(ssp) => *slot = ssp,
@@ -1521,7 +1511,6 @@ options! {
15211511
"whether each function should go in its own section"),
15221512
future_incompat_test: bool = (false, parse_bool, [UNTRACKED],
15231513
"forces all lints to be future incompatible, used for internal testing (default: no)"),
1524-
gcc_ld: Option<LdImpl> = (None, parse_gcc_ld, [TRACKED], "implementation of ld used by cc"),
15251514
graphviz_dark_mode: bool = (false, parse_bool, [UNTRACKED],
15261515
"use dark-themed colors in graphviz output (default: no)"),
15271516
graphviz_font: String = ("Courier, monospace".to_string(), parse_string, [UNTRACKED],
@@ -1906,8 +1895,3 @@ pub enum WasiExecModel {
19061895
Command,
19071896
Reactor,
19081897
}
1909-
1910-
#[derive(Clone, Copy, Hash)]
1911-
pub enum LdImpl {
1912-
Lld,
1913-
}

src/bootstrap/compile.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1677,15 +1677,17 @@ impl Step for Assemble {
16771677
let src_exe = exe("lld", target_compiler.host);
16781678
let dst_exe = exe("rust-lld", target_compiler.host);
16791679
builder.copy(&lld_install.join("bin").join(&src_exe), &libdir_bin.join(&dst_exe));
1680-
// for `-Z gcc-ld=lld`
1681-
let gcc_ld_dir = libdir_bin.join("gcc-ld");
1682-
t!(fs::create_dir(&gcc_ld_dir));
1680+
let self_contained_lld_dir = libdir_bin.join("gcc-ld");
1681+
t!(fs::create_dir(&self_contained_lld_dir));
16831682
let lld_wrapper_exe = builder.ensure(crate::tool::LldWrapper {
16841683
compiler: build_compiler,
16851684
target: target_compiler.host,
16861685
});
16871686
for name in crate::LLD_FILE_NAMES {
1688-
builder.copy(&lld_wrapper_exe, &gcc_ld_dir.join(exe(name, target_compiler.host)));
1687+
builder.copy(
1688+
&lld_wrapper_exe,
1689+
&self_contained_lld_dir.join(exe(name, target_compiler.host)),
1690+
);
16891691
}
16901692
}
16911693

src/bootstrap/dist.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,15 @@ impl Step for Rustc {
471471
let src_dir = builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin");
472472
let rust_lld = exe("rust-lld", compiler.host);
473473
builder.copy(&src_dir.join(&rust_lld), &dst_dir.join(&rust_lld));
474-
// for `-Z gcc-ld=lld`
475-
let gcc_lld_src_dir = src_dir.join("gcc-ld");
476-
let gcc_lld_dst_dir = dst_dir.join("gcc-ld");
477-
t!(fs::create_dir(&gcc_lld_dst_dir));
474+
let self_contained_lld_src_dir = src_dir.join("gcc-ld");
475+
let self_contained_lld_dst_dir = dst_dir.join("gcc-ld");
476+
t!(fs::create_dir(&self_contained_lld_dst_dir));
478477
for name in crate::LLD_FILE_NAMES {
479478
let exe_name = exe(name, compiler.host);
480-
builder
481-
.copy(&gcc_lld_src_dir.join(&exe_name), &gcc_lld_dst_dir.join(&exe_name));
479+
builder.copy(
480+
&self_contained_lld_src_dir.join(&exe_name),
481+
&self_contained_lld_dst_dir.join(&exe_name),
482+
);
482483
}
483484
}
484485

src/tools/compiletest/src/header/needs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ impl CachedNeedsConditions {
241241
profiler_support: std::env::var_os("RUSTC_PROFILER_SUPPORT").is_some(),
242242
xray: config.target_cfg().xray,
243243

244-
// For tests using the `needs-rust-lld` directive (e.g. for `-Zgcc-ld=lld`), we need to find
245-
// whether `rust-lld` is present in the compiler under test.
244+
// For tests using the `needs-rust-lld` directive (e.g. for `-Clink-self-contained=+linker`),
245+
// we need to find whether `rust-lld` is present in the compiler under test.
246246
//
247247
// The --compile-lib-path is the path to host shared libraries, but depends on the OS. For
248248
// example:

src/tools/lld-wrapper/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
//! two arguments the `<flavor>` command line interface is used to process the remaining arguments.
55
//! If no `-flavor` argument is present the flavor is determined by the executable name.
66
//!
7-
//! In Rust with `-Z gcc-ld=lld` we have gcc or clang invoke rust-lld. Since there is no way to
8-
//! make gcc/clang pass `-flavor <flavor>` as the first two arguments in the linker invocation
7+
//! With `-Clink-self-contained=+linker` we have gcc or clang invoke rust-lld. Since there is no way
8+
//! to make gcc/clang pass `-flavor <flavor>` as the first two arguments in the linker invocation
99
//! and since Windows does not support symbolic links for files this wrapper is used in place of a
1010
//! symbolic link. It execs `../rust-lld -flavor <flavor>` by propagating the flavor argument
1111
//! obtained from the wrapper's name as the first two arguments.

tests/run-make/issue-71519/Makefile

-8
This file was deleted.

tests/run-make/issue-71519/main.rs

-4
This file was deleted.

0 commit comments

Comments
 (0)