Skip to content

Commit

Permalink
[Driver] Enable ASan on Solaris/SPARC (llvm#107403)
Browse files Browse the repository at this point in the history
Once PR llvm#107223 lands, ASan can be enabled on Solaris/SPARC. This patch
does just that. As on Solaris/x86, the dynamic ASan runtime lib needs to
be linked with `-z now` to avoid an `AsanInitInternal` cycle.

Tested on `sparcv9-sun-solaris2.11` and `sparc64-unknown-linux-gnu`.
  • Loading branch information
rorth authored and xgupta committed Oct 4, 2024
1 parent 91561ff commit 067ba20
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions clang/lib/Driver/ToolChains/Solaris.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ void solaris::Linker::ConstructJob(Compilation &C, const JobAction &JA,
}
}
// Avoid AsanInitInternal cycle, Issue #64126.
if (ToolChain.getTriple().isX86() && SA.needsSharedRt() &&
SA.needsAsanRt()) {
if (SA.needsSharedRt() && SA.needsAsanRt()) {
CmdArgs.push_back("-z");
CmdArgs.push_back("now");
}
Expand Down Expand Up @@ -334,10 +333,11 @@ Solaris::Solaris(const Driver &D, const llvm::Triple &Triple,
}

SanitizerMask Solaris::getSupportedSanitizers() const {
const bool IsSparc = getTriple().getArch() == llvm::Triple::sparc;
const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
SanitizerMask Res = ToolChain::getSupportedSanitizers();
// FIXME: Omit X86_64 until 64-bit support is figured out.
if (IsX86) {
// FIXME: Omit SparcV9 and X86_64 until 64-bit support is figured out.
if (IsSparc || IsX86) {
Res |= SanitizerKind::Address;
Res |= SanitizerKind::PointerCompare;
Res |= SanitizerKind::PointerSubtract;
Expand Down

0 comments on commit 067ba20

Please sign in to comment.