From e7fe0d485d8b41d35410f3bec3683eba391a1917 Mon Sep 17 00:00:00 2001
Date: Mon, 17 May 2021 21:17:07 -0700
Subject: [PATCH 16/24] 10.10 and less: compiler-rt find macosx sdk

if there is no sdk that responds to "macosx" use the CMAKE passed in deployment target
---
 .../cmake/Modules/CompilerRTDarwinUtils.cmake      | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
index 456a8dcda59f..e9f6f577d626 100644
--- a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -69,15 +69,6 @@ function(find_darwin_sdk_version var sdk_name)
       ERROR_FILE /dev/null
     )
   endif()
-  if(NOT result_process EQUAL 0)
-    message(FATAL_ERROR
-      "Failed to determine SDK version for \"${sdk_name}\" SDK")
-  endif()
-  # Check reported version looks sane.
-  if (NOT "${var_internal}" MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+)?$")
-    message(FATAL_ERROR
-      "Reported SDK version \"${var_internal}\" does not look like a version")
-  endif()
   set(${var} ${var_internal} PARENT_SCOPE)
 endfunction()
 
@@ -128,6 +119,11 @@ function(darwin_test_archs os valid_archs)
     # binaries.
     if ("${os}" STREQUAL "osx")
       find_darwin_sdk_version(macosx_sdk_version "macosx")
+      # if there is no sdk that responds to "macosx" use the CMAKE passed in deployment target
+      if(NOT macosx_sdk_version)
+        message(WARNING "Could not determine MacOSX SDK Version, trying CMAKE_OSX_DEPLOYMENT_TARGET")
+        set(macosx_sdk_version CMAKE_OSX_DEPLOYMENT_TARGET)
+      endif()
       if ("${macosx_sdk_version}" VERSION_GREATER 10.15 OR "${macosx_sdk_version}" VERSION_EQUAL 10.15)
         message(STATUS "Disabling i386 slice for ${valid_archs}")
         list(REMOVE_ITEM archs "i386")
-- 
2.21.1 (Apple Git-122.3)

