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

[C++] CMake Configuration Broken When Setting CMAKE_CXX_COMPILER=clang++ #45325

Open
WillAyd opened this issue Jan 21, 2025 · 0 comments
Open

Comments

@WillAyd
Copy link
Contributor

WillAyd commented Jan 21, 2025

Describe the bug, including details regarding any error messages, version, and platform.

If you add -DCMAKE_CXX_COMPILER=clang++ you get a rather confusing error message about the threads library not being found:

$ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja -DARROW_COMPUTE=ON -DARROW_BUILD_TESTS=ON -DCMAKE_CXX_COMPILER=clang++
CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
  /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.28/Modules/FindThreads.cmake:226 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  cmake_modules/ThirdpartyToolchain.cmake:1050 (find_package)
  CMakeLists.txt:546 (include)

If you look at the CMake configuration log, you will see that the error actually doesn't have anything to do with thread support, but rather with the C compiler (in my case gcc) being provided arguments that only work with clang:

---
events:
    kind: "try_compile-v1"
    backtrace:
      - "/usr/share/cmake-3.28/Modules/Internal/CheckSourceCompiles.cmake:101 (try_compile)"
      - "/usr/share/cmake-3.28/Modules/CheckCSourceCompiles.cmake:52 (cmake_check_source_compiles)"
      - "/usr/share/cmake-3.28/Modules/FindThreads.cmake:97 (CHECK_C_SOURCE_COMPILES)"
      - "/usr/share/cmake-3.28/Modules/FindThreads.cmake:163 (_threads_check_libc)"
      - "cmake_modules/ThirdpartyToolchain.cmake:1050 (find_package)"
      - "CMakeLists.txt:546 (include)"
    checks:
      - "Performing Test CMAKE_HAVE_LIBC_PTHREAD"
    directories:
      source: "/home/willayd/clones/arrow/cpp/build/CMakeFiles/CMakeScratch/TryCompile-C4sSBS"
      binary: "/home/willayd/clones/arrow/cpp/build/CMakeFiles/CMakeScratch/TryCompile-C4sSBS"
    cmakeVariables:
      CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS: "/usr/bin/clang-scan-deps-18"
      CMAKE_C_FLAGS: "-O0 -O0 -Qunused-arguments"
      CMAKE_C_FLAGS_DEBUG: "-g -Werror -O0 -ggdb "
      CMAKE_EXE_LINKER_FLAGS: ""
      CMAKE_MODULE_PATH: "/home/willayd/clones/arrow/cpp/cmake_modules"
      CMAKE_POSITION_INDEPENDENT_CODE: "ON"
    buildResult:
      variable: "CMAKE_HAVE_LIBC_PTHREAD"
      cached: true
      stdout: |
        Change Dir: '/home/willayd/clones/arrow/cpp/build/CMakeFiles/CMakeScratch/TryCompile-C4sSBS'
        
        Run Build Command(s): /usr/bin/ninja -v cmTC_500bc
        [1/2] /usr/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD  -O0 -O0 -Qunused-arguments  -std=gnu11 -fPIE -o CMakeFiles/cmTC_500bc.dir/src.c.o -c /home/willayd/clones/arrow/cpp/build/CMakeFiles/CMakeScratch/TryCompile-C4sSBS/src.c
        FAILED: CMakeFiles/cmTC_500bc.dir/src.c.o 
        /usr/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD  -O0 -O0 -Qunused-arguments  -std=gnu11 -fPIE -o CMakeFiles/cmTC_500bc.dir/src.c.o -c /home/willayd/clones/arrow/cpp/build/CMakeFiles/CMakeScratch/TryCompile-C4sSBS/src.c
        cc: error: unrecognized command-line option ‘-Qunused-arguments’
        ninja: build stopped: subcommand failed.
        
      exitCode: 1

Component(s)

C++

WillAyd added a commit to WillAyd/arrow that referenced this issue Jan 21, 2025
WillAyd added a commit to WillAyd/arrow that referenced this issue Jan 21, 2025
WillAyd added a commit to WillAyd/arrow that referenced this issue Jan 21, 2025
@kou kou changed the title CMake Configuration Broken When Setting CMAKE_CXX_COMPILER=clang++ [C++] CMake Configuration Broken When Setting CMAKE_CXX_COMPILER=clang++ Jan 21, 2025
WillAyd added a commit to WillAyd/arrow that referenced this issue Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant