linker: Remove -Zgcc-ld
option
It is subsumed by `-Clinker-flavor=*-lld-cc -Clink-self-contained=+linker` options now
This commit is contained in:
parent
1516ca1bc0
commit
b563595c6e
@ -168,8 +168,6 @@ codegen_ssa_multiple_main_functions = entry symbol `main` declared multiple time
|
|||||||
|
|
||||||
codegen_ssa_no_natvis_directory = error enumerating natvis directory: {$error}
|
codegen_ssa_no_natvis_directory = error enumerating natvis directory: {$error}
|
||||||
|
|
||||||
codegen_ssa_option_gcc_only = option `-Z gcc-ld` is used even though linker flavor is not gcc
|
|
||||||
|
|
||||||
codegen_ssa_processing_dymutil_failed = processing debug info with `dsymutil` failed: {$status}
|
codegen_ssa_processing_dymutil_failed = processing debug info with `dsymutil` failed: {$status}
|
||||||
.note = {$output}
|
.note = {$output}
|
||||||
|
|
||||||
|
@ -2964,31 +2964,22 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result<String, errors::AppleSdkRootErro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// When using the linker flavors opting in to `lld`, or the unstable `-Zgcc-ld=lld` flag, add the
|
/// When using the linker flavors opting in to `lld`, add the necessary paths and arguments to
|
||||||
/// necessary paths and arguments to invoke it:
|
/// invoke it:
|
||||||
/// - when the self-contained linker flag is active: the build of `lld` distributed with rustc,
|
/// - when the self-contained linker flag is active: the build of `lld` distributed with rustc,
|
||||||
/// - or any `lld` available to `cc`.
|
/// - or any `lld` available to `cc`.
|
||||||
fn add_lld_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
fn add_lld_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||||
let unstable_use_lld = sess.opts.unstable_opts.gcc_ld.is_some();
|
debug!("add_lld_args requested, flavor: '{flavor:?}'");
|
||||||
debug!("add_lld_args requested, flavor: '{flavor:?}', `-Zgcc-ld=lld`: {unstable_use_lld}");
|
|
||||||
|
|
||||||
// Sanity check: using the old unstable `-Zgcc-ld=lld` option requires a `cc`-using flavor.
|
|
||||||
let flavor_uses_cc = flavor.uses_cc();
|
|
||||||
if unstable_use_lld && !flavor_uses_cc {
|
|
||||||
sess.emit_fatal(errors::OptionGccOnly);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the flavor doesn't use a C/C++ compiler to invoke the linker, or doesn't opt in to `lld`,
|
// If the flavor doesn't use a C/C++ compiler to invoke the linker, or doesn't opt in to `lld`,
|
||||||
// we don't need to do anything.
|
// we don't need to do anything.
|
||||||
let use_lld = flavor.uses_lld() || unstable_use_lld;
|
if !(flavor.uses_cc() && flavor.uses_lld()) {
|
||||||
if !flavor_uses_cc || !use_lld {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Implement the "self-contained" part of this feature by adding rustc distribution
|
// 1. Implement the "self-contained" part of this feature by adding rustc distribution
|
||||||
// directories to the tool's search path.
|
// directories to the tool's search path.
|
||||||
let self_contained_linker = sess.opts.cg.link_self_contained.linker() || unstable_use_lld;
|
if sess.opts.cg.link_self_contained.linker() {
|
||||||
if self_contained_linker {
|
|
||||||
for path in sess.get_tools_search_paths(false) {
|
for path in sess.get_tools_search_paths(false) {
|
||||||
cmd.arg({
|
cmd.arg({
|
||||||
let mut arg = OsString::from("-B");
|
let mut arg = OsString::from("-B");
|
||||||
@ -3012,13 +3003,13 @@ fn add_lld_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
|||||||
// shown in issue #101653 and the discussion in PR #101792.
|
// shown in issue #101653 and the discussion in PR #101792.
|
||||||
//
|
//
|
||||||
// It could be required in some cases of cross-compiling with
|
// It could be required in some cases of cross-compiling with
|
||||||
// `-Zgcc-ld=lld`, but this is generally unspecified, and we don't know
|
// LLD, but this is generally unspecified, and we don't know
|
||||||
// which specific versions of clang, macOS SDK, host and target OS
|
// which specific versions of clang, macOS SDK, host and target OS
|
||||||
// combinations impact us here.
|
// combinations impact us here.
|
||||||
//
|
//
|
||||||
// So we do a simple first-approximation until we know more of what the
|
// So we do a simple first-approximation until we know more of what the
|
||||||
// Apple targets require (and which would be handled prior to hitting this
|
// Apple targets require (and which would be handled prior to hitting this
|
||||||
// `-Zgcc-ld=lld` codepath anyway), but the expectation is that until then
|
// LLD codepath anyway), but the expectation is that until then
|
||||||
// this should be manually passed if needed. We specify the target when
|
// this should be manually passed if needed. We specify the target when
|
||||||
// targeting a different linker flavor on macOS, and that's also always
|
// targeting a different linker flavor on macOS, and that's also always
|
||||||
// the case when targeting WASM.
|
// the case when targeting WASM.
|
||||||
|
@ -489,10 +489,6 @@ pub struct RlibArchiveBuildFailure {
|
|||||||
pub error: Error,
|
pub error: Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
|
||||||
#[diag(codegen_ssa_option_gcc_only)]
|
|
||||||
pub struct OptionGccOnly;
|
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
pub enum ExtractBundledLibsError<'a> {
|
pub enum ExtractBundledLibsError<'a> {
|
||||||
#[diag(codegen_ssa_extract_bundled_libs_open_file)]
|
#[diag(codegen_ssa_extract_bundled_libs_open_file)]
|
||||||
|
@ -3167,9 +3167,9 @@ impl PpMode {
|
|||||||
pub(crate) mod dep_tracking {
|
pub(crate) mod dep_tracking {
|
||||||
use super::{
|
use super::{
|
||||||
BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, DebugInfoCompression,
|
BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, DebugInfoCompression,
|
||||||
ErrorOutputType, InstrumentCoverage, InstrumentXRay, LdImpl, LinkerPluginLto,
|
ErrorOutputType, InstrumentCoverage, InstrumentXRay, LinkerPluginLto, LocationDetail,
|
||||||
LocationDetail, LtoCli, OomStrategy, OptLevel, OutFileName, OutputType, OutputTypes,
|
LtoCli, OomStrategy, OptLevel, OutFileName, OutputType, OutputTypes, Passes,
|
||||||
Passes, ResolveDocLinks, SourceFileHashAlgorithm, SplitDwarfKind, SwitchWithOptPath,
|
ResolveDocLinks, SourceFileHashAlgorithm, SplitDwarfKind, SwitchWithOptPath,
|
||||||
SymbolManglingVersion, TraitSolver, TrimmedDefPaths,
|
SymbolManglingVersion, TraitSolver, TrimmedDefPaths,
|
||||||
};
|
};
|
||||||
use crate::lint;
|
use crate::lint;
|
||||||
@ -3266,7 +3266,6 @@ pub(crate) mod dep_tracking {
|
|||||||
SymbolManglingVersion,
|
SymbolManglingVersion,
|
||||||
SourceFileHashAlgorithm,
|
SourceFileHashAlgorithm,
|
||||||
TrimmedDefPaths,
|
TrimmedDefPaths,
|
||||||
Option<LdImpl>,
|
|
||||||
OutFileName,
|
OutFileName,
|
||||||
OutputType,
|
OutputType,
|
||||||
RealFileName,
|
RealFileName,
|
||||||
|
@ -412,7 +412,6 @@ mod desc {
|
|||||||
"one of supported split-debuginfo modes (`off`, `packed`, or `unpacked`)";
|
"one of supported split-debuginfo modes (`off`, `packed`, or `unpacked`)";
|
||||||
pub const parse_split_dwarf_kind: &str =
|
pub const parse_split_dwarf_kind: &str =
|
||||||
"one of supported split dwarf modes (`split` or `single`)";
|
"one of supported split dwarf modes (`split` or `single`)";
|
||||||
pub const parse_gcc_ld: &str = "one of: no value, `lld`";
|
|
||||||
pub const parse_link_self_contained: &str = "one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) \
|
pub const parse_link_self_contained: &str = "one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) \
|
||||||
components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw`";
|
components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw`";
|
||||||
pub const parse_stack_protector: &str =
|
pub const parse_stack_protector: &str =
|
||||||
@ -1202,15 +1201,6 @@ mod parse {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn parse_gcc_ld(slot: &mut Option<LdImpl>, v: Option<&str>) -> bool {
|
|
||||||
match v {
|
|
||||||
None => *slot = None,
|
|
||||||
Some("lld") => *slot = Some(LdImpl::Lld),
|
|
||||||
_ => return false,
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn parse_stack_protector(slot: &mut StackProtector, v: Option<&str>) -> bool {
|
pub(crate) fn parse_stack_protector(slot: &mut StackProtector, v: Option<&str>) -> bool {
|
||||||
match v.and_then(|s| StackProtector::from_str(s).ok()) {
|
match v.and_then(|s| StackProtector::from_str(s).ok()) {
|
||||||
Some(ssp) => *slot = ssp,
|
Some(ssp) => *slot = ssp,
|
||||||
@ -1521,7 +1511,6 @@ options! {
|
|||||||
"whether each function should go in its own section"),
|
"whether each function should go in its own section"),
|
||||||
future_incompat_test: bool = (false, parse_bool, [UNTRACKED],
|
future_incompat_test: bool = (false, parse_bool, [UNTRACKED],
|
||||||
"forces all lints to be future incompatible, used for internal testing (default: no)"),
|
"forces all lints to be future incompatible, used for internal testing (default: no)"),
|
||||||
gcc_ld: Option<LdImpl> = (None, parse_gcc_ld, [TRACKED], "implementation of ld used by cc"),
|
|
||||||
graphviz_dark_mode: bool = (false, parse_bool, [UNTRACKED],
|
graphviz_dark_mode: bool = (false, parse_bool, [UNTRACKED],
|
||||||
"use dark-themed colors in graphviz output (default: no)"),
|
"use dark-themed colors in graphviz output (default: no)"),
|
||||||
graphviz_font: String = ("Courier, monospace".to_string(), parse_string, [UNTRACKED],
|
graphviz_font: String = ("Courier, monospace".to_string(), parse_string, [UNTRACKED],
|
||||||
@ -1906,8 +1895,3 @@ pub enum WasiExecModel {
|
|||||||
Command,
|
Command,
|
||||||
Reactor,
|
Reactor,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Hash)]
|
|
||||||
pub enum LdImpl {
|
|
||||||
Lld,
|
|
||||||
}
|
|
||||||
|
@ -1677,15 +1677,17 @@ impl Step for Assemble {
|
|||||||
let src_exe = exe("lld", target_compiler.host);
|
let src_exe = exe("lld", target_compiler.host);
|
||||||
let dst_exe = exe("rust-lld", target_compiler.host);
|
let dst_exe = exe("rust-lld", target_compiler.host);
|
||||||
builder.copy(&lld_install.join("bin").join(&src_exe), &libdir_bin.join(&dst_exe));
|
builder.copy(&lld_install.join("bin").join(&src_exe), &libdir_bin.join(&dst_exe));
|
||||||
// for `-Z gcc-ld=lld`
|
let self_contained_lld_dir = libdir_bin.join("gcc-ld");
|
||||||
let gcc_ld_dir = libdir_bin.join("gcc-ld");
|
t!(fs::create_dir(&self_contained_lld_dir));
|
||||||
t!(fs::create_dir(&gcc_ld_dir));
|
|
||||||
let lld_wrapper_exe = builder.ensure(crate::tool::LldWrapper {
|
let lld_wrapper_exe = builder.ensure(crate::tool::LldWrapper {
|
||||||
compiler: build_compiler,
|
compiler: build_compiler,
|
||||||
target: target_compiler.host,
|
target: target_compiler.host,
|
||||||
});
|
});
|
||||||
for name in crate::LLD_FILE_NAMES {
|
for name in crate::LLD_FILE_NAMES {
|
||||||
builder.copy(&lld_wrapper_exe, &gcc_ld_dir.join(exe(name, target_compiler.host)));
|
builder.copy(
|
||||||
|
&lld_wrapper_exe,
|
||||||
|
&self_contained_lld_dir.join(exe(name, target_compiler.host)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,14 +471,15 @@ impl Step for Rustc {
|
|||||||
let src_dir = builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin");
|
let src_dir = builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin");
|
||||||
let rust_lld = exe("rust-lld", compiler.host);
|
let rust_lld = exe("rust-lld", compiler.host);
|
||||||
builder.copy(&src_dir.join(&rust_lld), &dst_dir.join(&rust_lld));
|
builder.copy(&src_dir.join(&rust_lld), &dst_dir.join(&rust_lld));
|
||||||
// for `-Z gcc-ld=lld`
|
let self_contained_lld_src_dir = src_dir.join("gcc-ld");
|
||||||
let gcc_lld_src_dir = src_dir.join("gcc-ld");
|
let self_contained_lld_dst_dir = dst_dir.join("gcc-ld");
|
||||||
let gcc_lld_dst_dir = dst_dir.join("gcc-ld");
|
t!(fs::create_dir(&self_contained_lld_dst_dir));
|
||||||
t!(fs::create_dir(&gcc_lld_dst_dir));
|
|
||||||
for name in crate::LLD_FILE_NAMES {
|
for name in crate::LLD_FILE_NAMES {
|
||||||
let exe_name = exe(name, compiler.host);
|
let exe_name = exe(name, compiler.host);
|
||||||
builder
|
builder.copy(
|
||||||
.copy(&gcc_lld_src_dir.join(&exe_name), &gcc_lld_dst_dir.join(&exe_name));
|
&self_contained_lld_src_dir.join(&exe_name),
|
||||||
|
&self_contained_lld_dst_dir.join(&exe_name),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,8 +241,8 @@ impl CachedNeedsConditions {
|
|||||||
profiler_support: std::env::var_os("RUSTC_PROFILER_SUPPORT").is_some(),
|
profiler_support: std::env::var_os("RUSTC_PROFILER_SUPPORT").is_some(),
|
||||||
xray: config.target_cfg().xray,
|
xray: config.target_cfg().xray,
|
||||||
|
|
||||||
// For tests using the `needs-rust-lld` directive (e.g. for `-Zgcc-ld=lld`), we need to find
|
// For tests using the `needs-rust-lld` directive (e.g. for `-Clink-self-contained=+linker`),
|
||||||
// whether `rust-lld` is present in the compiler under test.
|
// we need to find whether `rust-lld` is present in the compiler under test.
|
||||||
//
|
//
|
||||||
// The --compile-lib-path is the path to host shared libraries, but depends on the OS. For
|
// The --compile-lib-path is the path to host shared libraries, but depends on the OS. For
|
||||||
// example:
|
// example:
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
//! two arguments the `<flavor>` command line interface is used to process the remaining arguments.
|
//! two arguments the `<flavor>` command line interface is used to process the remaining arguments.
|
||||||
//! If no `-flavor` argument is present the flavor is determined by the executable name.
|
//! If no `-flavor` argument is present the flavor is determined by the executable name.
|
||||||
//!
|
//!
|
||||||
//! In Rust with `-Z gcc-ld=lld` we have gcc or clang invoke rust-lld. Since there is no way to
|
//! With `-Clink-self-contained=+linker` we have gcc or clang invoke rust-lld. Since there is no way
|
||||||
//! make gcc/clang pass `-flavor <flavor>` as the first two arguments in the linker invocation
|
//! to make gcc/clang pass `-flavor <flavor>` as the first two arguments in the linker invocation
|
||||||
//! and since Windows does not support symbolic links for files this wrapper is used in place of a
|
//! and since Windows does not support symbolic links for files this wrapper is used in place of a
|
||||||
//! symbolic link. It execs `../rust-lld -flavor <flavor>` by propagating the flavor argument
|
//! symbolic link. It execs `../rust-lld -flavor <flavor>` by propagating the flavor argument
|
||||||
//! obtained from the wrapper's name as the first two arguments.
|
//! obtained from the wrapper's name as the first two arguments.
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
include ../tools.mk
|
|
||||||
|
|
||||||
# ignore-msvc
|
|
||||||
# needs-rust-lld
|
|
||||||
# ignore-s390x lld does not yet support s390x as target
|
|
||||||
all:
|
|
||||||
RUSTC_LOG=rustc_codegen_ssa::back::link=info $(RUSTC) -Z gcc-ld=lld -C link-args=-Wl,-v main.rs 2> $(TMPDIR)/output.txt
|
|
||||||
$(CGREP) -e "^LLD [0-9]+\.[0-9]+\.[0-9]+" < $(TMPDIR)/output.txt
|
|
@ -1,4 +0,0 @@
|
|||||||
// test linking using cc with rust-lld injected into search path as ld
|
|
||||||
// see rust-lang/rust#71519 for more info
|
|
||||||
|
|
||||||
fn main() {}
|
|
Loading…
x
Reference in New Issue
Block a user