[compiler-rt] f414136 - [compiler-rt] Make various Apple lit substitutions work correctly for other Apple platforms.
Dan Liew via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 14 13:55:50 PST 2020
Author: Dan Liew
Date: 2020-02-14T13:53:54-08:00
New Revision: f4141367d00dc8524626d682c8ad56a11df5c850
URL: https://github.com/llvm/llvm-project/commit/f4141367d00dc8524626d682c8ad56a11df5c850
DIFF: https://github.com/llvm/llvm-project/commit/f4141367d00dc8524626d682c8ad56a11df5c850.diff
LOG: [compiler-rt] Make various Apple lit substitutions work correctly for other Apple platforms.
This change makes the following lit substitutions expand to the correct
thing for macOS, iOS, tvOS, and watchOS.
%darwin_min_target_with_full_runtime_arc_support
%macos_min_target_10_11
rdar://problem/59463146
Added:
Modified:
compiler-rt/test/lit.common.cfg.py
Removed:
################################################################################
diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py
index bf2190a93dad..6c4a6f526551 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -258,6 +258,44 @@
lit.util.usePlatformSdkOnDarwin(config, lit_config)
if config.host_os == 'Darwin':
+ def get_apple_platform_version_aligned_with(macos_version, apple_platform):
+ """
+ Given a macOS version (`macos_version`) returns the corresponding version for
+ the specified Apple platform if it exists.
+
+ `macos_version` - The macOS version as a string.
+ `apple_platform` - The Apple platform name as a string.
+
+ Returns the corresponding version as a string if it exists, otherwise
+ `None` is returned.
+ """
+ m = re.match(r'^10\.(?P<min>\d+)(\.(?P<patch>\d+))?$', macos_version)
+ if not m:
+ raise Exception('Could not parse macOS version: "{}"'.format(macos_version))
+ ver_min = int(m.group('min'))
+ ver_patch = m.group('patch')
+ if ver_patch:
+ ver_patch = int(ver_patch)
+ else:
+ ver_patch = 0
+ result_str = ''
+ if apple_platform == 'osx':
+ # Drop patch for now.
+ result_str = '10.{}'.format(ver_min)
+ elif apple_platform.startswith('ios') or apple_platform.startswith('tvos'):
+ result_maj = ver_min - 2
+ if result_maj < 1:
+ return None
+ result_str = '{}.{}'.format(result_maj, ver_patch)
+ elif apple_platform.startswith('watch'):
+ result_maj = ver_min - 9
+ if result_maj < 1:
+ return None
+ result_str = '{}.{}'.format(result_maj, ver_patch)
+ else:
+ raise Exception('Unsuported apple platform "{}"'.format(apple_platform))
+ return result_str
+
osx_version = (10, 0, 0)
try:
osx_version = subprocess.check_output(["sw_vers", "-productVersion"])
@@ -288,12 +326,17 @@
except:
pass
- config.substitutions.append( ("%macos_min_target_10_11", "-mmacosx-version-min=10.11") )
-
- isIOS = config.apple_platform != "osx"
+ min_os_aligned_with_osx_10_11 = get_apple_platform_version_aligned_with('10.11', config.apple_platform)
+ min_os_aligned_with_osx_10_11_flag = ''
+ if min_os_aligned_with_osx_10_11:
+ min_os_aligned_with_osx_10_11_flag = '{flag}={version}'.format(
+ flag=config.apple_platform_min_deployment_target_flag,
+ version=min_os_aligned_with_osx_10_11)
+ else:
+ lit_config.warning('Could not find a version of {} that corresponds with macOS 10.11'.format(config.apple_platform))
+ config.substitutions.append( ("%macos_min_target_10_11", min_os_aligned_with_osx_10_11_flag) )
# rdar://problem/22207160
- config.substitutions.append( ("%darwin_min_target_with_full_runtime_arc_support",
- "-miphoneos-version-min=9.0" if isIOS else "-mmacosx-version-min=10.11") )
+ config.substitutions.append( ("%darwin_min_target_with_full_runtime_arc_support", min_os_aligned_with_osx_10_11_flag) )
# 32-bit iOS simulator is deprecated and removed in latest Xcode.
if config.apple_platform == "iossim":
More information about the llvm-commits
mailing list