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

CMake files do not respect the LLVM config files from the custom installation #689

Closed
3 tasks
flipreverse opened this issue Dec 8, 2023 · 1 comment · Fixed by #690
Closed
3 tasks

Comments

@flipreverse
Copy link
Contributor

  • [X ] I have searched open and closed issues for duplicates
  • [ X] I made sure that I am not using an old project version (DO: pull PhASAR, update git submodules, rebuild the project and check if the bug is still there)

Bug description

CMake does not use the include directory of the self-built LLVM/clang.

Steps to reproduce

  • Use an LLVM version greater than 14 due a bug when building it on Debian 12
  • Build steps
    • Run bootstrap.sh
    • Manually
      • CC=/fs/scratch/al/llvm-14/bin/clang CXX=/fs/scratch/al/llvm-14/bin/clang++ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DPHASAR_BUILD_UNITTESTS=true /fs/scratch/al/phasar/src
      • cmake --build . -j 1

Actual result: Due to the newer LLVM, the build process aborts. This in turn shows the wrong include dir: -I/usr/lib/llvm-14/include.

/fs/scratch/al/llvm-14/bin/clang++ -DBOOST_ALL_NO_LIB -DBOOST_GRAPH_DYN_LINK -DBOOST_REGEX_DYN_LINK -DPHASAR_BUILD_DIR=\"/fs/scratch/al/phasar/src/build\" -DPHASAR_SRC_DIR=\"/fs/scratch/al/phasar/src\" -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/usr/lib/llvm-14/include -I/fs/scratch/al/phasar/src/include -I/fs/scratch/al/phasar/src/build/include -I/fs/scratch/al/phasar/src/external/json/include -I/fs/scratch/al/phasar/src/external/json-schema-validator/src -MP -fstack-protector-strong -ffunction-sections -fdata-sections -pipe -Wall -Wextra -Wno-unused-parameter -O3 -DNDEBUG -march=native -fPIC -fvisibility-inlines-hidden -std=c++17 -MD -MT lib/CMakeFiles/phasar.dir/LibPhasar.cpp.o -MF lib/CMakeFiles/phasar.dir/LibPhasar.cpp.o.d -o lib/CMakeFiles/phasar.dir/LibPhasar.cpp.o -c /fs/scratch/al/phasar/src/lib/LibPhasar.cpp

Expected result: The CMake files should honor the custom LLVM installation. The parameter -I/usr/lib/llvm-14/include should be replaced by -I/fs/scratch/al/llvm-14//include.

(Important /fs/scratch/al/llvm-14/ does contain a built of LLVM 17.0.6. The directory name is misleading.)

Context (Environment)

  • phasar: [b796f7d44681514f58a683a3a71ff17c94edb0c1]
  • googletest: [b07f56a]
  • json: [bc889afb4c5bf1c0d8ee29ef35eaaf4c8bef8a5d]
  • json-schema-validator [491ac44026e08f31790f5cacffa62e168bb35e32]

Operating System:

  • [X ] Linux
  • Windows
  • macOS

Build Type:

  • [ X] cmake
  • [ X] bootstrap.sh
  • custom build

Possible solution

The CMake variable LLVM_INCLUDE_DIRS, used in cmake/phasar_macros.cmake:209 shall point to the aforementioned directory.
That variable is set in /fs/scratch/al/llvm-14/lib/cmake/llvm/LLVMConfig.cmake. I assume CMake must use the CMake files for LLVM from /fs/scratch/al/llvm-14/lib/cmake.

Example files

Files:

@fabianbs96
Copy link
Member

Hi @flipreverse,

PhASAR currently requires LLVM 14. We are in the process of supporting newer LLVM versions, but there are two major problems that have to be solved first (#533 and #687).

In our build configuration, we use find_package(LLVM 14 REQUIRED CONFIG) to find the required LLVM version. Even if there is a newer version installed, this command will prefer LLVM 14.
Please note, that this LLVM version is independent from the clang version that you use for compilation -- you just cannot compile the unittests with clang>14.
Your invocation

CC=/fs/scratch/al/llvm-14/bin/clang CXX=/fs/scratch/al/llvm-14/bin/clang++ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DPHASAR_BUILD_UNITTESTS=true /fs/scratch/al/phasar/src

only changes the compiler, but has no influence on the LLVM version that phasar links against.

In order to use a different LLVM version, you would need to modify the corresponding line in our top-level CMakeLists.txt.

@MMory MMory closed this as completed in #690 Feb 1, 2024
MMory pushed a commit that referenced this issue Feb 1, 2024
Currently, the custom build of LLVM must be located in
/usr/local/llvm-14.
If not, CMake will either fail finding LLVMConfig.cmake or use a
different LLVM installation, e.g., the system-wide one.
This will, for example, result in an include path different from the
custom LLVM installation.
This commit extends 'bootstrap.sh' to set 'LLVM_ROOT' to the
custom installation. Moreover, it allows the user to select
an arbitrary location for LLVM.

(Fixed #689)

Co-authored-by: Fabian Schiebel <[email protected]>
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

Successfully merging a pull request may close this issue.

2 participants