@@ -270,6 +270,29 @@ toolchains::Darwin::addArgsToLinkARCLite(ArgStringList &Arguments,
270
270
}
271
271
}
272
272
273
+ void
274
+ toolchains::Darwin::addSanitizerArgs (ArgStringList &Arguments,
275
+ const DynamicLinkJobAction &job,
276
+ const JobContext &context) const {
277
+ // Linking sanitizers will add rpaths, which might negatively interact when
278
+ // other rpaths are involved, so we should make sure we add the rpaths after
279
+ // all user-specified rpaths.
280
+ if (context.OI .SelectedSanitizers & SanitizerKind::Address)
281
+ addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " asan" , *this );
282
+
283
+ if (context.OI .SelectedSanitizers & SanitizerKind::Thread)
284
+ addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " tsan" , *this );
285
+
286
+ if (context.OI .SelectedSanitizers & SanitizerKind::Undefined)
287
+ addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " ubsan" , *this );
288
+
289
+ // Only link in libFuzzer for executables.
290
+ if (job.getKind () == LinkKind::Executable &&
291
+ (context.OI .SelectedSanitizers & SanitizerKind::Fuzzer))
292
+ addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " fuzzer" , *this ,
293
+ /* shared=*/ false );
294
+ }
295
+
273
296
void
274
297
toolchains::Darwin::addArgsToLinkStdlib (ArgStringList &Arguments,
275
298
const DynamicLinkJobAction &job,
@@ -556,23 +579,7 @@ toolchains::Darwin::constructInvocation(const DynamicLinkJobAction &job,
556
579
Arguments.push_back (" -application_extension" );
557
580
}
558
581
559
- // Linking sanitizers will add rpaths, which might negatively interact when
560
- // other rpaths are involved, so we should make sure we add the rpaths after
561
- // all user-specified rpaths.
562
- if (context.OI .SelectedSanitizers & SanitizerKind::Address)
563
- addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " asan" , *this );
564
-
565
- if (context.OI .SelectedSanitizers & SanitizerKind::Thread)
566
- addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " tsan" , *this );
567
-
568
- if (context.OI .SelectedSanitizers & SanitizerKind::Undefined)
569
- addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " ubsan" , *this );
570
-
571
- // Only link in libFuzzer for executables.
572
- if (job.getKind () == LinkKind::Executable &&
573
- (context.OI .SelectedSanitizers & SanitizerKind::Fuzzer))
574
- addLinkSanitizerLibArgsForDarwin (context.Args , Arguments, " fuzzer" , *this ,
575
- /* shared=*/ false );
582
+ addSanitizerArgs (Arguments, job, context);
576
583
577
584
if (context.Args .hasArg (options::OPT_embed_bitcode,
578
585
options::OPT_embed_bitcode_marker)) {
0 commit comments