Skip to content

Conversation

@flipreverse
Copy link

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 the CMake scripts to force the user to specify the variable PHASAR_LLVM_INSTALL_DIR that points to the LLVM installation directory.
This variable is also used to extend CMAKE_PREFIX_PATH which will make CMake use LLVMConfig.cmake from the custom build.
(Fixed #689)

@fabianbs96
Copy link
Member

Hi @flipreverse,

as I already commented on #689, PhASAR's CMake Configuration should be able to automatically find the correct LLVM installation.

In addition, the bootstrap script is meant for the very first build of phasar only and it installs all system dependencies of phasar, as well as the correct LLVM version.
If you use a custom LLVM that you have built (and installed) already, the bootstrap script is probably not, what you are looking for.

Furthermore, it is not a good idea to force users to pass an additional argument to the cmake command (PHASAR_LLVM_INSTALL_DIR).
So, as of now, I am not in favor of merging this PR.

@flipreverse
Copy link
Author

flipreverse commented Dec 9, 2023

Hi @flipreverse,

as I already commented on #689, PhASAR's CMake Configuration should be able to automatically find the correct LLVM installation.

I can ensure you, it doesn't. It looks at system paths, e.g., /usr/lib/..., and at /usr/local/llvm-14/.
There is currently no way to make CMake use a custom path. We, for example, want to install that LLVM custom build at /fs/proj/phasar . CMake won't detect that path unless explicitly specified.

In addition, the bootstrap script is meant for the very first build of phasar only and it installs all system dependencies of phasar, as well as the correct LLVM version. If you use a custom LLVM that you have built (and installed) already, the bootstrap script is probably not, what you are looking for.

Furthermore, it is not a good idea to force users to pass an additional argument to the cmake command (PHASAR_LLVM_INSTALL_DIR). So, as of now, I am not in favor of merging this PR.

What do you think about an optional argument?
PHASAR_LLVM_INSTALL_DIR defaults to /usr/local/llvm-14, and can be overwritten.

@fabianbs96
Copy link
Member

Hi @flipreverse,
according to the cmake documentation for find_package you can customize the search procedure.
Have you tried setting the cmake- or env variable LLVM_ROOT to your LLVM installation?

@flipreverse
Copy link
Author

Hi @flipreverse, according to the cmake documentation for find_package you can customize the search procedure. Have you tried setting the cmake- or env variable LLVM_ROOT to your LLVM installation?

That did the trick. Thx! :)
Now I get a compile error on my Debian Testing: use of undeclared identifier 'uint32_t' std::vector<uint32_t> SourceValues;. But that is a different issue.

Out of curiosity: Why are LLVM_INSTALL_DIR and PHASAR_INSTALL_DIR read-only variables? At least for PHASAR_INSTALL_DIR there is a cmdline switch.

What do you think about the following patch?
Add a new cmdline switch to change the LLVM install dir. If used, bootstrap.sh will set LLVM_ROOT.

@fabianbs96
Copy link
Member

Hi @flipreverse, to answer your questions:

Out of curiosity: Why are LLVM_INSTALL_DIR and PHASAR_INSTALL_DIR read-only variables? At least for PHASAR_INSTALL_DIR there is a cmdline switch.

We simply did not have the use-case yet of installing LLVM to a custom location; probably PHASAR_INSTALL_DIR should not be readonly then anyway

What do you think about the following patch?
Add a new cmdline switch to change the LLVM install dir. If used, bootstrap.sh will set LLVM_ROOT

This sounds reasonable

@flipreverse
Copy link
Author

Hi @flipreverse, to answer your questions:

Out of curiosity: Why are LLVM_INSTALL_DIR and PHASAR_INSTALL_DIR read-only variables? At least for PHASAR_INSTALL_DIR there is a cmdline switch.

We simply did not have the use-case yet of installing LLVM to a custom location; probably PHASAR_INSTALL_DIR should not be readonly then anyway

What do you think about the following patch?
Add a new cmdline switch to change the LLVM install dir. If used, bootstrap.sh will set LLVM_ROOT

This sounds reasonable

What is your opinion on the new commit?

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)
Copy link
Member

@fabianbs96 fabianbs96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

@MMory MMory merged commit 7aae84d into secure-software-engineering:development Feb 1, 2024
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 this pull request may close these issues.

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

3 participants