@@ -1317,28 +1317,28 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
1317
1317
const SanitizerArgs &SanArgs = TC.getSanitizerArgs (Args);
1318
1318
// Collect shared runtimes.
1319
1319
if (SanArgs.needsSharedRt ()) {
1320
- if (SanArgs.needsAsanRt () && SanArgs. linkRuntimes () ) {
1320
+ if (SanArgs.needsAsanRt ()) {
1321
1321
SharedRuntimes.push_back (" asan" );
1322
1322
if (!Args.hasArg (options::OPT_shared) && !TC.getTriple ().isAndroid ())
1323
1323
HelperStaticRuntimes.push_back (" asan-preinit" );
1324
1324
}
1325
- if (SanArgs.needsMemProfRt () && SanArgs. linkRuntimes () ) {
1325
+ if (SanArgs.needsMemProfRt ()) {
1326
1326
SharedRuntimes.push_back (" memprof" );
1327
1327
if (!Args.hasArg (options::OPT_shared) && !TC.getTriple ().isAndroid ())
1328
1328
HelperStaticRuntimes.push_back (" memprof-preinit" );
1329
1329
}
1330
- if (SanArgs.needsUbsanRt () && SanArgs. linkRuntimes () ) {
1330
+ if (SanArgs.needsUbsanRt ()) {
1331
1331
if (SanArgs.requiresMinimalRuntime ())
1332
1332
SharedRuntimes.push_back (" ubsan_minimal" );
1333
1333
else
1334
1334
SharedRuntimes.push_back (" ubsan_standalone" );
1335
1335
}
1336
- if (SanArgs.needsScudoRt () && SanArgs. linkRuntimes () ) {
1336
+ if (SanArgs.needsScudoRt ()) {
1337
1337
SharedRuntimes.push_back (" scudo_standalone" );
1338
1338
}
1339
- if (SanArgs.needsTsanRt () && SanArgs. linkRuntimes () )
1339
+ if (SanArgs.needsTsanRt ())
1340
1340
SharedRuntimes.push_back (" tsan" );
1341
- if (SanArgs.needsHwasanRt () && SanArgs. linkRuntimes () ) {
1341
+ if (SanArgs.needsHwasanRt ()) {
1342
1342
if (SanArgs.needsHwasanAliasesRt ())
1343
1343
SharedRuntimes.push_back (" hwasan_aliases" );
1344
1344
else
@@ -1349,7 +1349,7 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
1349
1349
}
1350
1350
1351
1351
// The stats_client library is also statically linked into DSOs.
1352
- if (SanArgs.needsStatsRt () && SanArgs. linkRuntimes () )
1352
+ if (SanArgs.needsStatsRt ())
1353
1353
StaticRuntimes.push_back (" stats_client" );
1354
1354
1355
1355
// Always link the static runtime regardless of DSO or executable.
@@ -1365,20 +1365,19 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
1365
1365
// Each static runtime that has a DSO counterpart above is excluded below,
1366
1366
// but runtimes that exist only as static are not affected by needsSharedRt.
1367
1367
1368
- if (!SanArgs.needsSharedRt () && SanArgs.needsAsanRt () && SanArgs. linkRuntimes () ) {
1368
+ if (!SanArgs.needsSharedRt () && SanArgs.needsAsanRt ()) {
1369
1369
StaticRuntimes.push_back (" asan" );
1370
1370
if (SanArgs.linkCXXRuntimes ())
1371
1371
StaticRuntimes.push_back (" asan_cxx" );
1372
1372
}
1373
1373
1374
- if (!SanArgs.needsSharedRt () && SanArgs.needsMemProfRt () &&
1375
- SanArgs.linkRuntimes ()) {
1374
+ if (!SanArgs.needsSharedRt () && SanArgs.needsMemProfRt ()) {
1376
1375
StaticRuntimes.push_back (" memprof" );
1377
1376
if (SanArgs.linkCXXRuntimes ())
1378
1377
StaticRuntimes.push_back (" memprof_cxx" );
1379
1378
}
1380
1379
1381
- if (!SanArgs.needsSharedRt () && SanArgs.needsHwasanRt () && SanArgs. linkRuntimes () ) {
1380
+ if (!SanArgs.needsSharedRt () && SanArgs.needsHwasanRt ()) {
1382
1381
if (SanArgs.needsHwasanAliasesRt ()) {
1383
1382
StaticRuntimes.push_back (" hwasan_aliases" );
1384
1383
if (SanArgs.linkCXXRuntimes ())
@@ -1389,22 +1388,21 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
1389
1388
StaticRuntimes.push_back (" hwasan_cxx" );
1390
1389
}
1391
1390
}
1392
- if (SanArgs.needsDfsanRt () && SanArgs. linkRuntimes () )
1391
+ if (SanArgs.needsDfsanRt ())
1393
1392
StaticRuntimes.push_back (" dfsan" );
1394
- if (SanArgs.needsLsanRt () && SanArgs. linkRuntimes () )
1393
+ if (SanArgs.needsLsanRt ())
1395
1394
StaticRuntimes.push_back (" lsan" );
1396
- if (SanArgs.needsMsanRt () && SanArgs. linkRuntimes () ) {
1395
+ if (SanArgs.needsMsanRt ()) {
1397
1396
StaticRuntimes.push_back (" msan" );
1398
1397
if (SanArgs.linkCXXRuntimes ())
1399
1398
StaticRuntimes.push_back (" msan_cxx" );
1400
1399
}
1401
- if (!SanArgs.needsSharedRt () && SanArgs.needsTsanRt () &&
1402
- SanArgs.linkRuntimes ()) {
1400
+ if (!SanArgs.needsSharedRt () && SanArgs.needsTsanRt ()) {
1403
1401
StaticRuntimes.push_back (" tsan" );
1404
1402
if (SanArgs.linkCXXRuntimes ())
1405
1403
StaticRuntimes.push_back (" tsan_cxx" );
1406
1404
}
1407
- if (!SanArgs.needsSharedRt () && SanArgs.needsUbsanRt () && SanArgs. linkRuntimes () ) {
1405
+ if (!SanArgs.needsSharedRt () && SanArgs.needsUbsanRt ()) {
1408
1406
if (SanArgs.requiresMinimalRuntime ()) {
1409
1407
StaticRuntimes.push_back (" ubsan_minimal" );
1410
1408
} else {
@@ -1413,24 +1411,24 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
1413
1411
StaticRuntimes.push_back (" ubsan_standalone_cxx" );
1414
1412
}
1415
1413
}
1416
- if (SanArgs.needsSafeStackRt () && SanArgs. linkRuntimes () ) {
1414
+ if (SanArgs.needsSafeStackRt ()) {
1417
1415
NonWholeStaticRuntimes.push_back (" safestack" );
1418
1416
RequiredSymbols.push_back (" __safestack_init" );
1419
1417
}
1420
- if (!(SanArgs.needsSharedRt () && SanArgs.needsUbsanRt () && SanArgs. linkRuntimes () )) {
1421
- if (SanArgs.needsCfiRt () && SanArgs. linkRuntimes () )
1418
+ if (!(SanArgs.needsSharedRt () && SanArgs.needsUbsanRt ())) {
1419
+ if (SanArgs.needsCfiRt ())
1422
1420
StaticRuntimes.push_back (" cfi" );
1423
- if (SanArgs.needsCfiDiagRt () && SanArgs. linkRuntimes () ) {
1421
+ if (SanArgs.needsCfiDiagRt ()) {
1424
1422
StaticRuntimes.push_back (" cfi_diag" );
1425
1423
if (SanArgs.linkCXXRuntimes ())
1426
1424
StaticRuntimes.push_back (" ubsan_standalone_cxx" );
1427
1425
}
1428
1426
}
1429
- if (SanArgs.needsStatsRt () && SanArgs. linkRuntimes () ) {
1427
+ if (SanArgs.needsStatsRt ()) {
1430
1428
NonWholeStaticRuntimes.push_back (" stats" );
1431
1429
RequiredSymbols.push_back (" __sanitizer_stats_register" );
1432
1430
}
1433
- if (!SanArgs.needsSharedRt () && SanArgs.needsScudoRt () && SanArgs. linkRuntimes () ) {
1431
+ if (!SanArgs.needsSharedRt () && SanArgs.needsScudoRt ()) {
1434
1432
StaticRuntimes.push_back (" scudo_standalone" );
1435
1433
if (SanArgs.linkCXXRuntimes ())
1436
1434
StaticRuntimes.push_back (" scudo_standalone_cxx" );
@@ -1441,13 +1439,15 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
1441
1439
// C runtime, etc). Returns true if sanitizer system deps need to be linked in.
1442
1440
bool tools::addSanitizerRuntimes (const ToolChain &TC, const ArgList &Args,
1443
1441
ArgStringList &CmdArgs) {
1442
+ const SanitizerArgs &SanArgs = TC.getSanitizerArgs (Args);
1444
1443
SmallVector<StringRef, 4 > SharedRuntimes, StaticRuntimes,
1445
1444
NonWholeStaticRuntimes, HelperStaticRuntimes, RequiredSymbols;
1446
- collectSanitizerRuntimes (TC, Args, SharedRuntimes, StaticRuntimes,
1447
- NonWholeStaticRuntimes, HelperStaticRuntimes,
1448
- RequiredSymbols);
1445
+ if (SanArgs.linkRuntimes ()) {
1446
+ collectSanitizerRuntimes (TC, Args, SharedRuntimes, StaticRuntimes,
1447
+ NonWholeStaticRuntimes, HelperStaticRuntimes,
1448
+ RequiredSymbols);
1449
+ }
1449
1450
1450
- const SanitizerArgs &SanArgs = TC.getSanitizerArgs (Args);
1451
1451
// Inject libfuzzer dependencies.
1452
1452
if (SanArgs.needsFuzzer () && SanArgs.linkRuntimes () &&
1453
1453
!Args.hasArg (options::OPT_shared)) {
0 commit comments