Skip to content

[Driver] TSan runtime now has a link-time dependency on libdispatch #23645

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 1 commit into from
Apr 1, 2019
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
6 changes: 6 additions & 0 deletions lib/Driver/UnixToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
if (job.getKind() == LinkKind::Executable && context.OI.SelectedSanitizers) {
Arguments.push_back(context.Args.MakeArgString(
"-fsanitize=" + getSanitizerList(context.OI.SelectedSanitizers)));

// The TSan runtime depends on the blocks runtime and libdispatch.
if (context.OI.SelectedSanitizers & SanitizerKind::Thread) {
Arguments.push_back("-lBlocksRuntime");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slightly worrisome. -fblocks-runtime-optional controls where you have a blocks runtime library or not that you link against. (The GNU ObjC runtime also provides the blocks runtime implicitly). I wish that we could delegate to the clang driver for the blocks runtime linkage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] delegate to the clang driver for the blocks runtime linkage.

This is what I am trying to do here. I don't really understand what you mean. What should we do instead?

Arguments.push_back("-ldispatch");
}
}

if (context.Args.hasArg(options::OPT_profile_generate)) {
Expand Down
2 changes: 1 addition & 1 deletion test/Driver/sanitizers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
// TSAN_watchOS_SIM: unsupported option '-sanitize=thread' for target 'i386-apple-watchos2.0'
// TSAN_watchOS: unsupported option '-sanitize=thread' for target 'armv7k-apple-watchos2.0'
// FUZZER_NONEXISTENT: unsupported option '-sanitize=fuzzer' for target 'x86_64-apple-macosx10.9'
// TSAN_LINUX: -fsanitize=thread
// TSAN_LINUX: -fsanitize=thread -lBlocksRuntime -ldispatch
// TSAN_WINDOWS: unsupported option '-sanitize=thread' for target 'x86_64-unknown-windows-msvc'

// TSAN: -rpath @executable_path
Expand Down