Skip to content

Commit 22e1cfd

Browse files
authored
Merge pull request #3911 from gottesmm/add_tsan_support
2 parents 35a8c00 + 7611e12 commit 22e1cfd

File tree

6 files changed

+70
-5
lines changed

6 files changed

+70
-5
lines changed

utils/build-presets.ini

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,25 @@ skip-test-watchos
336336

337337
enable-asan
338338

339+
[preset: buildbot_incremental_tsan,tools=RDA,stdlib=RDA]
340+
mixin-preset=buildbot_incremental_base_all_platforms
341+
342+
build-subdir=buildbot_incremental_tsan
343+
344+
# Build Release with debug info, so that we can symbolicate backtraces.
345+
release-debuginfo
346+
assertions
347+
enable-tsan
348+
349+
dash-dash
350+
351+
skip-build-ios
352+
skip-test-ios
353+
skip-build-tvos
354+
skip-test-tvos
355+
skip-build-watchos
356+
skip-test-watchos
357+
339358
[preset: buildbot_incremental_asan_ubsan,tools=RDA,stdlib=RDA]
340359
mixin-preset=buildbot_incremental_base_all_platforms
341360

utils/build-script

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,11 +1278,13 @@ details of the setups of other systems or automated environments.""")
12781278
help="build libdispatch",
12791279
action=arguments.action.optional_bool,
12801280
dest="build_libdispatch")
1281-
projects_group.add_argument("--playgroundlogger",
1281+
projects_group.add_argument(
1282+
"--playgroundlogger",
12821283
help="build playgroundlogger",
12831284
action="store_true",
12841285
dest="build_playgroundlogger")
1285-
projects_group.add_argument("--playgroundsupport",
1286+
projects_group.add_argument(
1287+
"--playgroundsupport",
12861288
help="build PlaygroundSupport",
12871289
action="store_true",
12881290
dest="build_playgroundsupport")
@@ -1847,6 +1849,10 @@ details of the setups of other systems or automated environments.""")
18471849
"--enable-ubsan",
18481850
help="enable Undefined Behavior Sanitizer",
18491851
action=arguments.action.optional_bool)
1852+
parser.add_argument(
1853+
"--enable-tsan",
1854+
help="enable Thread Sanitizer",
1855+
action=arguments.action.optional_bool)
18501856
parser.add_argument(
18511857
"--clang-compiler-version",
18521858
help="string that indicates a compiler version for Clang",

utils/build-script-impl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ KNOWN_SETTINGS=(
7878
xctest-build-type "Debug" "the build variant for xctest"
7979
llbuild-enable-assertions "1" "enable assertions in llbuild"
8080
enable-asan "" "enable Address Sanitizer"
81-
enable-ubsan "" "enable Undefined Behavior Sanitizer"
8281
cmake "" "path to the cmake binary"
8382
distcc "" "use distcc in pump mode"
8483
distcc-pump "" "the path to distcc pump executable. This argument is required if distcc is set."

utils/line-directive

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,15 @@ def run():
9797
l = line.rstrip('\n')
9898
m = error_pattern.match(l)
9999
if m:
100-
file, line_num = map_line(m.group('file'), int(m.group('line')))
100+
file, line_num = map_line(m.group('file'),
101+
int(m.group('line')))
101102
line = '%s:%s:%s:%s\n' % (
102103
file, line_num, int(m.group(3)), m.group(4))
103104
else:
104105
m = assertion_pattern.match(l)
105106
if m:
106-
file, line_num = map_line(m.group('file'), int(m.group('line')))
107+
file, line_num = map_line(m.group('file'),
108+
int(m.group('line')))
107109
line = '%s%s%s%s%s\n' % (
108110
m.group('head'), file, m.group('middle'), line_num,
109111
m.group('tail'))

utils/swift_build_support/swift_build_support/cmake.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ def common_options(self):
9090
sanitizers.append('Address')
9191
if args.enable_ubsan:
9292
sanitizers.append('Undefined')
93+
if args.enable_tsan:
94+
sanitizers.append('Thread')
9395
if sanitizers:
9496
define("LLVM_USE_SANITIZER", ";".join(sanitizers))
9597

utils/swift_build_support/tests/test_cmake.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def default_args(self):
3232
host_cxx="/path/to/clang++",
3333
enable_asan=False,
3434
enable_ubsan=False,
35+
enable_tsan=False,
3536
export_compile_commands=False,
3637
distcc=False,
3738
cmake_generator="Ninja",
@@ -84,6 +85,17 @@ def test_common_options_ubsan(self):
8485
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
8586
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++"])
8687

88+
def test_common_options_tsan(self):
89+
args = self.default_args()
90+
args.enable_tsan = True
91+
cmake = self.cmake(args)
92+
self.assertEqual(
93+
list(cmake.common_options()),
94+
["-G", "Ninja",
95+
"-DLLVM_USE_SANITIZER=Thread",
96+
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
97+
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++"])
98+
8799
def test_common_options_asan_ubsan(self):
88100
args = self.default_args()
89101
args.enable_asan = True
@@ -96,6 +108,31 @@ def test_common_options_asan_ubsan(self):
96108
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
97109
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++"])
98110

111+
def test_common_options_ubsan_tsan(self):
112+
args = self.default_args()
113+
args.enable_ubsan = True
114+
args.enable_tsan = True
115+
cmake = self.cmake(args)
116+
self.assertEqual(
117+
list(cmake.common_options()),
118+
["-G", "Ninja",
119+
"-DLLVM_USE_SANITIZER=Undefined;Thread",
120+
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
121+
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++"])
122+
123+
def test_common_options_asan_ubsan_tsan(self):
124+
args = self.default_args()
125+
args.enable_asan = True
126+
args.enable_ubsan = True
127+
args.enable_tsan = True
128+
cmake = self.cmake(args)
129+
self.assertEqual(
130+
list(cmake.common_options()),
131+
["-G", "Ninja",
132+
"-DLLVM_USE_SANITIZER=Address;Undefined;Thread",
133+
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
134+
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++"])
135+
99136
def test_common_options_export_compile_commands(self):
100137
args = self.default_args()
101138
args.export_compile_commands = True

0 commit comments

Comments
 (0)