On Linux, when compiling a simple C program with clang and a sanitizer enabled the driver ensures that all parts of the sanitizer runtime (*.a file) make it into the final executable via `--whole-archive <runtime.a> --no-whole-archive`.
clang simple.c -fsanitize=thread -v [...]
"/usr/bin/ld" -z relro
--whole-archive /home/yln/swift-DEVELOPMENT-SNAPSHOT-2019-03-17-a-ubuntu18.04/usr/lib/clang/7.0.0/lib/linux/libclang_rt.tsan-x86_64.a --no-whole-archive
When compiling a simple swift program (swiftc simple.swift -sanitize=thread), these linker directives are missing.
My understanding is that for the linking step: swift driver -> clang driver -> system linker.
The swift driver directly specifies the sanitizer runtime, but does not wrap it in `--whole-archive` (which is required for static archives).
If there is nothing preventing it, then a better option would probably be to pass through the `-sanitize=xxx` to the clang invocation (instead of directly specifying the sanitizer runtime) and let the clang driver figure out the right sanitizer runtime and linker flags to use.