r281071 - Myriad: nominally "support" ASAN.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 8 12:14:43 PDT 2019


On Fri, 9 Sep 2016 at 11:29, Douglas Katzman via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: dougk
> Date: Fri Sep  9 13:20:49 2016
> New Revision: 281071
>
> URL: http://llvm.org/viewvc/llvm-project?rev=281071&view=rev
> Log:
> Myriad: nominally "support" ASAN.
>
> Doesn't work, but needs to be enabled in order to get there.
>
> Modified:
>     cfe/trunk/lib/Driver/ToolChains.cpp
>     cfe/trunk/lib/Driver/ToolChains.h
>     cfe/trunk/lib/Driver/Tools.cpp
>     cfe/trunk/test/Driver/sanitizer-ld.c
>
> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=281071&r1=281070&r2=281071&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Sep  9 13:20:49 2016
> @@ -5042,6 +5042,10 @@ Tool *MyriadToolChain::buildLinker() con
>    return new tools::Myriad::Linker(*this);
>  }
>
> +SanitizerMask MyriadToolChain::getSupportedSanitizers() const {
> +  return SanitizerKind::Address;
>

This change disabled the use of UBSan on Myriad; was that intentional? (All
other overriders call the base class version to get a list of sanitizers
that don't require special platform support, and then add values to the
mask that it returns.)


> +}
> +
>  WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple,
>                           const llvm::opt::ArgList &Args)
>    : ToolChain(D, Triple, Args) {
>
> Modified: cfe/trunk/lib/Driver/ToolChains.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=281071&r1=281070&r2=281071&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Driver/ToolChains.h (original)
> +++ cfe/trunk/lib/Driver/ToolChains.h Fri Sep  9 13:20:49 2016
> @@ -1147,6 +1147,7 @@ public:
>        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;
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=281071&r1=281070&r2=281071&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Fri Sep  9 13:20:49 2016
> @@ -3081,11 +3081,15 @@ static void linkSanitizerRuntimeDeps(con
>    // 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");
>  }
>
> @@ -11055,9 +11059,12 @@ void tools::Myriad::Linker::ConstructJob
>
>    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) {
>
> Modified: cfe/trunk/test/Driver/sanitizer-ld.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=281071&r1=281070&r2=281071&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Driver/sanitizer-ld.c (original)
> +++ cfe/trunk/test/Driver/sanitizer-ld.c Fri Sep  9 13:20:49 2016
> @@ -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 \
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190708/719108cd/attachment-0001.html>


More information about the cfe-commits mailing list