Skip to content

Commit da45361

Browse files
authored
Merge pull request #23645 from apple/driver-tsan-linux-linker-flags
[Driver] TSan runtime now has a link-time dependency on libdispatch
2 parents 13e805e + 1cac0be commit da45361

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/Driver/UnixToolChains.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
278278
if (job.getKind() == LinkKind::Executable && context.OI.SelectedSanitizers) {
279279
Arguments.push_back(context.Args.MakeArgString(
280280
"-fsanitize=" + getSanitizerList(context.OI.SelectedSanitizers)));
281+
282+
// The TSan runtime depends on the blocks runtime and libdispatch.
283+
if (context.OI.SelectedSanitizers & SanitizerKind::Thread) {
284+
Arguments.push_back("-lBlocksRuntime");
285+
Arguments.push_back("-ldispatch");
286+
}
281287
}
282288

283289
if (context.Args.hasArg(options::OPT_profile_generate)) {

test/Driver/sanitizers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
// TSAN_watchOS_SIM: unsupported option '-sanitize=thread' for target 'i386-apple-watchos2.0'
8787
// TSAN_watchOS: unsupported option '-sanitize=thread' for target 'armv7k-apple-watchos2.0'
8888
// FUZZER_NONEXISTENT: unsupported option '-sanitize=fuzzer' for target 'x86_64-apple-macosx10.9'
89-
// TSAN_LINUX: -fsanitize=thread
89+
// TSAN_LINUX: -fsanitize=thread -lBlocksRuntime -ldispatch
9090
// TSAN_WINDOWS: unsupported option '-sanitize=thread' for target 'x86_64-unknown-windows-msvc'
9191

9292
// TSAN: -rpath @executable_path

0 commit comments

Comments
 (0)