Author: Fangrui Song Date: 2024-01-11T18:30:16-08:00 New Revision: 6a0c440159aa2b2e895fe6e04af39c91e54733ce
URL: https://github.com/llvm/llvm-project/commit/6a0c440159aa2b2e895fe6e04af39c91e54733ce DIFF: https://github.com/llvm/llvm-project/commit/6a0c440159aa2b2e895fe6e04af39c91e54733ce.diff LOG: [Driver,sanitizer] Remove RequiresPIE and msan's NeedPIE setting (#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.) Added: Modified: clang/lib/Driver/SanitizerArgs.cpp Removed: ################################################################################ diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index ad68c086b71790..9d6ea371f9f6dd 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -39,8 +39,6 @@ static const SanitizerMask NotAllowedWithTrap = SanitizerKind::Vptr; static const SanitizerMask NotAllowedWithMinimalRuntime = SanitizerKind::Vptr; static const SanitizerMask NotAllowedWithExecuteOnly = SanitizerKind::Function | SanitizerKind::KCFI; -static const SanitizerMask RequiresPIE = - SanitizerKind::DataFlow | SanitizerKind::Scudo; static const SanitizerMask NeedsUnwindTables = SanitizerKind::Address | SanitizerKind::HWAddress | SanitizerKind::Thread | SanitizerKind::Memory | SanitizerKind::DataFlow; @@ -303,9 +301,7 @@ bool SanitizerArgs::needsCfiDiagRt() const { CfiCrossDso && !ImplicitCfiRuntime; } -bool SanitizerArgs::requiresPIE() const { - return NeedPIE || (Sanitizers.Mask & RequiresPIE); -} +bool SanitizerArgs::requiresPIE() const { return NeedPIE; } bool SanitizerArgs::needsUnwindTables() const { return static_cast<bool>(Sanitizers.Mask & NeedsUnwindTables); @@ -699,8 +695,6 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, MsanParamRetval = Args.hasFlag( options::OPT_fsanitize_memory_param_retval, options::OPT_fno_sanitize_memory_param_retval, MsanParamRetval); - NeedPIE |= !(TC.getTriple().isOSLinux() && - TC.getTriple().getArch() == llvm::Triple::x86_64); } else if (AllAddedKinds & SanitizerKind::KernelMemory) { MsanUseAfterDtor = false; MsanParamRetval = Args.hasFlag( _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits