Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.17.0: cmake fails on using system installed llvm/clang #126

Open
kloczek opened this issue Feb 6, 2024 · 11 comments
Open

0.17.0: cmake fails on using system installed llvm/clang #126

kloczek opened this issue Feb 6, 2024 · 11 comments

Comments

@kloczek
Copy link

kloczek commented Feb 6, 2024

Looks like vc-intrinsics wants to have an access to llvm source tree 🤔

+ /usr/bin/cmake -B x86_64-redhat-linux-gnu -D BUILD_SHARED_LIBS=ON -D CMAKE_AR=/usr/bin/gcc-ar -D CMAKE_BUILD_TYPE=RelWithDebInfo -D CMAKE_C_FLAGS_RELEASE=-DNDEBUG -D CMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -D CMAKE_Fortran_FLAGS_RELEASE=-DNDEBUG -D CMAKE_INSTALL_PREFIX=/usr -D CMAKE_NM=/usr/bin/gcc-nm -D CMAKE_RANLIB=/usr/bin/gcc-ranlib -D CMAKE_VERBOSE_MAKEFILE=ON -D INCLUDE_INSTALL_DIR=/usr/include -D LIB_INSTALL_DIR=/usr/lib64 -D LIB_SUFFIX=64 -D SHARE_INSTALL_PREFIX=/usr/share -D SYSCONF_INSTALL_DIR=/etc -S .
CMake Error at CMakeLists.txt:17 (get_filename_component):
  get_filename_component unknown component BASE_DIR


-- Configuring incomplete, errors occurred!
@vmustya
Copy link
Contributor

vmustya commented Feb 6, 2024

@kloczek, as mentioned in the readme file, the intrinsics package requires -DLLVM_DIR=<llvm install>/lib/cmake/llvm option to be passed into cmake. So, could you please pass this option and check if it helps?

@kloczek
Copy link
Author

kloczek commented Feb 7, 2024

@kloczek, as mentioned in the readme file, the intrinsics package requires -DLLVM_DIR=/lib/cmake/llvm option to be passed into cmake. So, could you please pass this option and check if it helps?

All LLVM projects are installing own cmake modules in standard cmake directory which is $(libdir)/cmake

[tkloczko@pers-jacek x86_64]$ rpm -ql llvm | grep cmake
/usr/lib64/cmake/llvm
/usr/lib64/cmake/llvm/AddLLVM.cmake
/usr/lib64/cmake/llvm/AddOCaml.cmake
/usr/lib64/cmake/llvm/AddSphinxTarget.cmake
/usr/lib64/cmake/llvm/CheckAtomic.cmake
/usr/lib64/cmake/llvm/CheckCompilerVersion.cmake
/usr/lib64/cmake/llvm/CheckProblematicConfigurations.cmake
/usr/lib64/cmake/llvm/ChooseMSVCCRT.cmake
/usr/lib64/cmake/llvm/CoverageReport.cmake
/usr/lib64/cmake/llvm/CrossCompile.cmake
/usr/lib64/cmake/llvm/DetermineGCCCompatible.cmake
/usr/lib64/cmake/llvm/FindFFI.cmake
/usr/lib64/cmake/llvm/FindLibEdit.cmake
/usr/lib64/cmake/llvm/FindLibpfm.cmake
/usr/lib64/cmake/llvm/FindOCaml.cmake
/usr/lib64/cmake/llvm/FindSphinx.cmake
/usr/lib64/cmake/llvm/FindTerminfo.cmake
/usr/lib64/cmake/llvm/FindZ3.cmake
/usr/lib64/cmake/llvm/Findzstd.cmake
/usr/lib64/cmake/llvm/GenerateVersionFromVCS.cmake
/usr/lib64/cmake/llvm/GetErrcMessages.cmake
/usr/lib64/cmake/llvm/GetLibraryName.cmake
/usr/lib64/cmake/llvm/HandleLLVMOptions.cmake
/usr/lib64/cmake/llvm/HandleLLVMStdlib.cmake
/usr/lib64/cmake/llvm/LLVM-Build.cmake
/usr/lib64/cmake/llvm/LLVM-Config.cmake
/usr/lib64/cmake/llvm/LLVMCheckLinkerFlag.cmake
/usr/lib64/cmake/llvm/LLVMConfig.cmake
/usr/lib64/cmake/llvm/LLVMConfigExtensions.cmake
/usr/lib64/cmake/llvm/LLVMConfigVersion.cmake
/usr/lib64/cmake/llvm/LLVMDistributionSupport.cmake
/usr/lib64/cmake/llvm/LLVMExports-relwithdebinfo.cmake
/usr/lib64/cmake/llvm/LLVMExports.cmake
/usr/lib64/cmake/llvm/LLVMExternalProjectUtils.cmake
/usr/lib64/cmake/llvm/LLVMInstallSymlink.cmake
/usr/lib64/cmake/llvm/LLVMProcessSources.cmake
/usr/lib64/cmake/llvm/SetTargetTriple.cmake
/usr/lib64/cmake/llvm/TableGen.cmake
/usr/lib64/cmake/llvm/TensorFlowCompile.cmake
/usr/lib64/cmake/llvm/UseLibtool.cmake
/usr/lib64/cmake/llvm/VersionFromVCS.cmake
/usr/lib64/cmake/llvm/llvm-driver-template.cpp.in

