Skip to content

Add tsan support #3911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,25 @@ skip-test-watchos

enable-asan

[preset: buildbot_incremental_tsan,tools=RDA,stdlib=RDA]
mixin-preset=buildbot_incremental_base_all_platforms

build-subdir=buildbot_incremental_tsan

# Build Release with debug info, so that we can symbolicate backtraces.
release-debuginfo
assertions
enable-tsan

dash-dash

skip-build-ios
skip-test-ios
skip-build-tvos
skip-test-tvos
skip-build-watchos
skip-test-watchos

[preset: buildbot_incremental_asan_ubsan,tools=RDA,stdlib=RDA]
mixin-preset=buildbot_incremental_base_all_platforms

Expand Down
10 changes: 8 additions & 2 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -1278,11 +1278,13 @@ details of the setups of other systems or automated environments.""")
help="build libdispatch",
action=arguments.action.optional_bool,
dest="build_libdispatch")
projects_group.add_argument("--playgroundlogger",
projects_group.add_argument(
"--playgroundlogger",
help="build playgroundlogger",
action="store_true",
dest="build_playgroundlogger")
projects_group.add_argument("--playgroundsupport",
projects_group.add_argument(
"--playgroundsupport",
help="build PlaygroundSupport",
action="store_true",
dest="build_playgroundsupport")
Expand Down Expand Up @@ -1847,6 +1849,10 @@ details of the setups of other systems or automated environments.""")
"--enable-ubsan",
help="enable Undefined Behavior Sanitizer",
action=arguments.action.optional_bool)
parser.add_argument(
"--enable-tsan",
help="enable Thread Sanitizer",
action=arguments.action.optional_bool)
parser.add_argument(
"--clang-compiler-version",
help="string that indicates a compiler version for Clang",
Expand Down
1 change: 0 additions & 1 deletion utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ KNOWN_SETTINGS=(
xctest-build-type "Debug" "the build variant for xctest"
llbuild-enable-assertions "1" "enable assertions in llbuild"
enable-asan "" "enable Address Sanitizer"
enable-ubsan "" "enable Undefined Behavior Sanitizer"
cmake "" "path to the cmake binary"
distcc "" "use distcc in pump mode"
distcc-pump "" "the path to distcc pump executable. This argument is required if distcc is set."
Expand Down
6 changes: 4 additions & 2 deletions utils/line-directive
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@ def run():
l = line.rstrip('\n')
m = error_pattern.match(l)
if m:
file, line_num = map_line(m.group('file'), int(m.group('line')))
file, line_num = map_line(m.group('file'),
int(m.group('line')))
line = '%s:%s:%s:%s\n' % (
file, line_num, int(m.group(3)), m.group(4))
else:
m = assertion_pattern.match(l)
if m:
file, line_num = map_line(m.group('file'), int(m.group('line')))
file, line_num = map_line(m.group('file'),
int(m.group('line')))
line = '%s%s%s%s%s\n' % (
m.group('head'), file, m.group('middle'), line_num,
m.group('tail'))
Expand Down
2 changes: 2 additions & 0 deletions utils/swift_build_support/swift_build_support/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def common_options(self):
sanitizers.append('Address')
if args.enable_ubsan:
sanitizers.append('Undefined')
if args.enable_tsan:
sanitizers.append('Thread')
if sanitizers:
define("LLVM_USE_SANITIZER", ";".join(sanitizers))

Expand Down
37 changes: 37 additions & 0 deletions utils/swift_build_support/tests/test_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def default_args(self):
host_cxx="/path/to/clang++",
enable_asan=False,
enable_ubsan=False,
enable_tsan=False,
export_compile_commands=False,
distcc=False,
cmake_generator="Ninja",
Expand Down Expand Up @@ -84,6 +85,17 @@ def test_common_options_ubsan(self):
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++"])

def test_common_options_tsan(self):
args = self.default_args()
args.enable_tsan = True
cmake = self.cmake(args)
self.assertEqual(
list(cmake.common_options()),
["-G", "Ninja",
"-DLLVM_USE_SANITIZER=Thread",
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++"])

def test_common_options_asan_ubsan(self):
args = self.default_args()
args.enable_asan = True
Expand All @@ -96,6 +108,31 @@ def test_common_options_asan_ubsan(self):
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++"])

def test_common_options_ubsan_tsan(self):
args = self.default_args()
args.enable_ubsan = True
args.enable_tsan = True
cmake = self.cmake(args)
self.assertEqual(
list(cmake.common_options()),
["-G", "Ninja",
"-DLLVM_USE_SANITIZER=Undefined;Thread",
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++"])

def test_common_options_asan_ubsan_tsan(self):
args = self.default_args()
args.enable_asan = True
args.enable_ubsan = True
args.enable_tsan = True
cmake = self.cmake(args)
self.assertEqual(
list(cmake.common_options()),
["-G", "Ninja",
"-DLLVM_USE_SANITIZER=Address;Undefined;Thread",
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++"])

def test_common_options_export_compile_commands(self):
args = self.default_args()
args.export_compile_commands = True
Expand Down