-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add -Z external-clangrt
#121207
Add -Z external-clangrt
#121207
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1201,20 +1201,29 @@ fn add_sanitizer_libraries( | |
crate_type: CrateType, | ||
linker: &mut dyn Linker, | ||
) { | ||
if sess.target.is_like_android { | ||
// Sanitizer runtime libraries are provided dynamically on Android | ||
// targets. | ||
return; | ||
} | ||
|
||
if sess.opts.unstable_opts.external_clangrt { | ||
// Linking against in-tree sanitizer runtimes is disabled via | ||
// `-Z external-clangrt` | ||
return; | ||
} | ||
|
||
if matches!(crate_type, CrateType::Rlib | CrateType::Staticlib) { | ||
return; | ||
} | ||
|
||
// On macOS and Windows using MSVC the runtimes are distributed as dylibs | ||
// which should be linked to both executables and dynamic libraries. | ||
// Everywhere else the runtimes are currently distributed as static | ||
// libraries which should be linked to executables only. | ||
let needs_runtime = !sess.target.is_like_android | ||
&& match crate_type { | ||
CrateType::Executable => true, | ||
CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro => { | ||
sess.target.is_like_osx || sess.target.is_like_msvc | ||
} | ||
CrateType::Rlib | CrateType::Staticlib => false, | ||
}; | ||
|
||
if !needs_runtime { | ||
if matches!(crate_type, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro) | ||
&& !(sess.target.is_like_osx || sess.target.is_like_msvc) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, isn't this the wrong way around now? That is, if this is some kind of dylib, then we do need to link the runtime on osx- and msvc-like platforms. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. Fixed. |
||
return; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this code path can even ever be hit for those crate types since those don't involve a linking step. In any case, the comment about seems fit better for the next condition. Also, is there a reason why Windows is not mentioned anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rushed the rebase process and incorrectly resurrected the old version of the comments. Fixed in the new commit.