-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
This issue was seen in https://lab.llvm.org/staging/#/builders/214/builds/5185, info copied here for reference.
Using the following configuration:
cmake -G Ninja ../llvm/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=True '-DLLVM_LIT_ARGS='"'"'-v'"'"'' -DCMAKE_INSTALL_PREFIX=../stage1.install -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_PARALLEL_LINK_JOBS=4 -DLLVM_TARGETS_TO_BUILD=Mips '-DLLVM_ENABLE_PROJECTS=llvm;clang;compiler-rt;clang-tools-extra'
compiler-rt tries to detect a multilib build of mips64 and mips32 and it does so using these flags:
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "mips")
# FIXME: Ideally, we would build the N32 library too.
if("${COMPILER_RT_MIPS_EL}" AND ("${COMPILER_RT_MIPS32R6}" OR "${COMPILER_RT_MIPS64R6}"))
test_target_arch(mipsel "" "-mips32r6" "-mabi=32" "-D_LARGEFILE_SOURCE" "-D_FILE_OFFSET_BITS=64")
test_target_arch(mips64el "" "-mips64r6" "-mabi=64")
This is passed down to https://cmake.org/cmake/help/v3.20/module/CheckCSourceCompiles.html which then errors like this:
-- Performing Test COMPILER_RT_HAS_mipsel_BFLOAT16
CMake Error: Parse error in command line argument: _LARGEFILE_SOURCE
Should be: VAR:type=value
CMake Error at /usr/share/cmake-3.25/Modules/Internal/CheckSourceCompiles.cmake:94 (try_compile):
Failed to configure test project build system.
Call Stack (most recent call first):
/usr/share/cmake-3.25/Modules/CheckCSourceCompiles.cmake:76 (cmake_check_source_compiles)
/var/lib/buildbot/workers/debian-tritium-mips64el/clang-mips64el-linux/llvm/compiler-rt/lib/builtins/CMakeLists.txt:810 (check_c_source_compiles)
I believe this is because definitions -D....
are passed as flags instead of using CMAKE_REQUIRED_DEFINITIONS
to check_c_source_compiles
.
Then somehow CMake thinks it's a CMake option not a compiler option. This may have worked in previous versions of CMake but it definitely doesn't with version 3.20.
You can reproduce this issue on another architecture by adding a -DSOMETHING
to the architecture test flags.
The workaround for this is to build only for one architecture by adding the CMake options:
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON -DCMAKE_C_COMPILER_TARGET="<your target triple>"
(https://reviews.llvm.org/D147598 improves the error reporting in that situation but does not fix this issue overall)