Skip to content

Commit 4b42851

Browse files
authored
[20230725][CMake] Detect properly new linker introduced in Xcode 15 (#8006)
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 search 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 (cherry picked from commit 9175dd9)
1 parent 79aab1b commit 4b42851

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
@@ -112,10 +112,10 @@ if (APPLE)
112112
endif()
113113

114114
if(CLANG_ORDER_FILE AND
115-
(LLVM_LINKER_IS_LD64 OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
115+
(LLVM_LINKER_IS_APPLE OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
116116
include(LLVMCheckLinkerFlag)
117117

118-
if (LLVM_LINKER_IS_LD64 OR (LLVM_LINKER_IS_LLD AND APPLE))
118+
if (LLVM_LINKER_IS_APPLE OR (LLVM_LINKER_IS_LLD AND APPLE))
119119
set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
120120
elseif (LLVM_LINKER_IS_GOLD)
121121
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)