Skip to content

Rollup of 10 pull requests #101264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6b68921
Change implementation of `-Z gcc-ld` and `lld-wrapper` again
petrochenkov Aug 6, 2022
d8a32dd
rustc_target: Add a compatibility layer to separate internal and user…
petrochenkov Aug 14, 2022
667eb18
rustc_target: Refactor internal linker flavors slightly
petrochenkov Aug 14, 2022
38de102
Support eager and lazy methods for providing references and values
shepmaster Jul 21, 2022
260ec93
Add `Provider::{would_be_satisfied_by_value_of,would_be_satisfied_by_…
shepmaster Jul 22, 2022
81a583c
Try normalizing types without RevealAll in ParamEnv in mir validation
Noratrieb Aug 3, 2022
96d4137
Only normalize once in mir validator typechecker
Noratrieb Aug 6, 2022
c846a2a
Make `std::os::fd` public.
sunfishcode Jun 14, 2022
09bbc42
Update asrawfd.js.
sunfishcode Jun 22, 2022
bda1262
Clarify that the `fd` module is supported on Unix and WASI.
sunfishcode Jun 30, 2022
7d80510
Re-introduce `unstable` attributes.
sunfishcode Aug 23, 2022
803e35a
Remove unneeded extra whitespace before where clause
GuillaumeGomez Aug 31, 2022
4304d1d
Update rustdoc tests
GuillaumeGomez Aug 31, 2022
b112bfe
Add rustdoc GUI test
GuillaumeGomez Aug 31, 2022
f8af919
Add warning against unexpected --cfg with --check-cfg
Urgau Aug 11, 2022
a928255
Fix bad target name in Walkthrough
diminishedprime Aug 31, 2022
037a911
rustdoc: remove unused `.docblock .impl-items` CSS
notriddle Aug 31, 2022
d8b572b
Tweaks to fuchsia doc walkthrough
andrewpollack Aug 31, 2022
a79ba45
Rollup merge of #98368 - sunfishcode:sunfishcode/std-os-fd, r=joshtri…
Dylan-DPC Sep 1, 2022
af0d634
Rollup merge of #99583 - shepmaster:provider-plus-plus, r=yaahc
Dylan-DPC Sep 1, 2022
eea3f28
Rollup merge of #100121 - Nilstrieb:mir-validator-param-env, r=oli-obk
Dylan-DPC Sep 1, 2022
2e4b24e
Rollup merge of #100200 - petrochenkov:zgccld2, r=lqd,Mark-Simulacrum
Dylan-DPC Sep 1, 2022
fa5ba19
Rollup merge of #100552 - petrochenkov:flavorcompat, r=lqd
Dylan-DPC Sep 1, 2022
006fa19
Rollup merge of #100574 - Urgau:check-cfg-warn-cfg, r=petrochenkov
Dylan-DPC Sep 1, 2022
ac09b59
Rollup merge of #101245 - GuillaumeGomez:remove-unneeded-where-whites…
Dylan-DPC Sep 1, 2022
abc020b
Rollup merge of #101251 - diminishedprime:patch-1, r=JohnTitor
Dylan-DPC Sep 1, 2022
87e5efc
Rollup merge of #101254 - rust-lang:notriddle/remove-even-more-css, r…
Dylan-DPC Sep 1, 2022
af32194
Rollup merge of #101256 - andrewpollack:fuchsia-docs-adding, r=tmandry
Dylan-DPC Sep 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Change implementation of -Z gcc-ld and lld-wrapper again
  • Loading branch information
petrochenkov committed Aug 6, 2022
commit 6b68921ca0d25690e9d7d3b5d6f442fb1bda1fcc
32 changes: 18 additions & 14 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2777,20 +2777,24 @@ fn add_gcc_ld_path(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
if let LinkerFlavor::Gcc = flavor {
match ld_impl {
LdImpl::Lld => {
let tools_path = sess.get_tools_search_paths(false);
let gcc_ld_dir = tools_path
.into_iter()
.map(|p| p.join("gcc-ld"))
.find(|p| {
p.join(if sess.host.is_like_windows { "ld.exe" } else { "ld" }).exists()
})
.unwrap_or_else(|| sess.fatal("rust-lld (as ld) not found"));
cmd.arg({
let mut arg = OsString::from("-B");
arg.push(gcc_ld_dir);
arg
});
cmd.arg(format!("-Wl,-rustc-lld-flavor={}", sess.target.lld_flavor.as_str()));
// Implement the "self-contained" part of -Zgcc-ld
// by adding rustc distribution directories to the tool search path.
for path in sess.get_tools_search_paths(false) {
cmd.arg({
let mut arg = OsString::from("-B");
arg.push(path.join("gcc-ld"));
arg
});
}
// Implement the "linker flavor" part of -Zgcc-ld
// by asking cc to use some kind of lld.
cmd.arg("-fuse-ld=lld");
if sess.target.lld_flavor != LldFlavor::Ld {
// Tell clang to use a non-default LLD flavor.
// Gcc doesn't understand the target option, but we currently assume
// that gcc is not used for Apple and Wasm targets (#97402).
cmd.arg(format!("--target={}", sess.target.llvm_target));
}
}
}
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,9 @@ impl Step for Assemble {
compiler: build_compiler,
target: target_compiler.host,
});
builder.copy(&lld_wrapper_exe, &gcc_ld_dir.join(exe("ld", target_compiler.host)));
for name in crate::LLD_FILE_NAMES {
builder.copy(&lld_wrapper_exe, &gcc_ld_dir.join(exe(name, target_compiler.host)));
}
}

if builder.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) {
Expand Down
7 changes: 5 additions & 2 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,11 @@ impl Step for Rustc {
let gcc_lld_src_dir = src_dir.join("gcc-ld");
let gcc_lld_dst_dir = dst_dir.join("gcc-ld");
t!(fs::create_dir(&gcc_lld_dst_dir));
let exe_name = exe("ld", compiler.host);
builder.copy(&gcc_lld_src_dir.join(&exe_name), &gcc_lld_dst_dir.join(&exe_name));
for name in crate::LLD_FILE_NAMES {
let exe_name = exe(name, compiler.host);
builder
.copy(&gcc_lld_src_dir.join(&exe_name), &gcc_lld_dst_dir.join(&exe_name));
}
}

// Man pages
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ const LLVM_TOOLS: &[&str] = &[
"opt", // used to optimize LLVM bytecode
];

/// LLD file names for all flavors.
const LLD_FILE_NAMES: &[&str] = &["ld.lld", "ld64.lld", "lld-link", "wasm-ld"];

pub const VERSION: usize = 2;

/// Extra --check-cfg to add when building
Expand Down
35 changes: 19 additions & 16 deletions src/tools/lld-wrapper/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
//! 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
//! symbolic link. It execs `../rust-lld -flavor <flavor>` by propagating the flavor argument
//! passed to the wrapper as the first two arguments. On Windows it spawns a `..\rust-lld.exe`
//! child process.
//! obtained from the wrapper's name as the first two arguments.
//! On Windows it spawns a `..\rust-lld.exe` child process.

use std::fmt::Display;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -53,29 +53,32 @@ fn get_rust_lld_path(current_exe_path: &Path) -> PathBuf {
rust_lld_path
}

/// Extract LLD flavor name from the lld-wrapper executable name.
fn get_lld_flavor(current_exe_path: &Path) -> Result<&'static str, String> {
let stem = current_exe_path.file_stem();
Ok(match stem.and_then(|s| s.to_str()) {
Some("ld.lld") => "gnu",
Some("ld64.lld") => "darwin",
Some("lld-link") => "link",
Some("wasm-ld") => "wasm",
_ => return Err(format!("{:?}", stem)),
})
}

/// Returns the command for invoking rust-lld with the correct flavor.
/// LLD only accepts the flavor argument at the first two arguments, so move it there.
/// LLD only accepts the flavor argument at the first two arguments, so pass it there.
///
/// Exits on error.
fn get_rust_lld_command(current_exe_path: &Path) -> process::Command {
let rust_lld_path = get_rust_lld_path(current_exe_path);
let mut command = process::Command::new(rust_lld_path);

let mut flavor = None;
let args = env::args_os()
.skip(1)
.filter(|arg| match arg.to_str().and_then(|s| s.strip_prefix("-rustc-lld-flavor=")) {
Some(suffix) => {
flavor = Some(suffix.to_string());
false
}
None => true,
})
.collect::<Vec<_>>();
let flavor =
get_lld_flavor(current_exe_path).unwrap_or_exit_with("executable has unexpected name");

command.arg("-flavor");
command.arg(flavor.unwrap_or_exit_with("-rustc-lld-flavor=<flavor> is not passed"));
command.args(args);
command.arg(flavor);
command.args(env::args_os().skip(1));
command
}

Expand Down