Skip to content
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

[SR-10152] [Driver] Missing --whole-archive in linker invocation #52554

yln opened this issue Mar 22, 2019 · 2 comments

[SR-10152] [Driver] Missing --whole-archive in linker invocation #52554

yln opened this issue Mar 22, 2019 · 2 comments


Copy link

@yln yln commented Mar 22, 2019

Previous ID SR-10152
Radar None
Original Reporter @yln
Type Bug
Status Resolved
Resolution Done



Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Driver
Assignee @yln
Priority Medium

md5: 71edd170c1983b68c68b76f6a4980b35

Issue Description:

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 [...]
<compile step>
<link step>:
"/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.

Copy link

@belkadan belkadan commented Mar 22, 2019

I like the idea of just asking Clang to figure out how to link for us on platforms where we use Clang as the linker.

Copy link
Contributor Author

@yln yln commented Mar 27, 2019

Resolved by #23508

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants