File tree Expand file tree Collapse file tree 2 files changed +21
-10
lines changed
rustc_codegen_ssa/src/back Expand file tree Collapse file tree 2 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -1216,20 +1216,29 @@ fn add_sanitizer_libraries(
12161216 crate_type : CrateType ,
12171217 linker : & mut dyn Linker ,
12181218) {
1219+ if sess. target . is_like_android {
1220+ // Sanitizer runtime libraries are provided dynamically on Android
1221+ // targets.
1222+ return ;
1223+ }
1224+
1225+ if sess. opts . unstable_opts . external_clangrt {
1226+ // Linking against in-tree sanitizer runtimes is disabled via
1227+ // `-Z external-clangrt`
1228+ return ;
1229+ }
1230+
1231+ if matches ! ( crate_type, CrateType :: Rlib | CrateType :: Staticlib ) {
1232+ return ;
1233+ }
1234+
12191235 // On macOS and Windows using MSVC the runtimes are distributed as dylibs
12201236 // which should be linked to both executables and dynamic libraries.
12211237 // Everywhere else the runtimes are currently distributed as static
12221238 // libraries which should be linked to executables only.
1223- let needs_runtime = !sess. target . is_like_android
1224- && match crate_type {
1225- CrateType :: Executable => true ,
1226- CrateType :: Dylib | CrateType :: Cdylib | CrateType :: ProcMacro => {
1227- sess. target . is_like_osx || sess. target . is_like_msvc
1228- }
1229- CrateType :: Rlib | CrateType :: Staticlib => false ,
1230- } ;
1231-
1232- if !needs_runtime {
1239+ if matches ! ( crate_type, CrateType :: Dylib | CrateType :: Cdylib | CrateType :: ProcMacro )
1240+ && !( sess. target . is_like_osx || sess. target . is_like_msvc )
1241+ {
12331242 return ;
12341243 }
12351244
Original file line number Diff line number Diff line change @@ -1645,6 +1645,8 @@ options! {
16451645 "emit the bc module with thin LTO info (default: yes)" ) ,
16461646 export_executable_symbols: bool = ( false , parse_bool, [ TRACKED ] ,
16471647 "export symbols from executables, as if they were dynamic libraries" ) ,
1648+ external_clangrt: bool = ( false , parse_bool, [ UNTRACKED ] ,
1649+ "rely on user specified linker commands to find clangrt" ) ,
16481650 extra_const_ub_checks: bool = ( false , parse_bool, [ TRACKED ] ,
16491651 "turns on more checks to detect const UB, which can be slow (default: no)" ) ,
16501652 #[ rustc_lint_opt_deny_field_access( "use `Session::fewer_names` instead of this field" ) ]
You can’t perform that action at this time.
0 commit comments