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

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

Open
6 of 7 tasks
icmccorm opened this issue Nov 1, 2022 · 11 comments
Open
6 of 7 tasks
Assignees

Comments

@icmccorm
Copy link

icmccorm commented Nov 1, 2022

  • I have searched open and closed issues for duplicates
  • 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:

  • Linux
  • Windows
  • macOS

Build Type:

  • cmake
  • 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!

@fabianbs96
Copy link
Member

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.

@fabianbs96
Copy link
Member

Can you please check whether #532 fixes the warnings you get from cmake?

@icmccorm
Copy link
Author

icmccorm commented Nov 9, 2022

Sure! I'll be able to look at this in the next day or so, and I'll get back to you ASAP.

@icmccorm
Copy link
Author

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!

@MMory
Copy link
Member

MMory commented Mar 2, 2023

what is the state of this issue? @icmccorm ?

@icmccorm
Copy link
Author

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.

@asesidaa
Copy link

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

@fabianbs96 fabianbs96 reopened this Mar 27, 2023
@fabianbs96
Copy link
Member

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?

@asesidaa
Copy link

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.

@fabianbs96
Copy link
Member

Thanks for that observation. For this one I don't have a quick fix^^. We will see what we can do about it

@asesidaa
Copy link

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

4 participants