Index: cmake/base-config-ix.cmake =================================================================== --- cmake/base-config-ix.cmake +++ cmake/base-config-ix.cmake @@ -176,12 +176,30 @@ # -mips32r2/-mips64r2. We don't use -mips1/-mips3 because we want to match # clang's default CPU's. In the 64-bit case, we must also specify the ABI # since the default ABI differs between gcc and clang. + # + # We also have to tolerate differences between different versions of GCC + # and Clang, notably that --target=mips(el)-linux-gnu is accepted by both + # but required for Clang and gives a warning for GCC prior to 7. GCC 7 + # rejects the option, causing a configuration issue leading cmake to + # believe GCC for mips, can't compile for mips. + set(CLANG_TARGET_FLAG "") + set(CLANG_TARGET_FLAG64 "") + if(CMAKE_C_COMPILER_ID MATCHES Clang) + set(CLANG_MIPS_TARGET_FLAG "--target=mipsel-linux-gnu") + set(CLANG_MIPS_TARGET_FLAG64 "--target=mips64el-linux-gnu") + endif() # FIXME: Ideally, we would build the N32 library too. - test_target_arch(mipsel "" "-mips32r2" "--target=mipsel-linux-gnu") - test_target_arch(mips64el "" "-mips64r2" "--target=mips64el-linux-gnu" "-mabi=64") + test_target_arch(mipsel "" "-mips32r2" "${CLANG_MIPS_TARGET_FLAG}" "-mabi=32") + test_target_arch(mips64el "" "-mips64r2" "${CLANG_MIPS_TARGET_FLAG64}" "-mabi=64") elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "mips") - test_target_arch(mips "" "-mips32r2" "--target=mips-linux-gnu") - test_target_arch(mips64 "" "-mips64r2" "--target=mips64-linux-gnu" "-mabi=64") + set(CLANG_TARGET_FLAG "") + set(CLANG_TARGET_FLAG64 "") + if(CMAKE_C_COMPILER_ID MATCHES Clang) + set(CLANG_MIPS_TARGET_FLAG "--target=mips-linux-gnu") + set(CLANG_MIPS_TARGET_FLAG64 "--target=mips64-linux-gnu") + endif() + test_target_arch(mips "" "-mips32r2" "${CLANG_MIPS_TARGET_FLAG}" "-mabi=32") + test_target_arch(mips64 "" "-mips64r2" "${CLANG_MIPS_TARGET_FLAG64}" "-mabi=64") elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "arm") if(WIN32) test_target_arch(arm "" "" "")