Skip to content

Commit 6a0c440

Browse files
authored
[Driver,sanitizer] Remove RequiresPIE and msan's NeedPIE setting (llvm#77689)
The two variables cause clang to default to -fPIE when no PIC/PIC option is specified. msan used to require PIE because many `kMemoryLayout` made the low address (used by ET_EXEC executables) invalid. Current msan.h no longer does so, rendering this PIE requirement unneeded. The same argument applies to -fsanitize=dataflow. On Linux, most builds set CLANG_DEFAULT_PIE_ON_LINUX to 1, making `RequiresPIE/NeedPIE` redundant on Linux. (`NeedPIE` is not removed for now due to the -fsanitize-cfi-cross-dso comment. If it's indeed incompatible with explicit -fno-pic, a warning is probably better.)
1 parent 9095eec commit 6a0c440

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ static const SanitizerMask NotAllowedWithTrap = SanitizerKind::Vptr;
3939
static const SanitizerMask NotAllowedWithMinimalRuntime = SanitizerKind::Vptr;
4040
static const SanitizerMask NotAllowedWithExecuteOnly =
4141
SanitizerKind::Function | SanitizerKind::KCFI;
42-
static const SanitizerMask RequiresPIE =
43-
SanitizerKind::DataFlow | SanitizerKind::Scudo;
4442
static const SanitizerMask NeedsUnwindTables =
4543
SanitizerKind::Address | SanitizerKind::HWAddress | SanitizerKind::Thread |
4644
SanitizerKind::Memory | SanitizerKind::DataFlow;
@@ -303,9 +301,7 @@ bool SanitizerArgs::needsCfiDiagRt() const {
303301
CfiCrossDso && !ImplicitCfiRuntime;
304302
}
305303

306-
bool SanitizerArgs::requiresPIE() const {
307-
return NeedPIE || (Sanitizers.Mask & RequiresPIE);
308-
}
304+
bool SanitizerArgs::requiresPIE() const { return NeedPIE; }
309305

310306
bool SanitizerArgs::needsUnwindTables() const {
311307
return static_cast<bool>(Sanitizers.Mask & NeedsUnwindTables);
@@ -699,8 +695,6 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
699695
MsanParamRetval = Args.hasFlag(
700696
options::OPT_fsanitize_memory_param_retval,
701697
options::OPT_fno_sanitize_memory_param_retval, MsanParamRetval);
702-
NeedPIE |= !(TC.getTriple().isOSLinux() &&
703-
TC.getTriple().getArch() == llvm::Triple::x86_64);
704698
} else if (AllAddedKinds & SanitizerKind::KernelMemory) {
705699
MsanUseAfterDtor = false;
706700
MsanParamRetval = Args.hasFlag(

0 commit comments

Comments
 (0)