[compiler-rt] Make SANITIZER_MIN_OSX_VERSION a cache variable (PR #74394)
Chris Apple via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 18 14:05:46 PST 2023
https://github.com/cjappl updated https://github.com/llvm/llvm-project/pull/74394
>From 82b8b5b6d81b04d3071e771ea6e6c14c3706684c Mon Sep 17 00:00:00 2001
From: Chris Apple <14171107+cjappl at users.noreply.github.com>
Date: Mon, 4 Dec 2023 15:40:24 -0800
Subject: [PATCH 1/2] 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 a8e078f1ebc988..cab8178969aa9e 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -457,25 +457,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 8965bac025017875ab2fc0694cad8ebbbfeddd5a Mon Sep 17 00:00:00 2001
From: Chris Apple <14171107+cjappl at users.noreply.github.com>
Date: Mon, 18 Dec 2023 14:05:13 -0800
Subject: [PATCH 2/2] Setting OSX version after the block if it is not defined
---
compiler-rt/cmake/config-ix.cmake | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index cab8178969aa9e..c176aa207cd25e 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -455,14 +455,9 @@ if(APPLE)
set(LSAN_SUPPORTED_OS osx)
set(STATS_SUPPORTED_OS osx)
- # 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(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)
@@ -473,6 +468,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()
@@ -482,7 +479,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
More information about the llvm-commits
mailing list