iAI icon indicating copy to clipboard operation
iAI copied to clipboard

Unable to build use-phasar-as-library example, phasar_FOUND set to false

Open icmccorm opened this issue 1 year ago • 11 comments

  • [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 and PHASAR_INCLUDE_DIR environment variables to point to the lib and include directories in either /usr/local/../phasar or in the build 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!

icmccorm avatar Nov 01 '22 23:11 icmccorm