<div dir="ltr">Hi Hal,<div><br></div><div>I don't understand why only ASAN is enabled. What about TSAN, etc.? Shouldn't you query whatever the host toolchain is?<br></div><div><br></div><div>I think you're right, I should just implement it as</div><div><br></div><div>SanitizerMask CudaToolChain::getSupportedSanitizers() const { return HostTC.getSupportedSanitizers(); }</div><div><br></div><div>I will get a patch up later today to do that.</div><div><br></div><div>Thanks for the suggestion!</div><div><br></div><div>-Jason</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Dec 2, 2016 at 4:31 AM Hal Finkel <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">----- Original Message -----<br class="gmail_msg">
> From: "Jason Henline via cfe-commits" <<a href="mailto:cfe-commits@lists.llvm.org" class="gmail_msg" target="_blank">cfe-commits@lists.llvm.org</a>><br class="gmail_msg">
> To: <a href="mailto:cfe-commits@lists.llvm.org" class="gmail_msg" target="_blank">cfe-commits@lists.llvm.org</a><br class="gmail_msg">
> Sent: Thursday, December 1, 2016 7:42:54 PM<br class="gmail_msg">
> Subject: r288448 - [CUDA] "Support" ASAN arguments in CudaToolChain<br class="gmail_msg">
><br class="gmail_msg">
> Author: jhen<br class="gmail_msg">
> Date: Thu Dec 1 19:42:54 2016<br class="gmail_msg">
> New Revision: 288448<br class="gmail_msg">
><br class="gmail_msg">
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=288448&view=rev" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project?rev=288448&view=rev</a><br class="gmail_msg">
> Log:<br class="gmail_msg">
> [CUDA] "Support" ASAN arguments in CudaToolChain<br class="gmail_msg">
><br class="gmail_msg">
> This fixes a bug that was introduced in rL287285. The bug made it<br class="gmail_msg">
> illegal to pass -fsanitize=address during CUDA compilation because<br class="gmail_msg">
> the<br class="gmail_msg">
> CudaToolChain class was switched from deriving from the Linux<br class="gmail_msg">
> toolchain<br class="gmail_msg">
> class to deriving directly from the ToolChain toolchain class. When<br class="gmail_msg">
> CudaToolChain derived from Linux, it used Linux's<br class="gmail_msg">
> getSupportedSanitizers<br class="gmail_msg">
> method, and that method allowed ASAN, but when it switched to<br class="gmail_msg">
> deriving<br class="gmail_msg">
> directly from ToolChain, it inherited a getSupportedSanitizers method<br class="gmail_msg">
> that didn't allow for ASAN.<br class="gmail_msg">
><br class="gmail_msg">
> This patch fixes that bug by creating a getSupportedSanitizers method<br class="gmail_msg">
> for CudaToolChain that supports ASAN.<br class="gmail_msg">
><br class="gmail_msg">
> This patch also fixes the test that checks that -fsanitize=address is<br class="gmail_msg">
> passed correctly for CUDA builds. That test didn't used to notice if<br class="gmail_msg">
> an<br class="gmail_msg">
> error message was emitted, and that's why it didn't catch this bug<br class="gmail_msg">
> when<br class="gmail_msg">
> it was first introduced. With the fix from this patch, that test will<br class="gmail_msg">
> now catch any similar bug in the future.<br class="gmail_msg">
><br class="gmail_msg">
> Modified:<br class="gmail_msg">
> cfe/trunk/lib/Driver/ToolChains.cpp<br class="gmail_msg">
> cfe/trunk/lib/Driver/ToolChains.h<br class="gmail_msg">
> cfe/trunk/test/Driver/<a href="http://cuda-no-sanitizers.cu" rel="noreferrer" class="gmail_msg" target="_blank">cuda-no-sanitizers.cu</a><br class="gmail_msg">
><br class="gmail_msg">
> Modified: cfe/trunk/lib/Driver/ToolChains.cpp<br class="gmail_msg">
> URL:<br class="gmail_msg">
> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=288448&r1=288447&r2=288448&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=288448&r1=288447&r2=288448&view=diff</a><br class="gmail_msg">
> ==============================================================================<br class="gmail_msg">
> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)<br class="gmail_msg">
> +++ cfe/trunk/lib/Driver/ToolChains.cpp Thu Dec 1 19:42:54 2016<br class="gmail_msg">
> @@ -4973,6 +4973,15 @@ void CudaToolChain::AddIAMCUIncludeArgs(<br class="gmail_msg">
> HostTC.AddIAMCUIncludeArgs(Args, CC1Args);<br class="gmail_msg">
> }<br class="gmail_msg">
><br class="gmail_msg">
> +SanitizerMask CudaToolChain::getSupportedSanitizers() const {<br class="gmail_msg">
> + // The CudaToolChain only supports address sanitization in the<br class="gmail_msg">
> sense that it<br class="gmail_msg">
> + // allows ASAN arguments on the command line. It must not error<br class="gmail_msg">
> out on these<br class="gmail_msg">
> + // command line arguments because the host code compilation<br class="gmail_msg">
> supports them.<br class="gmail_msg">
> + // However, it doesn't actually do any address sanitization for<br class="gmail_msg">
> device code;<br class="gmail_msg">
> + // instead, it just ignores any ASAN command line arguments it<br class="gmail_msg">
> sees.<br class="gmail_msg">
> + return SanitizerKind::Address;<br class="gmail_msg">
> +}<br class="gmail_msg">
<br class="gmail_msg">
I don't understand why only ASAN is enabled. What about TSAN, etc.? Shouldn't you query whatever the host toolchain is?<br class="gmail_msg">
<br class="gmail_msg">
Thanks again,<br class="gmail_msg">
Hal<br class="gmail_msg">
<br class="gmail_msg">
> +<br class="gmail_msg">
> /// XCore tool chain<br class="gmail_msg">
> XCoreToolChain::XCoreToolChain(const Driver &D, const llvm::Triple<br class="gmail_msg">
> &Triple,<br class="gmail_msg">
> const ArgList &Args)<br class="gmail_msg">
><br class="gmail_msg">
> Modified: cfe/trunk/lib/Driver/ToolChains.h<br class="gmail_msg">
> URL:<br class="gmail_msg">
> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=288448&r1=288447&r2=288448&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=288448&r1=288447&r2=288448&view=diff</a><br class="gmail_msg">
> ==============================================================================<br class="gmail_msg">
> --- cfe/trunk/lib/Driver/ToolChains.h (original)<br class="gmail_msg">
> +++ cfe/trunk/lib/Driver/ToolChains.h Thu Dec 1 19:42:54 2016<br class="gmail_msg">
> @@ -912,6 +912,8 @@ public:<br class="gmail_msg">
> void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,<br class="gmail_msg">
> llvm::opt::ArgStringList &CC1Args) const<br class="gmail_msg">
> override;<br class="gmail_msg">
><br class="gmail_msg">
> + SanitizerMask getSupportedSanitizers() const override;<br class="gmail_msg">
> +<br class="gmail_msg">
> const ToolChain &HostTC;<br class="gmail_msg">
> CudaInstallationDetector CudaInstallation;<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> Modified: cfe/trunk/test/Driver/<a href="http://cuda-no-sanitizers.cu" rel="noreferrer" class="gmail_msg" target="_blank">cuda-no-sanitizers.cu</a><br class="gmail_msg">
> URL:<br class="gmail_msg">
> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-no-sanitizers.cu?rev=288448&r1=288447&r2=288448&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-no-sanitizers.cu?rev=288448&r1=288447&r2=288448&view=diff</a><br class="gmail_msg">
> ==============================================================================<br class="gmail_msg">
> --- cfe/trunk/test/Driver/<a href="http://cuda-no-sanitizers.cu" rel="noreferrer" class="gmail_msg" target="_blank">cuda-no-sanitizers.cu</a> (original)<br class="gmail_msg">
> +++ cfe/trunk/test/Driver/<a href="http://cuda-no-sanitizers.cu" rel="noreferrer" class="gmail_msg" target="_blank">cuda-no-sanitizers.cu</a> Thu Dec 1 19:42:54<br class="gmail_msg">
> 2016<br class="gmail_msg">
> @@ -6,6 +6,7 @@<br class="gmail_msg">
> // RUN: %clang -### -target x86_64-linux-gnu -c<br class="gmail_msg">
> --cuda-gpu-arch=sm_20 -fsanitize=address %s 2>&1 | \<br class="gmail_msg">
> // RUN: FileCheck %s<br class="gmail_msg">
><br class="gmail_msg">
> +// CHECK-NOT: error:<br class="gmail_msg">
> // CHECK-DAG: "-fcuda-is-device"<br class="gmail_msg">
> // CHECK-NOT: "-fsanitize=address"<br class="gmail_msg">
> // CHECK-DAG: "-triple" "x86_64--linux-gnu"<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> _______________________________________________<br class="gmail_msg">
> cfe-commits mailing list<br class="gmail_msg">
> <a href="mailto:cfe-commits@lists.llvm.org" class="gmail_msg" target="_blank">cfe-commits@lists.llvm.org</a><br class="gmail_msg">
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br class="gmail_msg">
><br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
Hal Finkel<br class="gmail_msg">
Lead, Compiler Technology and Programming Languages<br class="gmail_msg">
Leadership Computing Facility<br class="gmail_msg">
Argonne National Laboratory<br class="gmail_msg">
</blockquote></div>