.. so instead looking for the llvm cmake module in exact directory all what should be done is just include() that module. If someone has installed that module in non standard location all what needs to be done is execute CMAKE_MODULE_PATH=</base/cmake/path> cmake <options>

In other words all those lines can be removed and replaced by probably include(llvm).

@vmustya
Copy link
Contributor

vmustya commented Feb 7, 2024

All LLVM projects are installing own cmake modules in standard cmake directory which is $(libdir)/cmake

@kloczek, at least on some distros the LLVM files are installed into /usr/lib/llvm-<version> directories as follows:

$ echo /usr/lib/llvm*
/usr/lib/llvm-11 /usr/lib/llvm-12 /usr/lib/llvm-13 /usr/lib/llvm-14 /usr/lib/llvm-15 /usr/lib/llvm-16 /usr/lib/llvm-17
$ ls /usr/lib/llvm-*/lib/cmake/llvm/
/usr/lib/llvm-11/lib/cmake/llvm/:
AddLLVM.cmake             CheckAtomic.cmake           CrossCompile.cmake            FindOCaml.cmake               HandleLLVMOptions.cmake  LLVMConfigExtensions.cmake     LLVMExports-relwithdebinfo.cmake  TableGen.cmake
AddLLVMDefinitions.cmake  CheckCompilerVersion.cmake  DetermineGCCCompatible.cmake  FindSphinx.cmake              HandleLLVMStdlib.cmake   LLVMConfigVersion.cmake        LLVMExternalProjectUtils.cmake    TensorFlowCompile.cmake
AddOCaml.cmake            CheckLinkerFlag.cmake       FindGRPC.cmake                FindZ3.cmake                  LLVM-Config.cmake        LLVMDistributionSupport.cmake  LLVMInstallSymlink.cmake          UseLibtool.cmake
AddSphinxTarget.cmake     ChooseMSVCCRT.cmake         FindLibpfm.cmake              GenerateVersionFromVCS.cmake  LLVMConfig.cmake         LLVMExports.cmake              LLVMProcessSources.cmake          VersionFromVCS.cmake

/usr/lib/llvm-12/lib/cmake/llvm/:
AddLLVM.cmake             CheckAtomic.cmake           CrossCompile.cmake            FindOCaml.cmake               GetLibraryName.cmake     LLVM-Config.cmake           LLVMDistributionSupport.cmake     LLVMInstallSymlink.cmake  UseLibtool.cmake
AddLLVMDefinitions.cmake  CheckCompilerVersion.cmake  DetermineGCCCompatible.cmake  FindSphinx.cmake              HandleLLVMOptions.cmake  LLVMConfig.cmake            LLVMExports.cmake                 LLVMProcessSources.cmake  VersionFromVCS.cmake
AddOCaml.cmake            CheckLinkerFlag.cmake       FindGRPC.cmake                FindZ3.cmake                  HandleLLVMStdlib.cmake   LLVMConfigExtensions.cmake  LLVMExports-relwithdebinfo.cmake  TableGen.cmake
AddSphinxTarget.cmake     ChooseMSVCCRT.cmake         FindLibpfm.cmake              GenerateVersionFromVCS.cmake  LLVM-Build.cmake         LLVMConfigVersion.cmake     LLVMExternalProjectUtils.cmake    TensorFlowCompile.cmake
...

We cannot hardcode any pre-defined LLVM paths in our CMakeLists.txt, because these paths are distro-dependent and LLVM version dependent. Indeed we cannot know which particular version of LLVM are you going to build vc-intrinsics package against.

So, could you please build the package as it's described in the readme file?

@kloczek
Copy link
Author

kloczek commented Feb 7, 2024

@kloczek, at least on some distros the LLVM files are installed into /usr/lib/llvm-<version> directories as follows:

