iAI
iAI copied to clipboard
Unable to build use-phasar-as-library example, phasar_FOUND set to false
- [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
I receive warnings of the following form when executing cmake .
as a step toward building the use-phasar-as-library example.
CMake Warning at /usr/local/phasar/lib/cmake/phasar/phasar_ifdside-config.cmake:28 (find_package):
Found package configuration file:
/usr/local/phasar/lib/cmake/phasar/phasarConfig.cmake
but it set phasar_FOUND to FALSE so package "phasar" is considered to be
NOT FOUND. Reason given by package:
The following imported targets are referenced, but are missing:
phasar::phasar_phasarllvm_utils
Call Stack (most recent call first):
/usr/local/phasar/lib/cmake/phasar/phasarConfig.cmake:31 (include)
CMakeLists.txt:16 (find_package)
This occurs for both phasar::phasar_phasarllvm_utils
and phasar::phasar_utils
. When using bootstrap.sh
as opposed to a custom build script, I also encountered this error:
CMake Error at /usr/local/lib/cmake/nlohmann_json_schema_validator/nlohmann_json_schema_validatorTargets.cmake:69 (message):
The imported target "nlohmann_json_schema_validator" references the file
"/usr/local/lib/libnlohmann_json_schema_validator.so.2.1.0"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/local/lib/cmake/nlohmann_json_schema_validator/nlohmann_json_schema_validatorTargets.cmake"
but not all the files it references.
Call Stack (most recent call first):
/usr/local/lib/cmake/nlohmann_json_schema_validator/nlohmann_json_schema_validatorConfig.cmake:12 (include)
/usr/local/phasar/lib/cmake/phasar/phasar_taintconfig-config.cmake:20 (find_package)
/usr/local/phasar/lib/cmake/phasar/phasarConfig.cmake:31 (include)
/usr/local/phasar/lib/cmake/phasar/phasar_ifdside-config.cmake:28 (find_package)
/usr/local/phasar/lib/cmake/phasar/phasarConfig.cmake:31 (include)
CMakeLists.txt:16 (find_package)
I have been able to build and use PhaSAR's example-tool without these errors occurring; this only happens when building something outside of PhaSAR's source.
Configuration
This occurs when building PhaSAR's use-phasar-as-library example in a Docker container on my M1 MacBook Pro; x86 emulation isn't enabled. I have created a directory with the contents of use-phasar-as-library
and a clone of PhaSAR inside. The structure is like so:
|- dir
|- phasar
|- ... (clone of phasar)
|- CMakeLists.txt
|- Dockerfile
|- myphasartool.cpp
|- README.md
When troubleshooting, I built PhaSAR in two ways. In the first configuration, I executed sudo ./bootstrap.sh
as suggested in the readme. Only this configuration triggered the error with json_schema_validator
. In the second configuration, I recreated the commands used in the GitHub Actions workflow configuration with an additional cmake . --install
at the end. Both Dockerfiles are attached below to assist with recreating these errors.
Within CMakeLists.txt
, I set the PHASAR_LIBRARY_DIR
and PHASAR_INCLUDE_DIR
variables to point to the include
and lib
directories in both phasar/build/
as well as /usr/local/lib/phasar/
and /usr/local/include/phasar/
. The error occurred with each of these options.
Steps to reproduce
- Copy the contents of use-phasar-as-library to a directory
- Clone PhaSAR into this directory
- Build PhaSAR using
bootstrap.sh
or the commands for a Release build as specified in ci.yml - Modify the
PHASAR_LIB_DIR
andPHASAR_INCLUDE_DIR
environment variables to point to thelib
andinclude
directories in either/usr/local/../phasar
or in thebuild
directory of the clone of PhaSAR. - Execute
cmake .
in the directory containing the contents of use-phasar-as-library
Context (Environment)
- phasar: [11aab80]
- googletest: [e2239ee]
- json: [4f8fba1]
- WALi-OpenNWA: [27fc1d0]
Operating System:
- [x] Linux
- [ ] Windows
- [x] macOS
Build Type:
- [x] cmake
- [x] custom build
Possible solution
Unknown.
Example files
Here are Dockerfiles that recreate each of the configurations I used.
Files:
Many thanks for your time and assistance!
Hi @icmccorm, I could reproduce your issue. Seems that our installation process is somewhat broken. However, with the non-bootstrap build I could still get myphasartool to build successfully (when out-commenting the stuff about WholeProgramAnalysis which seems to be out-of-sync with rest of phasar). I will see, what we can do about this issue.
Can you please check whether #532 fixes the warnings you get from cmake?
Sure! I'll be able to look at this in the next day or so, and I'll get back to you ASAP.
My apologies for the delay!
I tried building this in the first docker container configuration I mentioned, which I had linked under Dockerfile-custom.txt. I received the following error:
CMake Error at CMakeLists.txt:139 (find_package):
Could not find a configuration file for package "LLVM" that is compatible
with requested version "10".
The following configuration files were considered but not accepted:
/usr/lib/llvm-14/cmake/LLVMConfig.cmake, version: 14.0.6
/lib/llvm-14/cmake/LLVMConfig.cmake, version: 14.0.6
I haven't been able to try this again with Dockerfile-bootstrap.txt, but I'll follow up again in the next day or two once I can!
what is the state of this issue? @icmccorm ?
Sorry for the wait! I just tried building in a local docker container using ./bootstrap.sh on my M1 Mac, and it worked correctly, passing all tests. Closing this issue.
Looks like the example is again broken on develop branch, with the renaming and split of libraries.
I have tried to add the libraries by changing here to
set(PHASAR_COMPONENTS
utils
config
llvm_utils
passes
llvm_db
db
llvm_pointer
pointer
llvm_controlflow
controlflow
llvm_typehierarchy
taintconfig
llvm_ifdside
)
, but now I get this error
CMake Error at CMakeLists.txt:16 (find_package):
Found package configuration file:
/usr/local/phasar/lib/cmake/phasar/phasarConfig.cmake
but it set phasar_FOUND to FALSE so package "phasar" is considered to be
NOT FOUND. Reason given by package:
The following imported targets are referenced, but are missing:
phasar::phasar_llvm
Add llvm
to it introduces more errors, looks like there's dependency issue in these
hi @asesidaa, thanks for pointing that out. You are right, the installation is broken again. Can you try whether https://github.com/secure-software-engineering/phasar/tree/f-FixInstallAfterReworkFolderStructure fixes the issue?
Thanks for the quick fix. I have tested it, the example now works correctly.
Oh, and another issue related to nlohmann_json_schema_validator
also occured at my end, but I was able to fix that issue.
It seems that when installed using bootstrap.sh
the cmake files for nlohmann_json_schema_validator
library are installed into /usr/local/lib/cmake
instead of /usr/local/phasar/lib/cmake
, and _IMPORT_PREFIX
is set to /usr/local
where as the real library (.so) files are installed into /usr/local/phasar/lib
. By manually moving the files to correct location and fix the prefix, this issue was solved manually.
Thanks for that observation. For this one I don't have a quick fix^^. We will see what we can do about it
It seems that the json validator repo has updated the cmake file about install, which could be related?
https://github.com/pboettch/json-schema-validator/blob/main/CMakeLists.txt#L129 https://github.com/pboettch/json-schema-validator/blob/27fc1d094503623dfe39365ba82581507524545c/CMakeLists.txt#L158