CHIP-SPV / chipStar

chipStar is a tool for compiling and running HIP/CUDA on SPIR-V via OpenCL or Level Zero APIs.
Other
220 stars 32 forks source link

cmake linker configuration issue on fedora #937

Open FuchtelJockel opened 1 week ago

FuchtelJockel commented 1 week ago
  1. mkdir build
  2. cd build
  3. cmake ..
-- Detected architecture: x86_64
-- GCC base path: /usr/lib64
-- Using llvm-config: /usr/bin/llvm-config
-- Using CLANG_ROOT_PATH: /usr
-- Using LLVM_VERSION: 18.1.8
-- Using CMAKE_CXX_COMPILER_PATH: /usr/bin/clang++
-- Using CMAKE_C_COMPILER_PATH: /usr/bin/clang
-- CMAKE_CXX_COMPILER is set to . Overriding with /usr/bin/clang++
-- CMAKE_C_COMPILER is set to . Overriding with /usr/bin/clang
-- Using llvm-link: /usr/bin/llvm-link
-- XXX LLVM-version-major: 18
-- Using llvm-spirv: /usr/bin/llvm-spirv
-- Using clang-offload-bundler: /usr/bin/clang-offload-bundler
-- llvm-spirv version: LLVM (http://llvm.org/):
  LLVM version 18.1.8
  Optimized build.

-- The CXX compiler identification is Clang 18.1.8
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ - broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake:60 (message):
  The C++ compiler

    "/usr/bin/clang++"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/home/alexander/TODO/de.demuc.colmap/chipStar/build/CMakeFiles/CMakeScratch/TryCompile-aorOCu'

    Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_0129a/fast
    /usr/bin/gmake  -f CMakeFiles/cmTC_0129a.dir/build.make CMakeFiles/cmTC_0129a.dir/build
    gmake[1]: Entering directory '/home/alexander/TODO/de.demuc.colmap/chipStar/build/CMakeFiles/CMakeScratch/TryCompile-aorOCu'
    Building CXX object CMakeFiles/cmTC_0129a.dir/testCXXCompiler.cxx.o
    /usr/bin/clang++   -Wno-duplicate-decl-specifier -Wno-tautological-constant-compare  -Wno-c++20-extensions -Wno-unused-result -Wno-delete-abstract-non-virtual-dtor -Wno-deprecated-declarations -Wunused-command-line-argument -gdwarf-4 --gcc-toolchain=/usr/lib64  -MD -MT CMakeFiles/cmTC_0129a.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_0129a.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_0129a.dir/testCXXCompiler.cxx.o -c /home/alexander/TODO/de.demuc.colmap/chipStar/build/CMakeFiles/CMakeScratch/TryCompile-aorOCu/testCXXCompiler.cxx
    Linking CXX executable cmTC_0129a
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_0129a.dir/link.txt --verbose=1
    /usr/bin/clang++  -Wno-duplicate-decl-specifier -Wno-tautological-constant-compare  -Wno-c++20-extensions -Wno-unused-result -Wno-delete-abstract-non-virtual-dtor -Wno-deprecated-declarations -Wunused-command-line-argument -gdwarf-4 --gcc-toolchain=/usr/lib64  CMakeFiles/cmTC_0129a.dir/testCXXCompiler.cxx.o -o cmTC_0129a 
    /usr/bin/ld: cannot find crtbegin.o: No such file or directory
    /usr/bin/ld: cannot find -lstdc++: No such file or directory
    clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    gmake[1]: *** [CMakeFiles/cmTC_0129a.dir/build.make:100: cmTC_0129a] Error 1
    gmake[1]: Leaving directory '/home/alexander/TODO/de.demuc.colmap/chipStar/build/CMakeFiles/CMakeScratch/TryCompile-aorOCu'
    gmake: *** [Makefile:127: cmTC_0129a/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  cmake/FindLLVM.cmake:144 (enable_language)
  CMakeLists.txt:69 (include)

Searching for this issue online or asking the AI didn't really help, sadly.

pvelesko commented 1 week ago
CMAKE_C_COMPILER_WORKS
CMAKE_CXX_COMPILER_WORKS

What if you skip compiler checks -DCMAKE_CXX_COMPILER_WORKS=1 ?

FuchtelJockel commented 1 week ago

Now it configures until:

-- Looking for C++ include filesystem
-- Looking for C++ include filesystem - not found
-- Looking for C++ include experimental/filesystem
-- Looking for C++ include experimental/filesystem - not found
CMake Error at CMakeLists.txt:167 (message):
  <filesystem> was not found.

I have installed both libcxx-devel and libstdc++-devel

$ find /usr/include/c++ -name filesystem
/usr/include/c++/14/experimental/filesystem
/usr/include/c++/14/filesystem
/usr/include/c++/v1/filesystem
FuchtelJockel commented 1 week ago

I found the issue.

which gcc
/usr/lib64/ccache/gcc

This will set the GCC_BASE_PATH to /usr/lib64 and CMake will look for /usr/lib64/include instead of /usr/include.