Skip to content

Commit 1530d4c

Browse files
committed
[CMake] Detect properly new linker introduced in Xcode 15
As explained in [1], this linker 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 [2], only Swift uses the value of this variable (which I will take care of updating in due time). [1]: https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking [2]: 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 rdar://120740222
1 parent 5c150e7 commit 1530d4c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

clang/tools/driver/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ if (APPLE)
103103
endif()
104104

105105
if(CLANG_ORDER_FILE AND
106-
(LLVM_LINKER_IS_LD64 OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
106+
(LLVM_LINKER_IS_APPLE OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
107107
include(LLVMCheckLinkerFlag)
108108

109-
if (LLVM_LINKER_IS_LD64 OR (LLVM_LINKER_IS_LLD AND APPLE))
109+
if (LLVM_LINKER_IS_APPLE OR (LLVM_LINKER_IS_LLD AND APPLE))
110110
set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
111111
elseif (LLVM_LINKER_IS_GOLD)
112112
set(LINKER_ORDER_FILE_OPTION "-Wl,--section-ordering-file,${CLANG_ORDER_FILE}")

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
211211
)
212212

213213
if(APPLE)
214-
if("${stderr}" MATCHES "PROJECT:ld64")
214+
if("${stderr}" MATCHES "PROGRAM:ld")
215215
set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
216-
set(LLVM_LINKER_IS_LD64 YES CACHE INTERNAL "")
217-
message(STATUS "Linker detection: ld64")
216+
set(LLVM_LINKER_IS_APPLE YES CACHE INTERNAL "")
217+
message(STATUS "Linker detection: Apple")
218218
elseif("${stderr}" MATCHES "^LLD" OR
219219
"${stdout}" MATCHES "^LLD")
220220
set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")

0 commit comments

Comments
 (0)