forked from OSchip/llvm-project
[clang] enable sanitizers for hexagon
This commit is contained in:
parent
f2880329eb
commit
59dfde7d94
|
@ -146,6 +146,8 @@ void hexagon::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
"-mcpu=hexagon" +
|
||||
toolchains::HexagonToolChain::GetTargetCPUVersion(Args)));
|
||||
|
||||
addSanitizerRuntimes(HTC, Args, CmdArgs);
|
||||
|
||||
if (Output.isFilename()) {
|
||||
CmdArgs.push_back("-o");
|
||||
CmdArgs.push_back(Output.getFilename());
|
||||
|
@ -223,6 +225,8 @@ constructHexagonLinkArgs(Compilation &C, const JobAction &JA,
|
|||
bool UseShared = IsShared && !IsStatic;
|
||||
StringRef CpuVer = toolchains::HexagonToolChain::GetTargetCPUVersion(Args);
|
||||
|
||||
bool NeedsSanitizerDeps = addSanitizerRuntimes(HTC, Args, CmdArgs);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Silence warnings for various options
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -288,6 +292,12 @@ constructHexagonLinkArgs(Compilation &C, const JobAction &JA,
|
|||
AddLinkerInputs(HTC, Inputs, Args, CmdArgs, JA);
|
||||
|
||||
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
|
||||
if (NeedsSanitizerDeps) {
|
||||
linkSanitizerRuntimeDeps(HTC, CmdArgs);
|
||||
|
||||
CmdArgs.push_back("-lunwind");
|
||||
}
|
||||
|
||||
CmdArgs.push_back("-lclang_rt.builtins-hexagon");
|
||||
CmdArgs.push_back("-lc");
|
||||
}
|
||||
|
@ -450,6 +460,13 @@ Optional<unsigned> HexagonToolChain::getSmallDataThreshold(
|
|||
return None;
|
||||
}
|
||||
|
||||
std::string HexagonToolChain::getCompilerRTPath() const {
|
||||
SmallString<128> Dir(getDriver().SysRoot);
|
||||
llvm::sys::path::append(Dir, "usr", "lib");
|
||||
Dir += SelectedMultilib.gccSuffix();
|
||||
return std::string(Dir.str());
|
||||
}
|
||||
|
||||
void HexagonToolChain::getHexagonLibraryPaths(const ArgList &Args,
|
||||
ToolChain::path_list &LibPaths) const {
|
||||
const Driver &D = getDriver();
|
||||
|
|
|
@ -104,6 +104,8 @@ public:
|
|||
void getHexagonLibraryPaths(const llvm::opt::ArgList &Args,
|
||||
ToolChain::path_list &LibPaths) const;
|
||||
|
||||
std::string getCompilerRTPath() const override;
|
||||
|
||||
static bool isAutoHVXEnabled(const llvm::opt::ArgList &Args);
|
||||
static const StringRef GetDefaultCPU();
|
||||
static const StringRef GetTargetCPUVersion(const llvm::opt::ArgList &Args);
|
||||
|
|
|
@ -694,6 +694,7 @@ SanitizerMask Linux::getSupportedSanitizers() const {
|
|||
getTriple().getArch() == llvm::Triple::thumbeb;
|
||||
const bool IsRISCV64 = getTriple().getArch() == llvm::Triple::riscv64;
|
||||
const bool IsSystemZ = getTriple().getArch() == llvm::Triple::systemz;
|
||||
const bool IsHexagon = getTriple().getArch() == llvm::Triple::hexagon;
|
||||
SanitizerMask Res = ToolChain::getSupportedSanitizers();
|
||||
Res |= SanitizerKind::Address;
|
||||
Res |= SanitizerKind::PointerCompare;
|
||||
|
@ -707,7 +708,7 @@ SanitizerMask Linux::getSupportedSanitizers() const {
|
|||
if (IsX86_64 || IsMIPS64 || IsAArch64)
|
||||
Res |= SanitizerKind::DataFlow;
|
||||
if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch || IsPowerPC64 ||
|
||||
IsRISCV64 || IsSystemZ)
|
||||
IsRISCV64 || IsSystemZ || IsHexagon)
|
||||
Res |= SanitizerKind::Leak;
|
||||
if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64 || IsSystemZ)
|
||||
Res |= SanitizerKind::Thread;
|
||||
|
@ -716,7 +717,7 @@ SanitizerMask Linux::getSupportedSanitizers() const {
|
|||
if (IsX86 || IsX86_64)
|
||||
Res |= SanitizerKind::Function;
|
||||
if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch ||
|
||||
IsPowerPC64)
|
||||
IsPowerPC64 || IsHexagon)
|
||||
Res |= SanitizerKind::Scudo;
|
||||
if (IsX86_64 || IsAArch64) {
|
||||
Res |= SanitizerKind::HWAddress;
|
||||
|
|
Loading…
Reference in New Issue