Skip to content

Commit

Permalink
Try use lld instead of lld-link when using clang
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Dec 21, 2024
1 parent 0f6a106 commit 427111e
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/compiler/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<'a> Clang<'a> {
let target_unknown_vendor = target.replace("-pc-", "-unknown-");
let env_target = target.to_lowercase().replace('-', "_");

symlink_llvm_tool("rust-lld", "lld-link", env_path.clone(), &cache_dir)?;
symlink_llvm_tool("rust-lld", "lld", env_path.clone(), &cache_dir)?;
symlink_llvm_tool("llvm-ar", "llvm-lib", env_path.clone(), &cache_dir)?;
symlink_llvm_tool("llvm-ar", "llvm-dlltool", env_path.clone(), &cache_dir)?;

Expand All @@ -87,15 +87,15 @@ impl<'a> Clang<'a> {
cmd.env(format!("AR_{}", env_target), "llvm-lib");
cmd.env(
format!("CARGO_TARGET_{}_LINKER", env_target.to_uppercase()),
"lld-link",
"lld",
);

let user_set_c_flags = env::var("CFLAGS").unwrap_or_default();
let user_set_cxx_flags = env::var("CXXFLAGS").unwrap_or_default();
let sysroot_dir =
adjust_canonicalization(msvc_sysroot_dir.to_slash_lossy().to_string());
let clang_flags = format!(
"--target={target_no_vendor} -fuse-ld=lld-link -I{dir}/include -I{dir}/include/c++/stl -L{dir}/lib/{target_unknown_vendor}",
"--target={target_no_vendor} -fuse-ld=lld -I{dir}/include -I{dir}/include/c++/stl -L{dir}/lib/{target_unknown_vendor}",
dir = sysroot_dir,
);
cmd.env(
Expand All @@ -116,9 +116,6 @@ impl<'a> Clang<'a> {
);

let mut rustflags = get_rustflags(&workdir, target)?.unwrap_or_default();
rustflags
.flags
.extend(["-C".to_string(), "linker-flavor=lld-link".to_string()]);
rustflags.push(format!(
"-Lnative={dir}/lib/{target_unknown_vendor}",
dir = sysroot_dir,
Expand Down Expand Up @@ -239,12 +236,12 @@ set(CMAKE_SYSTEM_PROCESSOR {processor})
set(CMAKE_C_COMPILER clang CACHE FILEPATH "")
set(CMAKE_CXX_COMPILER clang++ CACHE FILEPATH "")
set(CMAKE_LINKER lld-link CACHE FILEPATH "")
set(CMAKE_LINKER_TYPE LLD CACHE FILEPATH "")
set(CMAKE_RC_COMPILER llvm-rc CACHE FILEPATH "")
set(COMPILE_FLAGS
--target={target_no_vendor}
-fuse-ld=lld-link
-fuse-ld=lld
-I{dir}/include
-I{dir}/include/c++/stl)
Expand Down

0 comments on commit 427111e

Please sign in to comment.