Pass -fuse-ld=/path/to/ld64 if -Z gcc-ld and the lld_flavor for the target is Ld64
This commit is contained in:
parent
a519095054
commit
0f7702efa1
1 changed files with 33 additions and 14 deletions
|
@ -2485,13 +2485,31 @@ fn add_gcc_ld_path(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||||
if let LinkerFlavor::Gcc = flavor {
|
if let LinkerFlavor::Gcc = flavor {
|
||||||
match ld_impl {
|
match ld_impl {
|
||||||
LdImpl::Lld => {
|
LdImpl::Lld => {
|
||||||
|
if sess.target.lld_flavor == LldFlavor::Ld64 {
|
||||||
|
let tools_path =
|
||||||
|
sess.host_filesearch(PathKind::All).get_tools_search_paths(false);
|
||||||
|
let ld64_exe = tools_path
|
||||||
|
.into_iter()
|
||||||
|
.map(|p| p.join("gcc-ld"))
|
||||||
|
.map(|p| {
|
||||||
|
p.join(if sess.host.is_like_windows { "ld64.exe" } else { "ld64" })
|
||||||
|
})
|
||||||
|
.find(|p| p.exists())
|
||||||
|
.unwrap_or_else(|| sess.fatal("rust-lld (as ld64) not found"));
|
||||||
|
cmd.cmd().arg({
|
||||||
|
let mut arg = OsString::from("-fuse-ld=");
|
||||||
|
arg.push(ld64_exe);
|
||||||
|
arg
|
||||||
|
});
|
||||||
|
} else {
|
||||||
let tools_path =
|
let tools_path =
|
||||||
sess.host_filesearch(PathKind::All).get_tools_search_paths(false);
|
sess.host_filesearch(PathKind::All).get_tools_search_paths(false);
|
||||||
let lld_path = tools_path
|
let lld_path = tools_path
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|p| p.join("gcc-ld"))
|
.map(|p| p.join("gcc-ld"))
|
||||||
.find(|p| {
|
.find(|p| {
|
||||||
p.join(if sess.host.is_like_windows { "ld.exe" } else { "ld" }).exists()
|
p.join(if sess.host.is_like_windows { "ld.exe" } else { "ld" })
|
||||||
|
.exists()
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| sess.fatal("rust-lld (as ld) not found"));
|
.unwrap_or_else(|| sess.fatal("rust-lld (as ld) not found"));
|
||||||
cmd.cmd().arg({
|
cmd.cmd().arg({
|
||||||
|
@ -2501,6 +2519,7 @@ fn add_gcc_ld_path(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sess.fatal("option `-Z gcc-ld` is used even though linker flavor is not gcc");
|
sess.fatal("option `-Z gcc-ld` is used even though linker flavor is not gcc");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue