Skip to content

Commit 464ec64

Browse files
committed
Auto merge of #97409 - GuillaumeGomez:rollup-808v9ge, r=GuillaumeGomez
Rollup of 4 pull requests Successful merges: - #97317 (Allow to click on setting text) - #97375 (Simplify implementation of `-Z gcc-ld`) - #97394 (Add more eslint rules) - #97407 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4cbaac6 + f74e61e commit 464ec64

File tree

23 files changed

+154
-173
lines changed

23 files changed

+154
-173
lines changed

compiler/rustc_codegen_ssa/src/back/command.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,7 @@ impl Command {
105105
}
106106
Program::Lld(ref p, flavor) => {
107107
let mut c = process::Command::new(p);
108-
c.arg("-flavor").arg(match flavor {
109-
LldFlavor::Wasm => "wasm",
110-
LldFlavor::Ld => "gnu",
111-
LldFlavor::Link => "link",
112-
LldFlavor::Ld64 => "darwin",
113-
});
108+
c.arg("-flavor").arg(flavor.as_str());
114109
if let LldFlavor::Wasm = flavor {
115110
// LLVM expects host-specific formatting for @file
116111
// arguments, but we always generate posix formatted files

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2698,37 +2698,20 @@ fn add_gcc_ld_path(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
26982698
if let LinkerFlavor::Gcc = flavor {
26992699
match ld_impl {
27002700
LdImpl::Lld => {
2701-
if sess.target.lld_flavor == LldFlavor::Ld64 {
2702-
let tools_path = sess.get_tools_search_paths(false);
2703-
let ld64_exe = tools_path
2704-
.into_iter()
2705-
.map(|p| p.join("gcc-ld"))
2706-
.map(|p| {
2707-
p.join(if sess.host.is_like_windows { "ld64.exe" } else { "ld64" })
2708-
})
2709-
.find(|p| p.exists())
2710-
.unwrap_or_else(|| sess.fatal("rust-lld (as ld64) not found"));
2711-
cmd.cmd().arg({
2712-
let mut arg = OsString::from("-fuse-ld=");
2713-
arg.push(ld64_exe);
2714-
arg
2715-
});
2716-
} else {
2717-
let tools_path = sess.get_tools_search_paths(false);
2718-
let lld_path = tools_path
2719-
.into_iter()
2720-
.map(|p| p.join("gcc-ld"))
2721-
.find(|p| {
2722-
p.join(if sess.host.is_like_windows { "ld.exe" } else { "ld" })
2723-
.exists()
2724-
})
2725-
.unwrap_or_else(|| sess.fatal("rust-lld (as ld) not found"));
2726-
cmd.cmd().arg({
2727-
let mut arg = OsString::from("-B");
2728-
arg.push(lld_path);
2729-
arg
2730-
});
2731-
}
2701+
let tools_path = sess.get_tools_search_paths(false);
2702+
let gcc_ld_dir = tools_path
2703+
.into_iter()
2704+
.map(|p| p.join("gcc-ld"))
2705+
.find(|p| {
2706+
p.join(if sess.host.is_like_windows { "ld.exe" } else { "ld" }).exists()
2707+
})
2708+
.unwrap_or_else(|| sess.fatal("rust-lld (as ld) not found"));
2709+
cmd.arg({
2710+
let mut arg = OsString::from("-B");
2711+
arg.push(gcc_ld_dir);
2712+
arg
2713+
});
2714+
cmd.arg(format!("-Wl,-rustc-lld-flavor={}", sess.target.lld_flavor.as_str()));
27322715
}
27332716
}
27342717
} else {

compiler/rustc_target/src/spec/mod.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ pub enum LldFlavor {
108108
}
109109

110110
impl LldFlavor {
111+
pub fn as_str(&self) -> &'static str {
112+
match self {
113+
LldFlavor::Wasm => "wasm",
114+
LldFlavor::Ld64 => "darwin",
115+
LldFlavor::Ld => "gnu",
116+
LldFlavor::Link => "link",
117+
}
118+
}
119+
111120
fn from_str(s: &str) -> Option<Self> {
112121
Some(match s {
113122
"darwin" => LldFlavor::Ld64,
@@ -121,13 +130,7 @@ impl LldFlavor {
121130

122131
impl ToJson for LldFlavor {
123132
fn to_json(&self) -> Json {
124-
match *self {
125-
LldFlavor::Ld64 => "darwin",
126-
LldFlavor::Ld => "gnu",
127-
LldFlavor::Link => "link",
128-
LldFlavor::Wasm => "wasm",
129-
}
130-
.to_json()
133+
self.as_str().to_json()
131134
}
132135
}
133136

src/bootstrap/compile.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,14 +1164,11 @@ impl Step for Assemble {
11641164
// for `-Z gcc-ld=lld`
11651165
let gcc_ld_dir = libdir_bin.join("gcc-ld");
11661166
t!(fs::create_dir(&gcc_ld_dir));
1167-
for flavor in ["ld", "ld64"] {
1168-
let lld_wrapper_exe = builder.ensure(crate::tool::LldWrapper {
1169-
compiler: build_compiler,
1170-
target: target_compiler.host,
1171-
flavor_feature: flavor,
1172-
});
1173-
builder.copy(&lld_wrapper_exe, &gcc_ld_dir.join(exe(flavor, target_compiler.host)));
1174-
}
1167+
let lld_wrapper_exe = builder.ensure(crate::tool::LldWrapper {
1168+
compiler: build_compiler,
1169+
target: target_compiler.host,
1170+
});
1171+
builder.copy(&lld_wrapper_exe, &gcc_ld_dir.join(exe("ld", target_compiler.host)));
11751172
}
11761173

11771174
if builder.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) {

src/bootstrap/dist.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,8 @@ impl Step for Rustc {
407407
let gcc_lld_src_dir = src_dir.join("gcc-ld");
408408
let gcc_lld_dst_dir = dst_dir.join("gcc-ld");
409409
t!(fs::create_dir(&gcc_lld_dst_dir));
410-
for flavor in ["ld", "ld64"] {
411-
let exe_name = exe(flavor, compiler.host);
412-
builder
413-
.copy(&gcc_lld_src_dir.join(&exe_name), &gcc_lld_dst_dir.join(&exe_name));
414-
}
410+
let exe_name = exe("ld", compiler.host);
411+
builder.copy(&gcc_lld_src_dir.join(&exe_name), &gcc_lld_dst_dir.join(&exe_name));
415412
}
416413

417414
// Man pages

src/bootstrap/tool.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,6 @@ impl Step for Cargo {
656656
pub struct LldWrapper {
657657
pub compiler: Compiler,
658658
pub target: TargetSelection,
659-
pub flavor_feature: &'static str,
660659
}
661660

662661
impl Step for LldWrapper {
@@ -676,7 +675,7 @@ impl Step for LldWrapper {
676675
path: "src/tools/lld-wrapper",
677676
is_optional_tool: false,
678677
source_type: SourceType::InTree,
679-
extra_features: vec![self.flavor_feature.to_owned()],
678+
extra_features: Vec::new(),
680679
})
681680
.expect("expected to build -- essential tool");
682681

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.3
1+
0.9.5

src/doc/book

Submodule book updated 123 files

0 commit comments

Comments
 (0)