Skip to content
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

Rollup of 8 pull requests #101317

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 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
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
54645e8
set up rustc_metadata for SessionDiagnostics, port dependency_format.rs
CleanCut Aug 23, 2022
3ed9310
port native_libs.rs to SessionDiagnostics
CleanCut Aug 23, 2022
f7e462a
port encoder.rs to SessionDiagnostics
CleanCut Aug 23, 2022
32e1823
port creader.rs to SessionDiagnostics
CleanCut Aug 23, 2022
bd8e312
port fs.rs to SessionDiagnostics
CleanCut Aug 23, 2022
d0ba1fb
port of locator.rs to SessionDiagnostics, fix some of the errors
CleanCut Aug 24, 2022
0d65819
respond to review feedback: mainly eliminate as many conversions as p…
CleanCut Aug 26, 2022
30adfd6
port 5 new diagnostics that appeared in master
CleanCut Aug 27, 2022
1171697
Generate error index with mdbook instead of raw HTML pages
GuillaumeGomez Aug 29, 2022
630f831
Use `FILE_ATTRIBUTE_TAG_INFO` to get reparse tag
ChrisDenton Sep 1, 2022
f5857d5
Move error code book into a sub folder
GuillaumeGomez Aug 31, 2022
096efc2
rustdoc: remove unused CSS `#main-content > .since`
notriddle Sep 1, 2022
e5d60af
Simplify MIR opt tests
JakobDegen Aug 21, 2022
4038521
Rollup merge of #99583 - shepmaster:provider-plus-plus, r=yaahc
Dylan-DPC Sep 2, 2022
34a430c
Rollup merge of #100121 - Nilstrieb:mir-validator-param-env, r=oli-obk
Dylan-DPC Sep 2, 2022
d9f11d2
Rollup merge of #100200 - petrochenkov:zgccld2, r=lqd,Mark-Simulacrum
Dylan-DPC Sep 2, 2022
85d68d6
Rollup merge of #100827 - JakobDegen:better-tests, r=wesleywiser
Dylan-DPC Sep 2, 2022
4c05e77
Rollup merge of #100928 - CleanCut:rustc_metadata_diagnostics, r=davi…
Dylan-DPC Sep 2, 2022
f865d5a
Rollup merge of #101166 - GuillaumeGomez:error-index-mdbook, r=notriddle
Dylan-DPC Sep 2, 2022
4fe796a
Rollup merge of #101260 - ChrisDenton:attribute-tag, r=thomcc
Dylan-DPC Sep 2, 2022
27b8d0c
Rollup merge of #101298 - notriddle:notriddle/rustdoc-main-since, r=G…
Dylan-DPC Sep 2, 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
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 @@ -2797,20 +2797,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 @@ -1281,7 +1281,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 @@ -187,6 +187,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