Skip to content

Commit

Permalink
Myriad: nominally "support" ASAN.
Browse files Browse the repository at this point in the history
Doesn't work, but needs to be enabled in order to get there.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@281071 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
snuglas committed Sep 9, 2016
1 parent 09a0c48 commit 27f089e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/Driver/ToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5042,6 +5042,10 @@ Tool *MyriadToolChain::buildLinker() const {
return new tools::Myriad::Linker(*this);
}

SanitizerMask MyriadToolChain::getSupportedSanitizers() const {
return SanitizerKind::Address;
}

WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple,
const llvm::opt::ArgList &Args)
: ToolChain(D, Triple, Args) {
Expand Down
1 change: 1 addition & 0 deletions lib/Driver/ToolChains.h
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,7 @@ class LLVM_LIBRARY_VISIBILITY MyriadToolChain : public Generic_ELF {
llvm::opt::ArgStringList &CC1Args) const override;
Tool *SelectTool(const JobAction &JA) const override;
unsigned GetDefaultDwarfVersion() const override { return 2; }
SanitizerMask getSupportedSanitizers() const override;

protected:
Tool *buildLinker() const override;
Expand Down
15 changes: 11 additions & 4 deletions lib/Driver/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3081,11 +3081,15 @@ static void linkSanitizerRuntimeDeps(const ToolChain &TC,
// Force linking against the system libraries sanitizers depends on
// (see PR15823 why this is necessary).
CmdArgs.push_back("--no-as-needed");
CmdArgs.push_back("-lpthread");
CmdArgs.push_back("-lrt");
// There's no libpthread or librt on RTEMS.
if (TC.getTriple().getOS() != llvm::Triple::RTEMS) {
CmdArgs.push_back("-lpthread");
CmdArgs.push_back("-lrt");
}
CmdArgs.push_back("-lm");
// There's no libdl on FreeBSD.
if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
// There's no libdl on FreeBSD or RTEMS.
if (TC.getTriple().getOS() != llvm::Triple::FreeBSD &&
TC.getTriple().getOS() != llvm::Triple::RTEMS)
CmdArgs.push_back("-ldl");
}

Expand Down Expand Up @@ -11055,9 +11059,12 @@ void tools::Myriad::Linker::ConstructJob(Compilation &C, const JobAction &JA,

TC.AddFilePathLibArgs(Args, CmdArgs);

bool NeedsSanitizerDeps = addSanitizerRuntimes(TC, Args, CmdArgs);
AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);

if (UseDefaultLibs) {
if (NeedsSanitizerDeps)
linkSanitizerRuntimeDeps(TC, CmdArgs);
if (C.getDriver().CCCIsCXX())
CmdArgs.push_back("-lstdc++");
if (T.getOS() == llvm::Triple::RTEMS) {
Expand Down
9 changes: 9 additions & 0 deletions test/Driver/sanitizer-ld.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@
// CHECK-ASAN-ANDROID-SHARED: libclang_rt.asan-arm-android.so"
// CHECK-ASAN-ANDROID-SHARED-NOT: "-lpthread"

// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: -target sparcel-myriad-rtems-elf -fsanitize=address \
// RUN: --sysroot=%S/Inputs/basic_myriad_tree \
// RUN: | FileCheck --check-prefix=CHECK-ASAN-MYRIAD %s
//
// CHECK-ASAN-MYRIAD: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
// CHECK-ASAN-MYRIAD-NOT: "-lc"
// CHECK-ASAN-MYRIAD: libclang_rt.asan-sparcel.a"

// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: -target x86_64-unknown-linux -stdlib=platform -lstdc++ \
// RUN: -fsanitize=thread \
Expand Down

0 comments on commit 27f089e

Please sign in to comment.