[llvm] fc651a0 - [CMake] Add option LLVM_FORCE_CREATE_SYMLINKS

Tobias Hieta via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 12 02:06:41 PDT 2022


Author: Tobias Hieta
Date: 2022-10-12T11:06:32+02:00
New Revision: fc651a06699eb10429316760dc5a6fef1eadab21

URL: https://github.com/llvm/llvm-project/commit/fc651a06699eb10429316760dc5a6fef1eadab21
DIFF: https://github.com/llvm/llvm-project/commit/fc651a06699eb10429316760dc5a6fef1eadab21.diff

LOG: [CMake] Add option LLVM_FORCE_CREATE_SYMLINKS

On Windows we don't create symlinks for the binaries (clang++, clang-cl)
since the support requires special setup (group policy settings and
you need to know exactly our distribution story). But if you know
about these things and have a controlled environment there is a lot
of storage to be saved, so let's add a manual opt-in for using symlinks
on Windows with LLVM_FORCE_CREATE_SYMLINKS=ON.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D135578

Added: 
    

Modified: 
    llvm/CMakeLists.txt
    llvm/cmake/modules/AddLLVM.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 4db8c458f923..d5925f9ae6a8 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -300,6 +300,11 @@ option(LLVM_INSTALL_BINUTILS_SYMLINKS
 option(LLVM_INSTALL_CCTOOLS_SYMLINKS
   "Install symlinks from the cctools tool names to the corresponding LLVM tools." OFF)
 
+# By default we use symlinks on Unix platforms and copy binaries on Windows
+# If you have the correct setup on Windows you can use this option to enable
+# symlinks and save a lot of diskspace.
+option(LLVM_USE_SYMLINKS "Use symlinks instead of copying binaries" ${CMAKE_HOST_UNIX})
+
 option(LLVM_INSTALL_UTILS "Include utility binaries in the 'install' target." OFF)
 
 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)

diff  --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 5bd862ac7201..83fb25b40049 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -2117,7 +2117,7 @@ function(llvm_add_tool_symlink project link_name target)
   if(NOT ARG_OUTPUT_DIR)
     # If you're not overriding the OUTPUT_DIR, we can make the link relative in
     # the same directory.
-    if(CMAKE_HOST_UNIX)
+    if(LLVM_USE_SYMLINKS)
       set(dest_binary "$<TARGET_FILE_NAME:${target}>")
     endif()
     if(CMAKE_CONFIGURATION_TYPES)
@@ -2143,7 +2143,7 @@ function(llvm_add_tool_symlink project link_name target)
     endif()
   endif()
 
-  if(CMAKE_HOST_UNIX)
+  if(LLVM_USE_SYMLINKS)
     set(LLVM_LINK_OR_COPY create_symlink)
   else()
     set(LLVM_LINK_OR_COPY copy)


        


More information about the llvm-commits mailing list