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
[CMake] find_package(LLVM CONFIG)
may fail when the project does not use C
#53950
Comments
Ping. |
+1 For now this completely blocks me to update to LLVM 14 as I really don't want to enable the C language in my all C++ project. I suppose a solution could be for the FindFFI and FindTerminfo modules to fallback to |
find_package(LLVM CONFIG)
may fail then the project does not use Cfind_package(LLVM CONFIG)
may fail when the project does not use C
... due to a bug. See: llvm/llvm-project#53950 Fixes: CMake Error at /usr/local/share/cmake-3.22/Modules/Internal/CheckSourceCompiles.cmake:44 (message): check_source_compiles: C: needs to be enabled before use. Call Stack (most recent call first): /usr/local/share/cmake-3.22/Modules/CheckCSourceCompiles.cmake:76 (cmake_check_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/FindFFI.cmake:44 (check_c_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/LLVMConfig.cmake:242 (find_package) CMakeLists.txt:31 (find_package)
... due to a bug. See: llvm/llvm-project#53950 Fixes: CMake Error at /usr/local/share/cmake-3.22/Modules/Internal/CheckSourceCompiles.cmake:44 (message): check_source_compiles: C: needs to be enabled before use. Call Stack (most recent call first): /usr/local/share/cmake-3.22/Modules/CheckCSourceCompiles.cmake:76 (cmake_check_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/FindFFI.cmake:44 (check_c_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/LLVMConfig.cmake:242 (find_package) CMakeLists.txt:31 (find_package)
... due to a bug. See: llvm/llvm-project#53950 Fixes: CMake Error at /usr/local/share/cmake-3.22/Modules/Internal/CheckSourceCompiles.cmake:44 (message): check_source_compiles: C: needs to be enabled before use. Call Stack (most recent call first): /usr/local/share/cmake-3.22/Modules/CheckCSourceCompiles.cmake:76 (cmake_check_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/FindFFI.cmake:44 (check_c_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/LLVMConfig.cmake:242 (find_package) CMakeLists.txt:31 (find_package)
... due to a bug. See: llvm/llvm-project#53950 Fixes: CMake Error at /usr/local/share/cmake-3.22/Modules/Internal/CheckSourceCompiles.cmake:44 (message): check_source_compiles: C: needs to be enabled before use. Call Stack (most recent call first): /usr/local/share/cmake-3.22/Modules/CheckCSourceCompiles.cmake:76 (cmake_check_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/FindFFI.cmake:44 (check_c_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/LLVMConfig.cmake:242 (find_package) CMakeLists.txt:31 (find_package)
... due to a bug. See: llvm/llvm-project#53950 Fixes: CMake Error at /usr/local/share/cmake-3.22/Modules/Internal/CheckSourceCompiles.cmake:44 (message): check_source_compiles: C: needs to be enabled before use. Call Stack (most recent call first): /usr/local/share/cmake-3.22/Modules/CheckCSourceCompiles.cmake:76 (cmake_check_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/FindFFI.cmake:44 (check_c_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/LLVMConfig.cmake:242 (find_package) CMakeLists.txt:31 (find_package)
... due to a bug. See: llvm/llvm-project#53950 Fixes: CMake Error at /usr/local/share/cmake-3.22/Modules/Internal/CheckSourceCompiles.cmake:44 (message): check_source_compiles: C: needs to be enabled before use. Call Stack (most recent call first): /usr/local/share/cmake-3.22/Modules/CheckCSourceCompiles.cmake:76 (cmake_check_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/FindFFI.cmake:44 (check_c_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/LLVMConfig.cmake:242 (find_package) CMakeLists.txt:31 (find_package)
... due to a bug. See: llvm/llvm-project#53950 Fixes: CMake Error at /usr/local/share/cmake-3.22/Modules/Internal/CheckSourceCompiles.cmake:44 (message): check_source_compiles: C: needs to be enabled before use. Call Stack (most recent call first): /usr/local/share/cmake-3.22/Modules/CheckCSourceCompiles.cmake:76 (cmake_check_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/FindFFI.cmake:44 (check_c_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/LLVMConfig.cmake:242 (find_package) CMakeLists.txt:31 (find_package)
... due to a bug. See: llvm/llvm-project#53950 Fixes: CMake Error at /usr/local/share/cmake-3.22/Modules/Internal/CheckSourceCompiles.cmake:44 (message): check_source_compiles: C: needs to be enabled before use. Call Stack (most recent call first): /usr/local/share/cmake-3.22/Modules/CheckCSourceCompiles.cmake:76 (cmake_check_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/FindFFI.cmake:44 (check_c_source_compiles) /usr/lib/llvm-14/lib/cmake/llvm/LLVMConfig.cmake:242 (find_package) CMakeLists.txt:31 (find_package)
Ping? |
I've opened PR #68549, which should fix this issue. I did some testing with the minimal example in the OP and a few other projects, and it seems okay. If anyone wants to try modifying their local installation files and test their projects, please report back with any bugs, suggestions, or react with 👍 (if it works) on the PR page. |
If a CMake project doesn't enable the C language, then the CMake FFI and Terminfo find modules will fail their checks for compilation and linking. This commit allows projects to enable only C++ by first checking if a C compiler is set before testing C source compilation; if not, it checks whether C++ compilation succeeds. Fixes #53950
LLVM_ENABLE_FFI
andLLVM_ENABLE_TERMINFO
options enabled.Changing the
project(test LANGUAGES CXX)
line toproject(test LANGUAGES C CXX)
makes the error go away, but that's just a work-around than a solution.CMake version: 3.22.2
Introduced by: https://reviews.llvm.org/D114327
The text was updated successfully, but these errors were encountered: