Skip to content

Commit 9d955a6

Browse files
authored
[driver] Allow ld as a driver alias to lld (#90515)
This adds a "hidden" alias kind that allows using LLD when symlinked as `ld`; however, it does not install `ld` as a symlink. This is to allow either using a mixed toolchain with both LLD and GNU ld, or a pure LLD toolchain where LLD has been installed (or symlinked) to `ld` for compatibility w/ older tools that expect `ld`.
1 parent 975eca0 commit 9d955a6

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

lld/tools/lld/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ endif()
4242
foreach(link ${LLD_SYMLINKS_TO_CREATE})
4343
add_lld_symlink(${link} lld)
4444
endforeach()
45+
46+
if(LLVM_TOOL_LLVM_DRIVER_BUILD)
47+
set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_HIDDEN_TOOL_ALIASES_lld ld)
48+
endif()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# REQUIRES: llvm-driver, lld
22

33
# RUN: %llvm ld.lld --help | FileCheck %s
4+
# RUN: %llvm ld --help | FileCheck %s
45
# RUN: %llvm lld -flavor ld.lld --help | FileCheck %s
6+
# RUN: %llvm ld -flavor ld.lld --help | FileCheck %s
57

68
# CHECK: supported targets: elf

llvm/tools/llvm-driver/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ foreach(tool ${LLVM_DRIVER_TOOLS})
1313
string(REPLACE "llvm-" "" alias ${alias})
1414
set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${alias}\", ${tool_entry})\n")
1515
endforeach()
16+
get_property(hidden_tool_aliases GLOBAL PROPERTY LLVM_DRIVER_HIDDEN_TOOL_ALIASES_${tool})
17+
foreach(alias ${hidden_tool_aliases})
18+
string(REPLACE "llvm-" "" alias ${alias})
19+
set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${alias}\", ${tool_entry})\n")
20+
endforeach()
1621
endforeach()
1722

1823
file(WRITE

utils/bazel/llvm-project-overlay/llvm/driver.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ _TOOLS = {
3737
# aliases for a given tool.
3838
_EXTRA_ALIASES = {
3939
"clang": ["clang++", "clang-cl", "clang-cpp"],
40-
"lld": ["lld-link", "ld.lld", "ld64.lld", "wasm-ld"],
40+
"lld": ["ld", "lld-link", "ld.lld", "ld64.lld", "wasm-ld"],
4141
"llvm-ar": ["ranlib", "lib", "dlltool"],
4242
"llvm-objcopy": ["bitcode-strip", "install-name-tool", "strip"],
4343
"llvm-objdump": ["otool"],

0 commit comments

Comments
 (0)