https://github.com/grahamc updated 
https://github.com/llvm/llvm-project/pull/242747

>From 542f3f888bdb0b3852befcd0aec59e68119ae8bb Mon Sep 17 00:00:00 2001
From: Graham Christensen <[email protected]>
Date: Sat, 14 Nov 2026 20:54:00 -0500
Subject: [PATCH] [clang][CMake] Match "lld" only in the linker file name

Skipping HOST_LINK_VERSION detection when CMAKE_LINKER matches .*lld.* is too 
broad.
Since that matched the entire path, "lld" in unrelated parts of the directory 
structure
would erroneously match.

This happened on a real environment when "lld" appeared in the Nix store path 
hash for a
recent build.

Assisted-by: Claude
---
 clang/CMakeLists.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index fbb4cfaf090059..62a28b40b7ef11 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -444,10 +444,12 @@ endif ()
 
 # Determine HOST_LINK_VERSION on Darwin.
 set(HOST_LINK_VERSION "" CACHE STRING "Host linker version on Darwin")
-if (APPLE AND NOT HOST_LINK_VERSION AND NOT CMAKE_LINKER MATCHES ".*lld.*")
+get_filename_component(CLANG_LINKER_NAME "${CMAKE_LINKER}" NAME)
+if (APPLE AND NOT HOST_LINK_VERSION AND NOT CLANG_LINKER_NAME MATCHES "lld")
   get_darwin_linker_version(HOST_LINK_VERSION)
   set(HOST_LINK_VERSION "${HOST_LINK_VERSION}" CACHE STRING "Host linker 
version on Darwin" FORCE)
 endif()
+unset(CLANG_LINKER_NAME)
 if (HOST_LINK_VERSION)
   message(STATUS "Host linker version: ${HOST_LINK_VERSION}")
 endif()

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to