Rollup merge of #121207 - chriswailes:z-external-clangrt, r=michaelwoerister
Add `-Z external-clangrt` This adds the unstable `-Z external-clangrt` flag that will prevent rustc from emitting linker paths for the in-tree LLVM sanitizer runtime library.
This commit is contained in:
commit
2b8fc6fd54
@ -1216,20 +1216,29 @@ fn add_sanitizer_libraries(
|
|||||||
crate_type: CrateType,
|
crate_type: CrateType,
|
||||||
linker: &mut dyn Linker,
|
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
|
// On macOS and Windows using MSVC the runtimes are distributed as dylibs
|
||||||
// which should be linked to both executables and dynamic libraries.
|
// which should be linked to both executables and dynamic libraries.
|
||||||
// Everywhere else the runtimes are currently distributed as static
|
// Everywhere else the runtimes are currently distributed as static
|
||||||
// libraries which should be linked to executables only.
|
// libraries which should be linked to executables only.
|
||||||
let needs_runtime = !sess.target.is_like_android
|
if matches!(crate_type, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro)
|
||||||
&& match crate_type {
|
&& !(sess.target.is_like_osx || sess.target.is_like_msvc)
|
||||||
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 {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1645,6 +1645,8 @@ options! {
|
|||||||
"emit the bc module with thin LTO info (default: yes)"),
|
"emit the bc module with thin LTO info (default: yes)"),
|
||||||
export_executable_symbols: bool = (false, parse_bool, [TRACKED],
|
export_executable_symbols: bool = (false, parse_bool, [TRACKED],
|
||||||
"export symbols from executables, as if they were dynamic libraries"),
|
"export symbols from executables, as if they were dynamic libraries"),
|
||||||
|
external_clangrt: bool = (false, parse_bool, [UNTRACKED],
|
||||||
|
"rely on user specified linker commands to find clangrt"),
|
||||||
extra_const_ub_checks: bool = (false, parse_bool, [TRACKED],
|
extra_const_ub_checks: bool = (false, parse_bool, [TRACKED],
|
||||||
"turns on more checks to detect const UB, which can be slow (default: no)"),
|
"turns on more checks to detect const UB, which can be slow (default: no)"),
|
||||||
#[rustc_lint_opt_deny_field_access("use `Session::fewer_names` instead of this field")]
|
#[rustc_lint_opt_deny_field_access("use `Session::fewer_names` instead of this field")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user