[llvm] [cmake, Apple] Check ld-classic when looking for ld64. (PR #77136)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 5 12:32:01 PST 2024


https://github.com/fhahn created https://github.com/llvm/llvm-project/pull/77136

In newer SDKs, ld64 is called ld-classic. Look for it first, as ld in those SDKs is still missing some functionality some tests depend on.

This enables running the tests from check-llvm-tools-lto with newer SDKs on ARM64 macOS.

>From 9fdffd9561d06e08857dbb0319708f520e5f6d31 Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Fri, 5 Jan 2024 19:46:22 +0000
Subject: [PATCH] [cmake,Apple] Check ld-classic when looking for ld64.

In newer SDKs, ld64 is called ld-classic. Look for it first, as ld in
those SDKs is still missing some functionality some tests depend on.

This enables running the tests from check-llvm-tools-lto with newer SDKs
on ARM64 macOS.
---
 llvm/cmake/config-ix.cmake | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 3e12213f6e6b5d..bf1b110245bb2f 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -639,12 +639,25 @@ if(CMAKE_HOST_APPLE AND APPLE)
     if(NOT CMAKE_XCRUN)
       find_program(CMAKE_XCRUN NAMES xcrun)
     endif()
+
+    # First, check if there's ld-classic, which is ld64 in newer SDKs.
     if(CMAKE_XCRUN)
-      execute_process(COMMAND ${CMAKE_XCRUN} -find ld
+      execute_process(COMMAND ${CMAKE_XCRUN} -find ld-classic
         OUTPUT_VARIABLE LD64_EXECUTABLE
         OUTPUT_STRIP_TRAILING_WHITESPACE)
     else()
-      find_program(LD64_EXECUTABLE NAMES ld DOC "The ld64 linker")
+      find_program(LD64_EXECUTABLE NAMES ld-classic DOC "The ld64 linker")
+    endif()
+
+    # Otherwise look for ld directly.
+    if(NOT LD64_EXECUTABLE)
+        if(CMAKE_XCRUN)
+          execute_process(COMMAND ${CMAKE_XCRUN} -find ld
+            OUTPUT_VARIABLE LD64_EXECUTABLE
+            OUTPUT_STRIP_TRAILING_WHITESPACE)
+        else()
+          find_program(LD64_EXECUTABLE NAMES ld DOC "The ld64 linker")
+        endif()
     endif()
   endif()
 



More information about the llvm-commits mailing list