@@ -262,6 +262,29 @@ toolchains::Darwin::addArgsToLinkARCLite(ArgStringList &Arguments,
262
262
}
263
263
}
264
264
265
+ void
266
+ toolchains::Darwin::addSanitizerArgs (ArgStringList &Arguments,
267
+ const LinkJobAction &job,
268
+ const JobContext &context) const {
269
+ // Linking sanitizers will add rpaths, which might negatively interact when
270
+ // other rpaths are involved, so we should make sure we add the rpaths after
271
+ // all user-specified rpaths.
272
+ if (context.OI .SelectedSanitizers & SanitizerKind::Address)
273
+ addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " asan" , *this );
274
+
275
+ if (context.OI .SelectedSanitizers & SanitizerKind::Thread)
276
+ addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " tsan" , *this );
277
+
278
+ if (context.OI .SelectedSanitizers & SanitizerKind::Undefined)
279
+ addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " ubsan" , *this );
280
+
281
+ // Only link in libFuzzer for executables.
282
+ if (job.getKind () == LinkKind::Executable &&
283
+ (context.OI .SelectedSanitizers & SanitizerKind::Fuzzer))
284
+ addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " fuzzer" , *this ,
285
+ /* shared=*/ false );
286
+ }
287
+
265
288
void
266
289
toolchains::Darwin::addArgsToLinkStdlib (ArgStringList &Arguments,
267
290
const JobContext &context) const {
@@ -497,23 +520,7 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,
497
520
Arguments.push_back (" -application_extension" );
498
521
}
499
522
500
- // Linking sanitizers will add rpaths, which might negatively interact when
501
- // other rpaths are involved, so we should make sure we add the rpaths after
502
- // all user-specified rpaths.
503
- if (context.OI .SelectedSanitizers & SanitizerKind::Address)
504
- addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " asan" , *this );
505
-
506
- if (context.OI .SelectedSanitizers & SanitizerKind::Thread)
507
- addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " tsan" , *this );
508
-
509
- if (context.OI .SelectedSanitizers & SanitizerKind::Undefined)
510
- addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " ubsan" , *this );
511
-
512
- // Only link in libFuzzer for executables.
513
- if (job.getKind () == LinkKind::Executable &&
514
- (context.OI .SelectedSanitizers & SanitizerKind::Fuzzer))
515
- addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " fuzzer" , *this ,
516
- /* shared=*/ false );
523
+ addSanitizerArgs (Arguments, job, context);
517
524
518
525
if (context.Args .hasArg (options::OPT_embed_bitcode,
519
526
options::OPT_embed_bitcode_marker)) {
0 commit comments