Add a %darwin_min_target_with_tls_support
lit substitution.
Summary: This substitution expands to the appropriate minimum deployment target flag where thread local storage (TLS) was first introduced on Darwin platforms. For all other platforms the substitution expands to an empty string. E.g. for macOS the substitution expands to `-mmacosx-version-min=10.12` This patch adds support for the substitution (and future substitutions) by doing a minor refactor and then uses the substitution in the relevant TSan tests. rdar://problem/59568956 Reviewers: yln, kubamracek, dvyukov, vitalybuka Subscribers: #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D74802
This commit is contained in:
parent
d1d5180e69
commit
562c6b8019
|
@ -257,6 +257,15 @@ if config.gwp_asan:
|
|||
|
||||
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',
|
||||
# rdar://problem/22207160
|
||||
'%darwin_min_target_with_full_runtime_arc_support': '10.11',
|
||||
'%darwin_min_target_with_tls_support': '10.12',
|
||||
}
|
||||
|
||||
if config.host_os == 'Darwin':
|
||||
def get_apple_platform_version_aligned_with(macos_version, apple_platform):
|
||||
"""
|
||||
|
@ -326,25 +335,29 @@ if config.host_os == 'Darwin':
|
|||
except:
|
||||
pass
|
||||
|
||||
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", min_os_aligned_with_osx_10_11_flag) )
|
||||
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
|
||||
else:
|
||||
config.substitutions.append( ("%macos_min_target_10_11", "") )
|
||||
config.substitutions.append( ("%darwin_min_target_with_full_runtime_arc_support", "") )
|
||||
for substitution in darwin_min_deployment_target_substitutions.keys():
|
||||
config.substitutions.append( (substitution, "") )
|
||||
|
||||
if config.android:
|
||||
env = os.environ.copy()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// RUN: %clang_tsan %s -o %t
|
||||
// RUN: %clang_tsan %s -DBUILD_SO -fPIC -o %t-so.so -shared
|
||||
// RUN: %clang_tsan %darwin_min_target_with_tls_support %s -o %t
|
||||
// RUN: %clang_tsan %darwin_min_target_with_tls_support %s -DBUILD_SO -fPIC -o \
|
||||
// RUN: %t-so.so -shared
|
||||
// RUN: %run %t 2>&1 | FileCheck %s
|
||||
// XFAIL: netbsd
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
|
||||
// RUN: %clangxx_tsan %darwin_min_target_with_tls_support -O1 %s -o %t && \
|
||||
// RUN: %deflake %run %t | FileCheck %s
|
||||
#include "test.h"
|
||||
|
||||
int Global;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
|
||||
// RUN: %clangxx_tsan %darwin_min_target_with_tls_support -O1 %s -o %t && \
|
||||
// RUN: %deflake %run %t | \
|
||||
// RUN: FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
|
||||
#include "test.h"
|
||||
|
||||
void *Thread(void *a) {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
|
||||
// RUN: %clangxx_tsan %darwin_min_target_with_tls_support -O1 %s -o %t && \
|
||||
// RUN: %deflake %run %t | \
|
||||
// RUN: FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
|
||||
#include "test.h"
|
||||
|
||||
void *Thread2(void *a) {
|
||||
|
|
Loading…
Reference in a new issue