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,17 @@ 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} -dumpmachine ${CMAKE_CXX_COMPILER_ARG1} ${CMAKE_CXX_FLAGS} + RESULT_VARIABLE TT_RV + OUTPUT_VARIABLE value + OUTPUT_STRIP_TRAILING_WHITESPACE) + if( NOT TT_RV EQUAL 0 ) + message(WARNING "Failed to execute ${CMAKE_CXX_COMPILER} for triple detection." + "Use DLLVM_HOST_TRIPLE= to specify the host triple. If you are " + "unsure of the host triple, you can run the llvm/cmake/config.guess " + "script to find out, but be aware that config.guess is sometimes wrong.") + endif( NOT TT_RV EQUAL 0 ) endif() endif( MSVC ) set( ${var} ${value} PARENT_SCOPE )