[clang] [llvm] CMake: Detect properly new linker introduced in Xcode 15 (PR #77806)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 11 09:48:42 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Eric Miotto (edymtt)
<details>
<summary>Changes</summary>
[This linker](https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking) is functionally equivalent to the classic one (`ld64`) for build system purposes -- in particular to enable the use of order files to link `clang`.
For this reason, in addition to fixing the detection rename `LLVM_LINKER_IS_LD64` to `LLVM_LINKER_IS_APPLE` to make the result of such detection more clear -- this should not cause any issue to downstream users, from a quick serch in
[Sourcegraph](https://sourcegraph.com/search?q=context:global+LLVM_LINKER_IS_LD64+lang:cmake+fork:no+-file:AddLLVM.cmake+-file:clang/tools/driver/CMakeLists.txt&patternType=standard&sm=1&groupBy=repo) only Swift uses the value of this variable (which I will take care of updating in due time).
rdar://120740222
---
Full diff: https://github.com/llvm/llvm-project/pull/77806.diff
2 Files Affected:
- (modified) clang/tools/driver/CMakeLists.txt (+2-2)
- (modified) llvm/cmake/modules/AddLLVM.cmake (+3-3)
``````````diff
diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt
index 2182486f93a555..d70b92b0984e52 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -103,10 +103,10 @@ if (APPLE)
endif()
if(CLANG_ORDER_FILE AND
- (LLVM_LINKER_IS_LD64 OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
+ (LLVM_LINKER_IS_APPLE OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
include(LLVMCheckLinkerFlag)
- if (LLVM_LINKER_IS_LD64 OR (LLVM_LINKER_IS_LLD AND APPLE))
+ if (LLVM_LINKER_IS_APPLE OR (LLVM_LINKER_IS_LLD AND APPLE))
set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
elseif (LLVM_LINKER_IS_GOLD)
set(LINKER_ORDER_FILE_OPTION "-Wl,--section-ordering-file,${CLANG_ORDER_FILE}")
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 14c0837c35964d..5e989618552824 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -211,10 +211,10 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
)
if(APPLE)
- if("${stderr}" MATCHES "PROJECT:ld64")
+ if("${stderr}" MATCHES "PROGRAM:ld")
set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
- set(LLVM_LINKER_IS_LD64 YES CACHE INTERNAL "")
- message(STATUS "Linker detection: ld64")
+ set(LLVM_LINKER_IS_APPLE YES CACHE INTERNAL "")
+ message(STATUS "Linker detection: Apple")
elseif("${stderr}" MATCHES "^LLD" OR
"${stdout}" MATCHES "^LLD")
set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
``````````
</details>
https://github.com/llvm/llvm-project/pull/77806
More information about the cfe-commits
mailing list