Index: cmake/config-ix.cmake =================================================================== --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -102,22 +102,30 @@ # flags to verify that: # 1) is defined (if non-empty) # 2) simple file can be successfully built. -# If successful, saves target flags for this architecture. +# If successful, saves target flags for this architecture. When we build only +# the builtins library, we assume that is supported if it's equal to the +# compiler-rt's default target architecture and the C compiler is forced by the +# user. macro(test_target_arch arch def) - set(TARGET_${arch}_CFLAGS ${ARGN}) - set(argstring "") - foreach(arg ${ARGN}) - set(argstring "${argstring} ${arg}") - endforeach() - check_compile_definition("${def}" "${argstring}" HAS_${arch}_DEF) - if(NOT HAS_${arch}_DEF) - set(CAN_TARGET_${arch} FALSE) + if (CMAKE_C_COMPILER_FORCED AND NOT COMPILER_RT_BUILD_SANITIZERS AND + COMPILER_RT_DEFAULT_TARGET_ARCH STREQUAL "${arch}") + set(CAN_TARGET_${arch} TRUE) else() - set(argstring "${CMAKE_EXE_LINKER_FLAGS} ${argstring}") - try_compile(CAN_TARGET_${arch} ${CMAKE_BINARY_DIR} ${SIMPLE_SOURCE} - COMPILE_DEFINITIONS "${TARGET_${arch}_CFLAGS}" - OUTPUT_VARIABLE TARGET_${arch}_OUTPUT - CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${argstring}") + set(TARGET_${arch}_CFLAGS ${ARGN}) + set(argstring "") + foreach(arg ${ARGN}) + set(argstring "${argstring} ${arg}") + endforeach() + check_compile_definition("${def}" "${argstring}" HAS_${arch}_DEF) + if(NOT HAS_${arch}_DEF) + set(CAN_TARGET_${arch} FALSE) + else() + set(argstring "${CMAKE_EXE_LINKER_FLAGS} ${argstring}") + try_compile(CAN_TARGET_${arch} ${CMAKE_BINARY_DIR} ${SIMPLE_SOURCE} + COMPILE_DEFINITIONS "${TARGET_${arch}_CFLAGS}" + OUTPUT_VARIABLE TARGET_${arch}_OUTPUT + CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${argstring}") + endif() endif() if(${CAN_TARGET_${arch}}) list(APPEND COMPILER_RT_SUPPORTED_ARCH ${arch})