diff --git a/compiler-rt/test/asan/TestCases/initialization-bug.cpp b/compiler-rt/test/asan/TestCases/initialization-bug.cpp --- a/compiler-rt/test/asan/TestCases/initialization-bug.cpp +++ b/compiler-rt/test/asan/TestCases/initialization-bug.cpp @@ -1,6 +1,6 @@ // Test to make sure basic initialization order errors are caught. -// RUN: %clangxx_asan %macos_min_target_10_11 -O0 %s %p/Helpers/initialization-bug-extra2.cpp -o %t-INIT-ORDER-EXE +// RUN: %clangxx_asan %min_macos_deployment_target=10.11 -O0 %s %p/Helpers/initialization-bug-extra2.cpp -o %t-INIT-ORDER-EXE // RUN: %env_asan_opts=check_initialization_order=true not %run %t-INIT-ORDER-EXE 2>&1 | FileCheck %s // Do not test with optimization -- the error may be optimized away. diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py --- a/compiler-rt/test/lit.common.cfg.py +++ b/compiler-rt/test/lit.common.cfg.py @@ -264,52 +264,14 @@ lit.util.usePlatformSdkOnDarwin(config, lit_config) -# Maps a lit substitution name for the minimum target OS flag -# to the macOS version that first contained the relevant feature. -darwin_min_deployment_target_substitutions = { - '%macos_min_target_10_11': '10.11', - '%darwin_min_target_with_tls_support': '10.12', # TLS requires watchOS 3+ simulator -} +min_macos_deployment_target_substitutions = [ + (10, 11), + (10, 12), +] +# TLS requires watchOS 3+ +config.substitutions.append( ('%darwin_min_target_with_tls_support', '%min_macos_deployment_target=10.12') ) 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\d+)(\.(?P\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"], @@ -341,29 +303,44 @@ except: pass - def get_apple_min_deploy_target_flag_aligned_with_osx(version): - min_os_aligned_with_osx_v = get_apple_platform_version_aligned_with(version, config.apple_platform) - min_os_aligned_with_osx_v_flag = '' - if min_os_aligned_with_osx_v: - min_os_aligned_with_osx_v_flag = '{flag}={version}'.format( - flag=config.apple_platform_min_deployment_target_flag, - version=min_os_aligned_with_osx_v) - else: - lit_config.warning('Could not find a version of {} that corresponds with macOS {}'.format( - config.apple_platform, - version)) - return min_os_aligned_with_osx_v_flag - - for substitution, osx_version in darwin_min_deployment_target_substitutions.items(): - config.substitutions.append( (substitution, get_apple_min_deploy_target_flag_aligned_with_osx(osx_version)) ) - # 32-bit iOS simulator is deprecated and removed in latest Xcode. if config.apple_platform == "iossim": if config.target_arch == "i386": config.unsupported = True + + def get_macos_aligned_version(macos_vers): + platform = config.apple_platform + if platform == 'osx': + return macos_vers + + macos_major, macos_minor = macos_vers + assert macos_major >= 10 + + if macos_major == 10: # macOS 10.x + major = macos_minor + minor = 0 + else: # macOS 11+ + major = macos_major + 5 + minor = macos_minor + + assert major >= 11 + + if platform.startswith('ios') or platform.startswith('tvos'): + major -= 2 + elif platform.startswith('watch'): + major -= 9 + else: + lit_config.fatal("Unsupported apple platform '{}'".format(platform)) + + return (major, minor) + + for vers in min_macos_deployment_target_substitutions: + flag = config.apple_platform_min_deployment_target_flag + major, minor = get_macos_aligned_version(vers) + config.substitutions.append( ('%%min_macos_deployment_target=%s.%s' % vers, '{}={}.{}'.format(flag, major, minor)) ) else: - for substitution in darwin_min_deployment_target_substitutions.keys(): - config.substitutions.append( (substitution, "") ) + for vers in min_macos_deployment_target_substitutions: + config.substitutions.append( ('%%min_macos_deployment_target=%s.%s' % vers, '') ) if config.android: env = os.environ.copy()