From 938ea992b1ab6171c54c9c1707fd12092c116e15 Mon Sep 17 00:00:00 2001 From: Chris Apple <14171107+cjappl@users.noreply.github.com> Date: Mon, 4 Dec 2023 15:40:24 -0800 Subject: [PATCH 1/4] Make SANITIZER_MIN_OSX_VERSION a cache variable --- compiler-rt/cmake/config-ix.cmake | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index 2dccd4954b253..358c1d4bc62f1 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -463,25 +463,32 @@ if(APPLE) # Note: In order to target x86_64h on OS X the minimum deployment target must # be 10.8 or higher. + set(SANITIZER_MIN_OSX_VERSION "" CACHE STRING + "Minimum OS X version to target (e.g. 10.10) for sanitizers.") + set(DEFAULT_SANITIZER_MIN_OSX_VERSION 10.10) set(DARWIN_osx_MIN_VER_FLAG "-mmacosx-version-min") - if(NOT SANITIZER_MIN_OSX_VERSION) + if(SANITIZER_MIN_OSX_VERSION STREQUAL "") string(REGEX MATCH "${DARWIN_osx_MIN_VER_FLAG}=([.0-9]+)" MACOSX_VERSION_MIN_FLAG "${CMAKE_CXX_FLAGS}") if(MACOSX_VERSION_MIN_FLAG) - set(SANITIZER_MIN_OSX_VERSION "${CMAKE_MATCH_1}") + set(MIN_OSX_VERSION "${CMAKE_MATCH_1}") elseif(CMAKE_OSX_DEPLOYMENT_TARGET) - set(SANITIZER_MIN_OSX_VERSION ${CMAKE_OSX_DEPLOYMENT_TARGET}) + set(MIN_OSX_VERSION ${CMAKE_OSX_DEPLOYMENT_TARGET}) else() - set(SANITIZER_MIN_OSX_VERSION ${DEFAULT_SANITIZER_MIN_OSX_VERSION}) + set(MIN_OSX_VERSION ${DEFAULT_SANITIZER_MIN_OSX_VERSION}) endif() - if(SANITIZER_MIN_OSX_VERSION VERSION_LESS "10.7") + + if(MIN_OSX_VERSION VERSION_LESS "10.7") message(FATAL_ERROR "macOS deployment target '${SANITIZER_MIN_OSX_VERSION}' is too old.") endif() - if(SANITIZER_MIN_OSX_VERSION VERSION_GREATER ${DEFAULT_SANITIZER_MIN_OSX_VERSION}) + if(MIN_OSX_VERSION VERSION_GREATER ${DEFAULT_SANITIZER_MIN_OSX_VERSION}) message(WARNING "macOS deployment target '${SANITIZER_MIN_OSX_VERSION}' is too new, setting to '${DEFAULT_SANITIZER_MIN_OSX_VERSION}' instead.") - set(SANITIZER_MIN_OSX_VERSION ${DEFAULT_SANITIZER_MIN_OSX_VERSION}) + set(MIN_OSX_VERSION ${DEFAULT_SANITIZER_MIN_OSX_VERSION}) endif() + + set(SANITIZER_MIN_OSX_VERSION "${MIN_OSX_VERSION}" CACHE STRING + "Minimum OS X version to target (e.g. 10.10) for sanitizers." FORCE) endif() # We're setting the flag manually for each target OS From 96afdbd6855c67ad15772cbada7b84b8bb7c580b Mon Sep 17 00:00:00 2001 From: Chris Apple <14171107+cjappl@users.noreply.github.com> Date: Mon, 18 Dec 2023 14:05:13 -0800 Subject: [PATCH 2/4] Setting OSX version after the block if it is not defined --- compiler-rt/cmake/config-ix.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index 358c1d4bc62f1..ffe4b9850d07e 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -468,7 +468,7 @@ if(APPLE) set(DEFAULT_SANITIZER_MIN_OSX_VERSION 10.10) set(DARWIN_osx_MIN_VER_FLAG "-mmacosx-version-min") - if(SANITIZER_MIN_OSX_VERSION STREQUAL "") + if(NOT SANITIZER_MIN_OSX_VERSION) string(REGEX MATCH "${DARWIN_osx_MIN_VER_FLAG}=([.0-9]+)" MACOSX_VERSION_MIN_FLAG "${CMAKE_CXX_FLAGS}") if(MACOSX_VERSION_MIN_FLAG) @@ -479,6 +479,8 @@ if(APPLE) set(MIN_OSX_VERSION ${DEFAULT_SANITIZER_MIN_OSX_VERSION}) endif() + # Note: In order to target x86_64h on OS X the minimum deployment target must + # be 10.8 or higher. if(MIN_OSX_VERSION VERSION_LESS "10.7") message(FATAL_ERROR "macOS deployment target '${SANITIZER_MIN_OSX_VERSION}' is too old.") endif() @@ -488,7 +490,7 @@ if(APPLE) endif() set(SANITIZER_MIN_OSX_VERSION "${MIN_OSX_VERSION}" CACHE STRING - "Minimum OS X version to target (e.g. 10.10) for sanitizers." FORCE) + "Minimum OS X version to target (e.g. 10.10) for sanitizers.") endif() # We're setting the flag manually for each target OS From 60eebf6c40fc75918ce6d7b15160b6014822becf Mon Sep 17 00:00:00 2001 From: Chris Apple <14171107+cjappl@users.noreply.github.com> Date: Mon, 18 Dec 2023 14:10:03 -0800 Subject: [PATCH 3/4] Get rid of rebase cruft --- compiler-rt/cmake/config-ix.cmake | 5 ----- 1 file changed, 5 deletions(-) diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index ffe4b9850d07e..fa97411dbe5af 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -461,11 +461,6 @@ if(APPLE) set(ORC_SUPPORTED_OS osx) endif() - # Note: In order to target x86_64h on OS X the minimum deployment target must - # be 10.8 or higher. - set(SANITIZER_MIN_OSX_VERSION "" CACHE STRING - "Minimum OS X version to target (e.g. 10.10) for sanitizers.") - set(DEFAULT_SANITIZER_MIN_OSX_VERSION 10.10) set(DARWIN_osx_MIN_VER_FLAG "-mmacosx-version-min") if(NOT SANITIZER_MIN_OSX_VERSION) From ad71692dd867f4ff5e6df7e607d40ffd5d12ebd0 Mon Sep 17 00:00:00 2001 From: Chris Apple <14171107+cjappl@users.noreply.github.com> Date: Tue, 19 Dec 2023 06:16:45 -0800 Subject: [PATCH 4/4] Review comments, moving outside of if --- compiler-rt/cmake/config-ix.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake index fa97411dbe5af..142ab60f7152d 100644 --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -484,10 +484,11 @@ if(APPLE) set(MIN_OSX_VERSION ${DEFAULT_SANITIZER_MIN_OSX_VERSION}) endif() - set(SANITIZER_MIN_OSX_VERSION "${MIN_OSX_VERSION}" CACHE STRING - "Minimum OS X version to target (e.g. 10.10) for sanitizers.") endif() + set(SANITIZER_MIN_OSX_VERSION "${MIN_OSX_VERSION}" CACHE STRING + "Minimum OS X version to target (e.g. 10.10) for sanitizers.") + # We're setting the flag manually for each target OS set(CMAKE_OSX_DEPLOYMENT_TARGET "")