This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Support symlinks even with LLVM_INSTALL_TOOLCHAIN_ONLY
ClosedPublic

Authored by phosek on Sep 29 2016, 9:37 PM.

Details

Summary

When LLVM_INSTALL_TOOLCHAIN_ONLY is used and LLVM_TOOLCHAIN_TOOLS contains a tool which is a symlink, it would be ignored. This already worked before but got broken in r282510.

Diff Detail

Event Timeline

phosek updated this revision to Diff 72975.Sep 29 2016, 9:37 PM
phosek retitled this revision from to [CMake] Support symlinks even with LLVM_INSTALL_TOOLCHAIN_ONLY.
phosek updated this object.
phosek added a reviewer: beanz.
phosek set the repository for this revision to rL LLVM.
phosek added subscribers: llvm-commits, phosek.
beanz edited edge metadata.Sep 29 2016, 10:22 PM

Looking at this, I messed up that logic worse than this fixes. I completely broke LLVM_INSTALL_TOOLCHAIN_ONLY=Off for symlinks.

I think something like this would cover your case and fix LLVM_INSTALL_TOOLCHAIN_ONLY:

diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index 51ae62d..00f2e80 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -1264,11 +1264,11 @@ function(add_llvm_tool_symlink name dest)
     set_target_properties(${target_name} PROPERTIES FOLDER Tools)
 
     # Make sure both the link and target are toolchain tools
-    if (NOT ${name} IN_LIST LLVM_TOOLCHAIN_TOOLS OR NOT ${dest} IN_LIST LLVM_TOOLCHAIN_TOOLS)
-      return()
+    if (${name} IN_LIST LLVM_TOOLCHAIN_TOOLS OR ${dest} IN_LIST LLVM_TOOLCHAIN_TOOLS)
+      set(TOOL_IS_TOOLCHAIN On)
     endif()
 
-    if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_TOOLS )
+    if ((TOOL_IS_TOOLCHAIN OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) AND LLVM_BUILD_TOOLS)
       llvm_install_symlink(${name} ${dest})
     endif()
   endif()

Thoughts?

LGTM! Shouldn't TOOL_IS_TOOLCHAIN be lowercase since a lower-case variable (I've seen both variants used in LLVM so I'm not sure if there is convention)? Shall I just update the diff with your version or do you want submit a new diff?

phosek updated this revision to Diff 72982.Sep 29 2016, 10:52 PM
phosek edited edge metadata.
phosek removed rL LLVM as the repository for this revision.

I just tested this with our toolchain build and seems to be working fine.

beanz accepted this revision.Sep 29 2016, 11:03 PM
beanz edited edge metadata.

One comment below. Otherwise LGTM, go ahead and commit.

Thanks for catching this!

cmake/modules/AddLLVM.cmake
1267

This should actually be AND not OR since we shouldn't install the symlink without also installing the tool.

This revision is now accepted and ready to land.Sep 29 2016, 11:03 PM
phosek updated this revision to Diff 72985.Sep 29 2016, 11:37 PM
phosek edited edge metadata.
phosek marked an inline comment as done.
This revision was automatically updated to reflect the committed changes.