[compiler-rt] r277377 - [CMake] Don't trust compiler error code, also check for errors
Chris Bieneman via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 1 13:18:18 PDT 2016
Author: cbieneman
Date: Mon Aug 1 15:18:18 2016
New Revision: 277377
URL: http://llvm.org/viewvc/llvm-project?rev=277377&view=rev
Log:
[CMake] Don't trust compiler error code, also check for errors
Summary: rnk reported that MSVC ignores unknown flags and still returns 0. This should cause unknown flags to be an error during the compiler check.
Reviewers: rnk
Subscribers: brad.king, llvm-commits
Differential Revision: https://reviews.llvm.org/D23030
Modified:
compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake
Modified: compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake?rev=277377&r1=277376&r2=277377&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake (original)
+++ compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake Mon Aug 1 15:18:18 2016
@@ -1,3 +1,4 @@
+include(CMakeCheckCompilerFlagCommonPatterns)
# This function takes an OS and a list of architectures and identifies the
# subset of the architectures list that the installed toolchain can target.
@@ -37,7 +38,18 @@ function(try_compile_only output)
OUTPUT_VARIABLE TEST_OUTPUT
ERROR_VARIABLE TEST_ERROR
)
- if(result EQUAL 0)
+
+ CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCCompilerFlag_COMMON_PATTERNS)
+ foreach(var ${_CheckCCompilerFlag_COMMON_PATTERNS})
+ if("${var}" STREQUAL "FAIL_REGEX")
+ continue()
+ endif()
+ if("${var}" MATCHES "${_CheckCCompilerFlag_COMMON_PATTERNS}")
+ set(ERRORS_FOUND True)
+ endif()
+ endforeach()
+
+ if(result EQUAL 0 AND NOT ERRORS_FOUND)
set(${output} True PARENT_SCOPE)
else()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
More information about the llvm-commits
mailing list