File tree 2 files changed +21
-10
lines changed
rustc_codegen_ssa/src/back
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(
1216
1216
crate_type : CrateType ,
1217
1217
linker : & mut dyn Linker ,
1218
1218
) {
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
+
1219
1235
// On macOS and Windows using MSVC the runtimes are distributed as dylibs
1220
1236
// which should be linked to both executables and dynamic libraries.
1221
1237
// Everywhere else the runtimes are currently distributed as static
1222
1238
// 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
+ {
1233
1242
return ;
1234
1243
}
1235
1244
Original file line number Diff line number Diff line change @@ -1645,6 +1645,8 @@ options! {
1645
1645
"emit the bc module with thin LTO info (default: yes)" ) ,
1646
1646
export_executable_symbols: bool = ( false , parse_bool, [ TRACKED ] ,
1647
1647
"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" ) ,
1648
1650
extra_const_ub_checks: bool = ( false , parse_bool, [ TRACKED ] ,
1649
1651
"turns on more checks to detect const UB, which can be slow (default: no)" ) ,
1650
1652
#[ 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