[PATCH] D101070: Make `llvm_install_symlink` robust with respect to absolute dirs.

John Ericson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 27 13:50:17 PST 2021


Ericson2314 updated this revision to Diff 396339.
Ericson2314 added a comment.
Herald added a project: Flang.



1. Updating D101070 <https://reviews.llvm.org/D101070>: Make `llvm_install_symlink` robust with respect to absolute dirs. #
2. Enter a brief description of the changes included in this update.
3. The first line is used as subject, next lines as comment. #
4. If you intended to create a new revision, use:
5. $ arc diff --create

rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101070/new/

https://reviews.llvm.org/D101070

Files:
  clang/cmake/modules/AddClang.cmake
  flang/cmake/modules/AddFlang.cmake
  lld/cmake/modules/AddLLD.cmake
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/LLVMInstallSymlink.cmake


Index: llvm/cmake/modules/LLVMInstallSymlink.cmake
===================================================================
--- llvm/cmake/modules/LLVMInstallSymlink.cmake
+++ llvm/cmake/modules/LLVMInstallSymlink.cmake
@@ -2,9 +2,9 @@
 # DESTDIR environment variable may be unset at configuration time.
 # See PR8397.
 
-function(install_symlink name target outdir)
+function(install_symlink name target absolute_outdir)
   set(DESTDIR $ENV{DESTDIR})
-  set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}")
+  set(bindir "${DESTDIR}${absolute_outdir}")
 
   message(STATUS "Creating ${name}")
 
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1905,7 +1905,7 @@
 
 endfunction()
 
-function(llvm_install_symlink name dest)
+function(llvm_install_symlink name dest output_dir)
   cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN})
   foreach(path ${CMAKE_MODULE_PATH})
     if(EXISTS ${path}/LLVMInstallSymlink.cmake)
@@ -1928,7 +1928,7 @@
   set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX})
 
   install(SCRIPT ${INSTALL_SYMLINK}
-          CODE "install_symlink(${full_name} ${full_dest} ${LLVM_TOOLS_INSTALL_DIR})"
+          CODE "install_symlink(${full_name} ${full_dest} ${output_dir})"
           COMPONENT ${component})
 
   if (NOT LLVM_ENABLE_IDE AND NOT ARG_ALWAYS_GENERATE)
@@ -2011,7 +2011,8 @@
     endif()
 
     if ((TOOL_IS_TOOLCHAIN OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) AND LLVM_BUILD_TOOLS)
-      llvm_install_symlink(${link_name} ${target})
+      GNUInstallDirs_get_absolute_install_dir(output_dir LLVM_TOOLS_INSTALL_DIR)
+      llvm_install_symlink(${link_name} ${target} ${output_dir})
     endif()
   endif()
 endfunction()
Index: lld/cmake/modules/AddLLD.cmake
===================================================================
--- lld/cmake/modules/AddLLD.cmake
+++ lld/cmake/modules/AddLLD.cmake
@@ -62,5 +62,5 @@
 macro(add_lld_symlink name dest)
   add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
   # Always generate install targets
-  llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
+  llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} ALWAYS_GENERATE)
 endmacro()
Index: flang/cmake/modules/AddFlang.cmake
===================================================================
--- flang/cmake/modules/AddFlang.cmake
+++ flang/cmake/modules/AddFlang.cmake
@@ -124,6 +124,6 @@
 macro(add_flang_symlink name dest)
   add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
   # Always generate install targets
-  llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
+  llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} ALWAYS_GENERATE)
 endmacro()
 
Index: clang/cmake/modules/AddClang.cmake
===================================================================
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -175,7 +175,7 @@
 macro(add_clang_symlink name dest)
   add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
   # Always generate install targets
-  llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
+  llvm_install_symlink(${name} ${dest} ${CMAKE_INSTALL_FULL_BINDIR} ALWAYS_GENERATE)
 endmacro()
 
 function(clang_target_link_libraries target type)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101070.396339.patch
Type: text/x-patch
Size: 3323 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211227/b9c3d21e/attachment.bin>


More information about the cfe-commits mailing list