UoB-HPC / SimEng

The University of Bristol HPC Simulation Engine
https://uob-hpc.github.io/SimEng
Apache License 2.0
93 stars 20 forks source link

Gtest already imported with external LLVM #423

Open JosephMoore25 opened 2 months ago

JosephMoore25 commented 2 months ago

Check List

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:

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.

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.

tom91136 commented 1 month ago

Should be resolved in https://github.com/UoB-HPC/SimEng/pull/433