Skip to content

Commit

Permalink
Rollup merge of rust-lang#98880 - topjohnwu:macos-dylib-cross, r=jyn514
Browse files Browse the repository at this point in the history
Proper macOS libLLVM symlink when cross compiling

Follow up of rust-lang#98418

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.

r? `@jyn514`
  • Loading branch information
GuillaumeGomez authored Jul 5, 2022
2 parents 4986379 + 22b4ea4 commit 3fe0191
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,16 +487,14 @@ impl Step for Llvm {
let version = output(cmd.arg("--version"));
let major = version.split('.').next().unwrap();
let lib_name = match llvm_version_suffix {
Some(s) => format!("lib/libLLVM-{}{}.dylib", major, s),
None => format!("lib/libLLVM-{}.dylib", major),
Some(s) => format!("libLLVM-{}{}.dylib", major, s),
None => format!("libLLVM-{}.dylib", major),
};

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

t!(stamp.write());
Expand Down

0 comments on commit 3fe0191

Please sign in to comment.