[lld] [lld][cmake] install symlinks when built standalone (PR #160471)

Ruoyu Zhong via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 19 11:35:40 PDT 2025


https://github.com/ZhongRuoyu updated https://github.com/llvm/llvm-project/pull/160471

>From c7a78eeb444f3a67c40c4535847f3ef737e8b879 Mon Sep 17 00:00:00 2001
From: Ruoyu Zhong <zhongruoyu at outlook.com>
Date: Wed, 24 Sep 2025 16:45:14 +0800
Subject: [PATCH] [lld][cmake] install symlinks when built standalone

lld installs symlinks with llvm_install_symlink, which relies on the
variable LLVM_USE_SYMLINKS to determine whether to use symlinks or
copies. Since that variable is defined in llvm's CMakeLists.txt, it may
not be defined when lld is built standalone. In that case, default to
using symlinks on Unix platforms. Users can still override this by
setting LLVM_USE_SYMLINKS manually.

Fixes https://github.com/llvm/llvm-project/issues/151557.

Signed-off-by: Ruoyu Zhong <zhongruoyu at outlook.com>
---
 lld/cmake/modules/AddLLD.cmake | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lld/cmake/modules/AddLLD.cmake b/lld/cmake/modules/AddLLD.cmake
index 37f73afa915f4..21008b5645d00 100644
--- a/lld/cmake/modules/AddLLD.cmake
+++ b/lld/cmake/modules/AddLLD.cmake
@@ -73,6 +73,11 @@ macro(add_lld_tool name)
 endmacro()
 
 macro(add_lld_symlink name dest)
+  # In standalone builds, LLVM_USE_SYMLINKS may not be defined.
+  # In that case, default to using symlinks on Unix platforms.
+  if(NOT DEFINED LLVM_USE_SYMLINKS)
+    set(LLVM_USE_SYMLINKS ${CMAKE_HOST_UNIX})
+  endif()
   get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
   if(LLVM_TOOL_LLVM_DRIVER_BUILD
      AND ${dest} IN_LIST LLVM_DRIVER_TOOLS



More information about the llvm-commits mailing list