diff options
| author | bors <bors@rust-lang.org> | 2022-09-02 18:40:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-02 18:40:21 +0000 |
| commit | 9ba169a73acfa9c9875b76eec09e9a91cc6246df (patch) | |
| tree | 356cb29d703b6de6f28ac6d1c455274822bbb1e9 /src/tools | |
| parent | b88e510cc886e4c367d90e1c7c36013a4bc0d6ab (diff) | |
| parent | e77b8ce1001b3174c5acc1990a4c86c73b0cd1e8 (diff) | |
Auto merge of #101333 - matthiaskrgr:rollup-qpf1otj, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #100121 (Try normalizing types without RevealAll in ParamEnv in MIR validation) - #100200 (Change implementation of `-Z gcc-ld` and `lld-wrapper` again) - #100814 ( Porting 'compiler/rustc_trait_selection' to translatable diagnostics - Part 1) - #101215 (Also replace the version placeholder in rustc_attr) - #101260 (Use `FILE_ATTRIBUTE_TAG_INFO` to get reparse tag) - #101323 (Remove unused .toggle-label CSS rule) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/lld-wrapper/src/main.rs | 35 | ||||
| -rw-r--r-- | src/tools/replace-version-placeholder/src/main.rs | 2 |
2 files changed, 20 insertions, 17 deletions
diff --git a/src/tools/lld-wrapper/src/main.rs b/src/tools/lld-wrapper/src/main.rs index 90bd24a75e0..1795f3d7fe5 100644 --- a/src/tools/lld-wrapper/src/main.rs +++ b/src/tools/lld-wrapper/src/main.rs @@ -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}; @@ -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 } diff --git a/src/tools/replace-version-placeholder/src/main.rs b/src/tools/replace-version-placeholder/src/main.rs index 146e53f2e9a..33b35d05415 100644 --- a/src/tools/replace-version-placeholder/src/main.rs +++ b/src/tools/replace-version-placeholder/src/main.rs @@ -14,7 +14,7 @@ fn main() { walk::filter_dirs(path) // We exempt these as they require the placeholder // for their operation - || path.ends_with("compiler/rustc_passes/src/lib_features.rs") + || path.ends_with("compiler/rustc_attr/src/builtin.rs") || path.ends_with("src/tools/tidy/src/features/version.rs") || path.ends_with("src/tools/replace-version-placeholder") }, |
