Skip to content

Commit 4ad3de3

Browse files
authored
[NFC][Driver] Simplify linking of ubsan_standalone_cxx (#120938)
Refactoring before linking it only with CFI diag or VPTR. Almost NFC as `requiresMinimalRuntime() && needsCfiDiagRt()` changed, but it was unsupported before anyway.
1 parent c7a7773 commit 4ad3de3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,8 +1561,6 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
15611561
StaticRuntimes.push_back("ubsan_minimal");
15621562
} else {
15631563
StaticRuntimes.push_back("ubsan_standalone");
1564-
if (SanArgs.linkCXXRuntimes())
1565-
StaticRuntimes.push_back("ubsan_standalone_cxx");
15661564
}
15671565
}
15681566
if (SanArgs.needsSafeStackRt()) {
@@ -1572,11 +1570,13 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
15721570
if (!(SanArgs.needsSharedRt() && SanArgs.needsUbsanRt())) {
15731571
if (SanArgs.needsCfiRt())
15741572
StaticRuntimes.push_back("cfi");
1575-
if (SanArgs.needsCfiDiagRt()) {
1573+
if (SanArgs.needsCfiDiagRt())
15761574
StaticRuntimes.push_back("cfi_diag");
1577-
if (SanArgs.linkCXXRuntimes())
1578-
StaticRuntimes.push_back("ubsan_standalone_cxx");
1579-
}
1575+
}
1576+
if (SanArgs.linkCXXRuntimes() && !SanArgs.requiresMinimalRuntime() &&
1577+
((!SanArgs.needsSharedRt() && SanArgs.needsUbsanRt()) ||
1578+
SanArgs.needsCfiDiagRt())) {
1579+
StaticRuntimes.push_back("ubsan_standalone_cxx");
15801580
}
15811581
if (SanArgs.needsStatsRt()) {
15821582
NonWholeStaticRuntimes.push_back("stats");

0 commit comments

Comments
 (0)