[lld] [llvm] [driver] Allow `ld` as a driver alias to lld (PR #90515)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 29 12:38:51 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld
Author: Jordan Rupprecht (rupprecht)
<details>
<summary>Changes</summary>
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`.
---
Full diff: https://github.com/llvm/llvm-project/pull/90515.diff
4 Files Affected:
- (modified) lld/tools/lld/CMakeLists.txt (+4)
- (modified) llvm/test/tools/llvm-driver/passthrough-lld.test (+2)
- (modified) llvm/tools/llvm-driver/CMakeLists.txt (+5)
- (modified) utils/bazel/llvm-project-overlay/llvm/driver.bzl (+1-1)
``````````diff
diff --git a/lld/tools/lld/CMakeLists.txt b/lld/tools/lld/CMakeLists.txt
index 0f5daa78846bc7..8498a91597a930 100644
--- a/lld/tools/lld/CMakeLists.txt
+++ b/lld/tools/lld/CMakeLists.txt
@@ -42,3 +42,7 @@ endif()
foreach(link ${LLD_SYMLINKS_TO_CREATE})
add_lld_symlink(${link} lld)
endforeach()
+
+if(LLVM_TOOL_LLVM_DRIVER_BUILD)
+ set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_HIDDEN_TOOL_ALIASES_lld ld)
+endif()
diff --git a/llvm/test/tools/llvm-driver/passthrough-lld.test b/llvm/test/tools/llvm-driver/passthrough-lld.test
index acd5f38784811c..b31fa4e483b92c 100644
--- a/llvm/test/tools/llvm-driver/passthrough-lld.test
+++ b/llvm/test/tools/llvm-driver/passthrough-lld.test
@@ -1,6 +1,8 @@
# REQUIRES: llvm-driver, lld
# RUN: %llvm ld.lld --help | FileCheck %s
+# RUN: %llvm ld --help | FileCheck %s
# RUN: %llvm lld -flavor ld.lld --help | FileCheck %s
+# RUN: %llvm ld -flavor ld.lld --help | FileCheck %s
# CHECK: supported targets: elf
diff --git a/llvm/tools/llvm-driver/CMakeLists.txt b/llvm/tools/llvm-driver/CMakeLists.txt
index 83e084069b96ac..82d85c7230109c 100644
--- a/llvm/tools/llvm-driver/CMakeLists.txt
+++ b/llvm/tools/llvm-driver/CMakeLists.txt
@@ -13,6 +13,11 @@ foreach(tool ${LLVM_DRIVER_TOOLS})
string(REPLACE "llvm-" "" alias ${alias})
set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${alias}\", ${tool_entry})\n")
endforeach()
+ get_property(hidden_tool_aliases GLOBAL PROPERTY LLVM_DRIVER_HIDDEN_TOOL_ALIASES_${tool})
+ foreach(alias ${hidden_tool_aliases})
+ string(REPLACE "llvm-" "" alias ${alias})
+ set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${alias}\", ${tool_entry})\n")
+ endforeach()
endforeach()
file(WRITE
diff --git a/utils/bazel/llvm-project-overlay/llvm/driver.bzl b/utils/bazel/llvm-project-overlay/llvm/driver.bzl
index 888626d7cf8451..10796d91983433 100644
--- a/utils/bazel/llvm-project-overlay/llvm/driver.bzl
+++ b/utils/bazel/llvm-project-overlay/llvm/driver.bzl
@@ -37,7 +37,7 @@ _TOOLS = {
# aliases for a given tool.
_EXTRA_ALIASES = {
"clang": ["clang++", "clang-cl", "clang-cpp"],
- "lld": ["lld-link", "ld.lld", "ld64.lld", "wasm-ld"],
+ "lld": ["ld", "lld-link", "ld.lld", "ld64.lld", "wasm-ld"],
"llvm-ar": ["ranlib", "lib", "dlltool"],
"llvm-objcopy": ["bitcode-strip", "install-name-tool", "strip"],
"llvm-objdump": ["otool"],
``````````
</details>
https://github.com/llvm/llvm-project/pull/90515
More information about the llvm-commits
mailing list