From fab28f2a4d0bd394546cc37417c7b8aa4ecc1a21 Mon Sep 17 00:00:00 2001 From: Rémy Rakic Date: Sat, 18 May 2024 22:58:25 +0000 Subject: rust-lld: fallback to the default default sysroot where rustc is currently located --- compiler/rustc_codegen_ssa/src/back/link.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_codegen_ssa/src') diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 6939674ce9d..874732ee9ef 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -3116,13 +3116,21 @@ fn add_lld_args( let self_contained_linker = self_contained_cli || self_contained_target; if self_contained_linker && !sess.opts.cg.link_self_contained.is_linker_disabled() { + let mut linker_path_exists = false; for path in sess.get_tools_search_paths(false) { + let linker_path = path.join("gcc-ld"); + linker_path_exists |= linker_path.exists(); cmd.arg({ let mut arg = OsString::from("-B"); - arg.push(path.join("gcc-ld")); + arg.push(linker_path); arg }); } + if !linker_path_exists { + // As an additional sanity check, we do nothing if the sysroot doesn't contain the + // linker path at all. + return; + } } // 2. Implement the "linker flavor" part of this feature by asking `cc` to use some kind of -- cgit 1.4.1-3-g733a5