From c0fc219bd52d3dc0fde3c6181b87b7b9c978f3a1 Mon Sep 17 00:00:00 2001 From: Juergen Ributzka Date: Tue, 29 Aug 2017 00:34:56 +0000 Subject: [PATCH] Re-apply "Fix cmake check for futimens when deploying to earlier macOS releases." This fixes an issue with the use of LLVM_PARALLEL_LINK_JOBS. Original commit message: macOS 10.13 added a new API (futimens). This API is only available on macOS 10.13 and later, but the cmake check we have in place only tests if the symbol is present and ignores the availability attribute. Luckily we have new warning for this and by making this warning an error the cmake check will return the correct result. See also rdar://problem/33992750. Differential Revision: https://reviews.llvm.org/D37027 llvm-svn: 311965 --- llvm/cmake/config-ix.cmake | 9 +++++++++ llvm/cmake/modules/HandleLLVMOptions.cmake | 1 + 2 files changed, 10 insertions(+) diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake index f777b9c1c144..a1a16b99eb1a 100644 --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -8,6 +8,7 @@ include(CheckIncludeFileCXX) include(CheckLibraryExists) include(CheckSymbolExists) include(CheckFunctionExists) +include(CheckCCompilerFlag) include(CheckCXXSourceCompiles) include(TestBigEndian) @@ -179,6 +180,14 @@ check_symbol_exists(arc4random "stdlib.h" HAVE_DECL_ARC4RANDOM) find_package(Backtrace) set(HAVE_BACKTRACE ${Backtrace_FOUND}) set(BACKTRACE_HEADER ${Backtrace_HEADER}) + +# Prevent check_symbol_exists from using API that is not supported for a given +# deployment target. +check_c_compiler_flag("-Werror=unguarded-availability-new" "C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW") +if(C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unguarded-availability-new") +endif() + check_symbol_exists(_Unwind_Backtrace "unwind.h" HAVE__UNWIND_BACKTRACE) check_symbol_exists(getpagesize unistd.h HAVE_GETPAGESIZE) check_symbol_exists(sysconf unistd.h HAVE_SYSCONF) diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 04596a6ff63f..a2ab12838083 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -383,6 +383,7 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE ) append_if(LLVM_ENABLE_WERROR "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) append_if(LLVM_ENABLE_WERROR "-Wno-error" CMAKE_REQUIRED_FLAGS) add_flag_if_supported("-Werror=date-time" WERROR_DATE_TIME) + add_flag_if_supported("-Werror=unguarded-availability-new" WERROR_UNGUARDED_AVAILABILITY_NEW) if (LLVM_ENABLE_CXX1Y) check_cxx_compiler_flag("-std=c++1y" CXX_SUPPORTS_CXX1Y) append_if(CXX_SUPPORTS_CXX1Y "-std=c++1y" CMAKE_CXX_FLAGS)