This is an archive of the discontinued LLVM Phabricator instance.

[llvm] [cmake] Silence GNUInstallDirs warning in LLVMInstallSymlink
ClosedPublic

Authored by mgorny on Oct 23 2022, 10:03 PM.

Details

Summary

Set a dummy CMAKE_INSTALL_LIBDIR in order to silence the following CMake
warning when executing LLVMInstallSymlink.cmake script:

CMake Warning (dev) at /usr/share/cmake/Modules/GNUInstallDirs.cmake:243 (message):
  Unable to determine default CMAKE_INSTALL_LIBDIR directory because no
  target architecture is known.  Please enable at least one language before
  including GNUInstallDirs.
Call Stack (most recent call first):
  /usr/lib/llvm/16/lib64/cmake/llvm/LLVMInstallSymlink.cmake:5 (include)
  tools/lld/cmake_install.cmake:66 (include)
  cmake_install.cmake:52 (include)

Diff Detail

Event Timeline

mgorny created this revision.Oct 23 2022, 10:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 23 2022, 10:04 PM
Herald added a subscriber: StephenFan. · View Herald Transcript
mgorny requested review of this revision.Oct 23 2022, 10:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 23 2022, 10:04 PM

What's the cmake configure command and ninja target to trigger the warning?

What's the cmake configure command and ninja target to trigger the warning?

I've noticed it while installing LLD standalone, so in my case it was:

cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm/16 -DBUILD_SHARED_LIBS=ON -DLLVM_INCLUDE_TESTS=no -DCMAKE_BUILD_TYPE=RelWithDebInfo ../lld
ninja -v -j12
ninja -v -j12 install

How to do a standalone build? The lld standalone build is not documented.

% cmake -GNinja -Sllvm -B/tmp/out/custom-llvm custom-llvm -DLLVM_ENABLE_PROJECTS=llvm -DCMAKE_INSTALL_PREFIX=/tmp/opt/llvm
% ninja install
% cmake -GNinja -Slld -B/tmp/out/lld -DLLVM_BUILD_MAIN_SRC_DIR=/tmp/out/custom-llvm/lib/cmake/llvm -DLLVM_DIR=/tmp/out/custom-llvm/lib/cmake/llvm -DLLVM_INCLUDE_TESTS=off
-- Building with -fPIC
-- LLD version: 16.0.0
-- Configuring done
CMake Error at /tmp/out/custom-llvm/lib/cmake/llvm/AddLLVM.cmake:958 (add_executable):
  Cannot find source file:

    /tmp/out/lld/tools/lld/lld-driver.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
  .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc
Call Stack (most recent call first):
  cmake/modules/AddLLD.cmake:35 (add_llvm_executable)
  cmake/modules/AddLLD.cmake:44 (add_lld_executable)
  tools/lld/CMakeLists.txt:5 (add_lld_tool)


CMake Error at /tmp/out/custom-llvm/lib/cmake/llvm/AddLLVM.cmake:958 (add_executable):
  No SOURCES given to target: lld
Call Stack (most recent call first):
  cmake/modules/AddLLD.cmake:35 (add_llvm_executable)
  cmake/modules/AddLLD.cmake:44 (add_lld_executable)
  tools/lld/CMakeLists.txt:5 (add_lld_tool)


CMake Generate step failed.  Build files cannot be regenerated correctly.

If you don't mind me being busy with other things right now, I've found a simpler reproducer:

$ cmake -GNinja ../llvm  -DCMAKE_INSTALL_PREFIX=$HOME/llvm-install -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_DISTRIBUTION_COMPONENTS=llvm-addr2line
[...]
$ ninja install-distribution
[...]
[690/691] cd /home/mgorny/llvm-project/llvm-build/tools/llvm-symbo...2line" -P /home/mgorny/llvm-project/llvm-build/cmake_install.cmake
-- Install configuration: "MinSizeRel"
CMake Warning (dev) at /usr/share/cmake/Modules/GNUInstallDirs.cmake:241 (message):
  Unable to determine default CMAKE_INSTALL_LIBDIR directory because no
  target architecture is known.  Please enable at least one language before
  including GNUInstallDirs.
Call Stack (most recent call first):
  /home/mgorny/llvm-project/llvm/cmake/modules/LLVMInstallSymlink.cmake:5 (include)
  cmake_install.cmake:56 (include)
  /home/mgorny/llvm-project/llvm-build/tools/cmake_install.cmake:119 (include)
  /home/mgorny/llvm-project/llvm-build/cmake_install.cmake:81 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Creating llvm-addr2line
MaskRay accepted this revision.Oct 27 2022, 10:32 AM

Thanks for the instructions. I see the warning and curl -L 'https://reviews.llvm.org/D136573?download=1' | patch -p0 fixes it.

Normally uploaded patches are applied via patch -p1. The patch you uploaded uses

--- llvm/cmake/modules/LLVMInstallSymlink.cmake
+++ llvm/cmake/modules/LLVMInstallSymlink.cmake

instead of a/ b/ (git format-patch -1, git diff 'HEAD^', etc).

This revision is now accepted and ready to land.Oct 27 2022, 10:32 AM

I've uploaded git-format-patch. Phabricator does weird stuff to patches sometimes. Never really figured it out. Can't wait to see it go in favor of GitHub pull requests (or anything else, really).