From: Daniel Sanders Date: Tue, 19 Feb 2019 19:45:03 +0000 (+0000) Subject: Fix builds for older macOS deployment targets after r354365 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=660bc13d97e2929e16e40ac2975841185130e594;p=llvm Fix builds for older macOS deployment targets after r354365 Surprisingly, check_symbol_exists is not sufficient. The macOS linker checks the called functions against a compatibility list for the given deployment target and check_symbol_exists doesn't trigger this check as it never calls the function. This fixes the GreenDragon bots where the deployment target is 10.9 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354374 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake index f60b457679e..694fe946b9b 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake @@ -917,25 +917,31 @@ get_compile_definitions() option(LLVM_FORCE_ENABLE_STATS "Enable statistics collection for builds that wouldn't normally enable it" OFF) -check_symbol_exists(os_signpost_interval_begin "os/signpost.h" _signposts_available) -if(_signposts_available) - set(LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS "WITH_ASSERTS" CACHE STRING - "Enable support for Xcode signposts. Can be WITH_ASSERTS, FORCE_ON, FORCE_OFF") - string(TOUPPER "${LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS}" - uppercase_LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS) - if( uppercase_LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS STREQUAL "WITH_ASSERTS" ) - if( LLVM_ENABLE_ASSERTIONS ) +check_symbol_exists(os_signpost_interval_begin "os/signpost.h" macos_signposts_available) +if(macos_signposts_available) + check_cxx_source_compiles( + "#include + int main() { os_signpost_interval_begin(nullptr, 0, \"\", \"\"); return 0; }" + macos_signposts_usable) + if(macos_signposts_usable) + set(LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS "WITH_ASSERTS" CACHE STRING + "Enable support for Xcode signposts. Can be WITH_ASSERTS, FORCE_ON, FORCE_OFF") + string(TOUPPER "${LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS}" + uppercase_LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS) + if( uppercase_LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS STREQUAL "WITH_ASSERTS" ) + if( LLVM_ENABLE_ASSERTIONS ) + set( LLVM_SUPPORT_XCODE_SIGNPOSTS 1 ) + endif() + elseif( uppercase_LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS STREQUAL "FORCE_ON" ) set( LLVM_SUPPORT_XCODE_SIGNPOSTS 1 ) + elseif( uppercase_LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS STREQUAL "FORCE_OFF" ) + # We don't need to do anything special to turn off signposts. + elseif( NOT DEFINED LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS ) + # Treat LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS like "FORCE_OFF" when it has not been + # defined. + else() + message(FATAL_ERROR "Unknown value for LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS:" + " \"${LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS}\"!") endif() - elseif( uppercase_LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS STREQUAL "FORCE_ON" ) - set( LLVM_SUPPORT_XCODE_SIGNPOSTS 1 ) - elseif( uppercase_LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS STREQUAL "FORCE_OFF" ) - # We don't need to do anything special to turn off signposts. - elseif( NOT DEFINED LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS ) - # Treat LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS like "FORCE_OFF" when it has not been - # defined. - else() - message(FATAL_ERROR "Unknown value for LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS:" - " \"${LLVM_ENABLE_SUPPORT_XCODE_SIGNPOSTS}\"!") endif() endif()