Change:
<!-- Thank you for filing a bug report! Please provide a short summary of the bug, along with any information you feel relevant to replicating the bug. --I tried this code: and this happened: I expected to see this happen: it would compile my crate. Instead, this happened: lld failed. <!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: fixed the problem that I reported in There seems to be a new problem with an unknown linker name. <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summaryBacktrace</summary<p</p</details
Could you post the list of files in the directory in Rust distribution?
I found in the clang invocation:
It looks like maybe clang replaces and changes it from to when calling lld-wrapper?
I can't confirm whether that's the case right now, but if that's true then the fix would be as simple as adding the alternative to in lld-wrapper.
Apple ships its linker as . I couldn't find a file.
I believe the issue is with the usage of in the PR, see: You probably meant to use . Wait. is because of Windows? is the only one that does not play well with it. One solution is to normalise the string or before the match statement.
This is not happening only on osx. I can reproduce this. The path is correct and unchanged by clang, but it's indeed the call that trims too much on unixes because of the weird executable name with a dot. I'll fix it.
The problem still exists, but the error changed to on macos. Need more investigation..

Discussion:
include ../../run-make-fulldeps/tools.mk <ins> # ignore-msvc </ins> # needs-rust-lld 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

let has_hwasan = util::HWASAN_SUPPORTED_TARGETS.contains(&&*config.target); let has_memtag = util::MEMTAG_SUPPORTED_TARGETS.contains(&&*config.target); let has_shadow_call_stack = util::SHADOWCALLSTACK_SUPPORTED_TARGETS.contains(&&*config.target); <del> // for `-Z gcc-ld=lld` </del> <ins> // For tests using the `needs-rust-lld` directive (e.g. for `-Zgcc-ld=lld`), 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 // example: // - on linux, it can be <sysroot>/lib // - on windows, it can be <sysroot>/bin // // However, `rust-lld` is only located under the lib path, so we look for it there. </ins> let has_rust_lld = config .compile_lib_path <ins> .parent() .expect("couldn't traverse to the parent of the specified --compile-lib-path") .join("lib") </ins> .join("rustlib") .join(&config.target) .join("bin") <del> .join("gcc-ld") .join(if config.host.contains("windows") { "ld.exe" } else { "ld" }) </del> <ins> .join(if config.host.contains("windows") { "rust-lld.exe" } else { "rust-lld" }) </ins> .exists(); iter_header(path, src, &mut |revision, ln| { if revision.is_some() && revision != cfg { return;

//! obtained from the wrapper's name as the first two arguments. //! On Windows it spawns a `..rust-lld.exe` child process. <ins> use std::env::{self, consts::EXE_SUFFIX}; </ins> use std::fmt::Display; use std::path::{Path, PathBuf}; <del> use std::{env, process}; </del> <ins> use std::process; </ins> trait UnwrapOrExitWith<T> { fn unwrap_or_exit_with(self, context: &str) -> T;

/// Exits if the parent directory cannot be determined. fn get_rust_lld_path(current_exe_path: &Path) -> PathBuf { let mut rust_lld_exe_name = "rust-lld".to_owned(); <del> rust_lld_exe_name.push_str(env::consts::EXE_SUFFIX); </del> <ins> rust_lld_exe_name.push_str(EXE_SUFFIX); </ins> let mut rust_lld_path = current_exe_path .parent() .unwrap_or_exit_with("directory containing current executable could not be determined")

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