[compiler-rt] 562c6b8 - Add a `%darwin_min_target_with_tls_support` lit substitution.
Dan Liew via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 19 15:42:22 PST 2020
Author: Dan Liew
Date: 2020-02-19T15:41:36-08:00
New Revision: 562c6b80192243b141d1ddd15d1827c860992147
URL: https://github.com/llvm/llvm-project/commit/562c6b80192243b141d1ddd15d1827c860992147
DIFF: https://github.com/llvm/llvm-project/commit/562c6b80192243b141d1ddd15d1827c860992147.diff
LOG: 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
Added:
Modified:
compiler-rt/test/lit.common.cfg.py
compiler-rt/test/tsan/dtls.c
compiler-rt/test/tsan/mutexset7.cpp
compiler-rt/test/tsan/tls_race.cpp
compiler-rt/test/tsan/tls_race2.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py
index 6c4a6f526551..3b1ea53fb8d9 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -257,6 +257,15 @@
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 @@ def get_apple_platform_version_aligned_with(macos_version, apple_platform):
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()
diff --git a/compiler-rt/test/tsan/dtls.c b/compiler-rt/test/tsan/dtls.c
index b00ca7691354..57c9da83a374 100644
--- a/compiler-rt/test/tsan/dtls.c
+++ b/compiler-rt/test/tsan/dtls.c
@@ -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
diff --git a/compiler-rt/test/tsan/mutexset7.cpp b/compiler-rt/test/tsan/mutexset7.cpp
index d3a221d1b421..d3729659717e 100644
--- a/compiler-rt/test/tsan/mutexset7.cpp
+++ b/compiler-rt/test/tsan/mutexset7.cpp
@@ -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;
diff --git a/compiler-rt/test/tsan/tls_race.cpp b/compiler-rt/test/tsan/tls_race.cpp
index dd37ff01d975..5f5b6aae4f58 100644
--- a/compiler-rt/test/tsan/tls_race.cpp
+++ b/compiler-rt/test/tsan/tls_race.cpp
@@ -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) {
diff --git a/compiler-rt/test/tsan/tls_race2.cpp b/compiler-rt/test/tsan/tls_race2.cpp
index 5968e66d5b18..0e008313518a 100644
--- a/compiler-rt/test/tsan/tls_race2.cpp
+++ b/compiler-rt/test/tsan/tls_race2.cpp
@@ -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) {
More information about the llvm-commits
mailing list