I'm talking about default setup during build LLVM.
As I wrote you can choose exact version by add additional path to $CMAKE_MODULE_PATH in cmake execution env.
If you want have such functionality directly supported by vc-intrinsics cmake it should be optional and definitely not obligatory.
Just look around on any other project which uses cmake and llvm cmake module.
First example on top of my head .. https://github.com/iovisor/bpftrace/

@kloczek
Copy link
Author

kloczek commented Sep 9, 2024

Any update?
Just checked 0.20.0 and still cmake fails with unknown component BASE_DIR error message.

@vmustya
Copy link
Contributor

vmustya commented Sep 9, 2024

@kloczek, we don't plan to use the CMAKE_MODULE_PATH. The proper way is to define -DLLVM_DIR=.... This is the same way as SPIRV-LLVM-Translator uses.

@kloczek
Copy link
Author

kloczek commented Sep 10, 2024

I'm not using $CMAKE_MODULE_PATH env variable.
Could you please repeat that on building vc-intrinsics is necessary to have unpacked LLVM source tree.
If that is true .. you must be kidding.

@vmustya
Copy link
Contributor

vmustya commented Sep 10, 2024

I'm not using $CMAKE_MODULE_PATH env variable. Could you please repeat that on building vc-intrinsics is necessary to have unpacked LLVM source tree. If that is true .. you must be kidding.

The VC intrinsics library doesn't require LLVM source code. It just requires something like -DLLVM_DIR=/usr/lib/llvm-18/lib/cmake/llvm to be passed when you run cmake.

@kloczek
Copy link
Author

kloczek commented Sep 10, 2024

cmake currently do not fails because some cmake modules are missing.

+ /usr/bin/cmake -B x86_64-redhat-linux-gnu -D BUILD_SHARED_LIBS=ON -D CMAKE_AR=/usr/bin/gcc-ar -D CMAKE_BUILD_TYPE=RelWithDebInfo -D CMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -D CMAKE_C_FLAGS_RELEASE=-DNDEBUG -D CMAKE_EXPORT_COMPILE_COMMANDS=ON -D CMAKE_Fortran_FLAGS_RELEASE=-DNDEBUG -D CMAKE_INSTALL_PREFIX=/usr -D CMAKE_NM=/usr/bin/gcc-nm -D CMAKE_RANLIB=/usr/bin/gcc-ranlib -D CMAKE_VERBOSE_MAKEFILE=ON -D ENABLE_BSYMBOLICFUNCTIONS=ON -D INCLUDE_INSTALL_DIR=/usr/include -D LIB_INSTALL_DIR=/usr/lib64 -D LIB_SUFFIX=64 -D SHARE_INSTALL_PREFIX=/usr/share -D SYSCONF_INSTALL_DIR=/etc -S .
CMake Error at CMakeLists.txt:17 (get_filename_component):
  get_filename_component unknown component BASE_DIR

@vmustya
Copy link
Contributor

vmustya commented Sep 10, 2024

cmake currently do not fails because some cmake modules are missing.

+ /usr/bin/cmake -B x86_64-redhat-linux-gnu -D BUILD_SHARED_LIBS=ON -D CMAKE_AR=/usr/bin/gcc-ar -D CMAKE_BUILD_TYPE=RelWithDebInfo -D CMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -D CMAKE_C_FLAGS_RELEASE=-DNDEBUG -D CMAKE_EXPORT_COMPILE_COMMANDS=ON -D CMAKE_Fortran_FLAGS_RELEASE=-DNDEBUG -D CMAKE_INSTALL_PREFIX=/usr -D CMAKE_NM=/usr/bin/gcc-nm -D CMAKE_RANLIB=/usr/bin/gcc-ranlib -D CMAKE_VERBOSE_MAKEFILE=ON -D ENABLE_BSYMBOLICFUNCTIONS=ON -D INCLUDE_INSTALL_DIR=/usr/include -D LIB_INSTALL_DIR=/usr/lib64 -D LIB_SUFFIX=64 -D SHARE_INSTALL_PREFIX=/usr/share -D SYSCONF_INSTALL_DIR=/etc -S .
CMake Error at CMakeLists.txt:17 (get_filename_component):
  get_filename_component unknown component BASE_DIR

@kloczek, that's expected. You run cmake incorrectly. You have to pass the -DLLVM_DIR=/path/to/llvm/install/lib/cmake/llvm option. Otherwise it wouldn't work.

@kloczek
Copy link
Author

kloczek commented Sep 10, 2024

And tat is odd because all other projects are assuming that those files will be installed in standard cmake module path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants