diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -475,6 +475,9 @@ set(LLVM_CODESIGNING_IDENTITY "" CACHE STRING "Sign executables and dylibs with the given identity or skip if empty (Darwin Only)") +option(LLVM_USE_CONFIG_GUESS + "(deprecated) Use config.guess to determine host architecture. This option will be removed in the future." OFF) + # If enabled, verify we are on a platform that supports oprofile. if( LLVM_USE_OPROFILE ) if( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" ) diff --git a/llvm/cmake/modules/GetHostTriple.cmake b/llvm/cmake/modules/GetHostTriple.cmake --- a/llvm/cmake/modules/GetHostTriple.cmake +++ b/llvm/cmake/modules/GetHostTriple.cmake @@ -44,7 +44,7 @@ else( MSVC ) if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND NOT MSYS) message(WARNING "unable to determine host target triple") - else() + elseif(LLVM_USE_CONFIG_GUESS) set(config_guess ${LLVM_MAIN_SRC_DIR}/cmake/config.guess) execute_process(COMMAND sh ${config_guess} RESULT_VARIABLE TT_RV @@ -54,6 +54,23 @@ message(FATAL_ERROR "Failed to execute ${config_guess}") endif( NOT TT_RV EQUAL 0 ) set( value ${TT_OUT} ) + elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + execute_process(COMMAND ${CMAKE_CXX_COMPILER} -v + RESULT_VARIABLE TT_RV + ERROR_VARIABLE TT_OUT + ERROR_STRIP_TRAILING_WHITESPACE) + if( NOT TT_RV EQUAL 0 ) + message(FATAL_ERROR "Failed to execute ${CMAKE_CXX_COMPILER} for triple detection") + endif( NOT TT_RV EQUAL 0 ) + string(REGEX MATCH "Target: ([^\r\n]+)[\r\n]" value "${TT_OUT}") + if (NOT "${CMAKE_MATCH_1}" STREQUAL "") + set(value ${CMAKE_MATCH_1}) + else() + message(FATAL_ERROR "Unable to determine host triple. Please file a bug. " + "You may work around this for now configuring with " + "-DLLVM_USE_CONFIG_GUESS=ON, however, this option " + "will be removed in the future") + endif() endif() endif( MSVC ) set( ${var} ${value} PARENT_SCOPE )