-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[NFC][Driver][CFI] Rename to clarify purpose of CFI runtime #135885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vitalybuka
merged 6 commits into
main
from
users/vitalybuka/spr/nfcdrivercfi-rename-to-clarify-purpose-of-cfi-runtime
Apr 16, 2025
Merged
[NFC][Driver][CFI] Rename to clarify purpose of CFI runtime #135885
vitalybuka
merged 6 commits into
main
from
users/vitalybuka/spr/nfcdrivercfi-rename-to-clarify-purpose-of-cfi-runtime
Apr 16, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4
Member
|
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang Author: Vitaly Buka (vitalybuka) ChangesCFI runtime (diagnostics, or not) is only needed Full diff: https://github.com/llvm/llvm-project/pull/135885.diff 3 Files Affected:
diff --git a/clang/include/clang/Driver/SanitizerArgs.h b/clang/include/clang/Driver/SanitizerArgs.h
index 6a866ded0e75c..528e3b400f3dc 100644
--- a/clang/include/clang/Driver/SanitizerArgs.h
+++ b/clang/include/clang/Driver/SanitizerArgs.h
@@ -105,8 +105,8 @@ class SanitizerArgs {
bool requiresMinimalRuntime() const { return MinimalRuntime; }
bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); }
bool needsSafeStackRt() const { return SafeStackRuntime; }
- bool needsCfiRt() const;
- bool needsCfiDiagRt() const;
+ bool needsCfiCrossDsoRt() const;
+ bool needsCfiCrossDsoDiagRt() const;
bool needsStatsRt() const { return Stats; }
bool needsScudoRt() const { return Sanitizers.has(SanitizerKind::Scudo); }
bool needsNsanRt() const {
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 1db9da1b60939..ee151d5c68b85 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -354,8 +354,8 @@ bool SanitizerArgs::needsFuzzerInterceptors() const {
bool SanitizerArgs::needsUbsanRt() const {
// All of these include ubsan.
if (needsAsanRt() || needsMsanRt() || needsNsanRt() || needsHwasanRt() ||
- needsTsanRt() || needsDfsanRt() || needsLsanRt() || needsCfiDiagRt() ||
- (needsScudoRt() && !requiresMinimalRuntime()))
+ needsTsanRt() || needsDfsanRt() || needsLsanRt() ||
+ needsCfiCrossDsoDiagRt() || (needsScudoRt() && !requiresMinimalRuntime()))
return false;
return (Sanitizers.Mask & NeedsUbsanRt & ~TrapSanitizers.Mask) ||
@@ -370,11 +370,13 @@ bool SanitizerArgs::needsUbsanCXXRt() const {
~TrapSanitizers.Mask);
}
-bool SanitizerArgs::needsCfiRt() const {
- return !needsCfiDiagRt() && CfiCrossDso && !ImplicitCfiRuntime;
+bool SanitizerArgs::needsCfiCrossDsoRt() const {
+ // Diag runtime includes cross dso runtime.
+ return !needsCfiCrossDsoDiagRt() && CfiCrossDso && !ImplicitCfiRuntime;
}
-bool SanitizerArgs::needsCfiDiagRt() const {
+bool SanitizerArgs::needsCfiCrossDsoDiagRt() const {
+ // UBSsan handles CFI diagnostics without cross-DSO suppport.
return (Sanitizers.Mask & SanitizerKind::CFI & ~TrapSanitizers.Mask) &&
CfiCrossDso && !ImplicitCfiRuntime;
}
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index ddeadff8f6dfb..7aab849abe0c1 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1550,14 +1550,14 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
RequiredSymbols.push_back("__safestack_init");
}
if (!(SanArgs.needsSharedRt() && SanArgs.needsUbsanRt())) {
- if (SanArgs.needsCfiRt())
+ if (SanArgs.needsCfiCrossDsoRt())
StaticRuntimes.push_back("cfi");
- if (SanArgs.needsCfiDiagRt())
+ if (SanArgs.needsCfiCrossDsoDiagRt())
StaticRuntimes.push_back("cfi_diag");
}
if (SanArgs.linkCXXRuntimes() && !SanArgs.requiresMinimalRuntime() &&
((!SanArgs.needsSharedRt() && SanArgs.needsUbsanCXXRt()) ||
- SanArgs.needsCfiDiagRt())) {
+ SanArgs.needsCfiCrossDsoDiagRt())) {
StaticRuntimes.push_back("ubsan_standalone_cxx");
}
if (SanArgs.needsStatsRt()) {
|
fmayer
approved these changes
Apr 16, 2025
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4 [skip ci]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:driver
'clang' and 'clang++' user-facing binaries. Not 'clang-cl'
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CFI runtime (diagnostics, or not) is only needed
for cross-dso support.