Skip to content

Commit 22b4ea4

Browse files
committed
Proper macOS libLLVM symlink when cross compiling
When cross compiling on macOS with `llvm.link-shared` enabled, the symlink creation will fail after compiling LLVM for the target architecture, because it will attempt to create the symlink in the host LLVM directory, which was already created when being built. This commit changes the symlink path to the actual LLVM output.
1 parent a5c6a48 commit 22b4ea4

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/bootstrap/native.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -487,16 +487,14 @@ impl Step for Llvm {
487487
let version = output(cmd.arg("--version"));
488488
let major = version.split('.').next().unwrap();
489489
let lib_name = match llvm_version_suffix {
490-
Some(s) => format!("lib/libLLVM-{}{}.dylib", major, s),
491-
None => format!("lib/libLLVM-{}.dylib", major),
490+
Some(s) => format!("libLLVM-{}{}.dylib", major, s),
491+
None => format!("libLLVM-{}.dylib", major),
492492
};
493493

494-
// The reason why we build the library path from llvm-config is because
495-
// the output of llvm-config depends on its location in the file system.
496-
// Make sure we create the symlink exactly where it's needed.
497-
let llvm_base = build_llvm_config.parent().unwrap().parent().unwrap();
498-
let lib_llvm = llvm_base.join(lib_name);
499-
t!(builder.symlink_file("libLLVM.dylib", &lib_llvm));
494+
let lib_llvm = out_dir.join("build").join("lib").join(lib_name);
495+
if !lib_llvm.exists() {
496+
t!(builder.symlink_file("libLLVM.dylib", &lib_llvm));
497+
}
500498
}
501499

502500
t!(stamp.write());

0 commit comments

Comments
 (0)