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

Gtest already imported with external LLVM #423

Open
JosephMoore25 opened this issue Aug 29, 2024 · 1 comment
Open

Gtest already imported with external LLVM #423

JosephMoore25 opened this issue Aug 29, 2024 · 1 comment
Labels
bug Something isn't working build Issues with the buid process and its dependencies tests Testing and CI

Comments

@JosephMoore25
Copy link
Contributor

Check List

  • [N/A] The binary I am trying to run has been compiled statically for either RV64 or AArch64.
  • [N/A] The compiled binary is a Linux Elf file.
  • [N/A] I have provided both a config file and a binary to SimEng as runtime arguments.

Binary File Information
Please run file on the binary used and paste the output below (i.e. file myBinary.elf).
N/A

System Description
Please provide the following as a list:

  • The Operating System of the system you are running SimEng on
    Ubuntu 22.04
  • The compiler used to compile SimEng and its version
    gcc 11.4.0 + clang-14.0.5
  • The compiler used to compile the static binary and its version
    N/A
  • The ISA or specific processor that the binary was compiled for
    • For example, if -march=armv8.4-a+sve was used, then present armv8.4-a+sve
    • If -mcpu=neoverse-v1 or similar was used, then present neoverse-v1
      N/A
  • The processor of the system you are running SimEng on
    N/A
  • The main memory capacity of the system you are running SimEng on
    64 GB

SimEng Version
Provide the SimEng repository branch, commit hash, and version tag (if relevant) that the issue is present on.
Any, but specifically tested on dev

SimEng CMAKE Options Used
Provide a bullet list of all CMAKE options used. E.g. -DCMAKE_BUILD_TYPE=Release.

  • -B build
  • -S .
  • -DCMAKE_BUILD_TYPE=Release
  • -DCMAKE_INSTALL_PREFIX=$HOME/SimEng/build/
  • -DSIMENG_ENABLE_TESTS=ON
  • -DSIMENG_USE_EXTERNAL_LLVM=ON
  • -DLLVM_DIR=$HOME/clang-14.0.5/lib/cmake/llvm/
  • -GNinja

Binary Compilation Instructions
Provide a bullet list of how the binary in question was compiled, including all compiler flags used.
N/A

SimEng Command Line Expression
Provide the command line expression used to run SimEng e.g. ./simeng /path/to/configs/a64fx.yaml /path/to/myBinary.elf
N/A

SimEng Metadata Output
If your simulation begins to execute the binary, please provide the metadata that SimEng prints at the start of execution.
N/A

Problem Description
Simeng fails to build with tests enabled when using an external clang/llvm build that has been built with unit tests enabled (the default build option). It errors with the following:

CMake Error at build/_deps/googletest-src/googletest/cmake/internal_utils.cmake:152 (add_library):
  add_library cannot create target "gtest" because an imported target with
  the same name already exists.

This appears to be because LLVM builds its unit tests with googletests as well, and if a version doesn't yet exist on the system (or isn't specified), then it installs version release-1.11.0, the same used in SimEng. This release version was found in llvm-project/third-party/benchmark/cmake/GoogleTest.cmake.in.

I expect a fix would be in SimEng's CMakeLists.txt to search for an existing gtest install, and if a compatible one is found to instead use this rather than attempting to still install.

In the meantime, users (and myself) can fix this by one of the following options:

  1. Recompiling clang/llvm with the flag -DLLVM_INCLUDE_TESTS=OFF to disable unit tests (and therefore not installing gtest),
  2. Building SimEng without using an external LLVM,
  3. Building SimEng with tests disabled.

Any of these three options should suffice for the short term.

@JosephMoore25 JosephMoore25 added bug Something isn't working tests Testing and CI build Issues with the buid process and its dependencies labels Aug 29, 2024
@tom91136
Copy link
Member

tom91136 commented Oct 6, 2024

Should be resolved in #433

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build Issues with the buid process and its dependencies tests Testing and CI
Projects
Status: ToDo
Development

No branches or pull requests

2 participants