llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-driver Author: Artem Belevich (Artem-B) <details> <summary>Changes</summary> We do not have support for the threadsafe statics on the GPU side. However, we do sometimes end up with empty local static initializers, and those happen to trigger calls to `__cxa_guard*`, which breaks compilation. Partially addresses https://github.com/llvm/llvm-project/issues/117023 --- Full diff: https://github.com/llvm/llvm-project/pull/117074.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/Cuda.cpp (+3-2) - (added) clang/test/Driver/cuda-no-threadsafe-statics.cu (+10) ``````````diff diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp index ddd5ea248ca0cc..102794829795da 100644 --- a/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/clang/lib/Driver/ToolChains/Cuda.cpp @@ -856,8 +856,9 @@ void CudaToolChain::addClangTargetOptions( DeviceOffloadingKind == Action::OFK_Cuda) && "Only OpenMP or CUDA offloading kinds are supported for NVIDIA GPUs."); - CC1Args.append( - {"-fcuda-is-device", "-mllvm", "-enable-memcpyopt-without-libcalls"}); + CC1Args.append({"-fcuda-is-device", "-mllvm", + "-enable-memcpyopt-without-libcalls", + "-fno-threadsafe-statics"}); // Unsized function arguments used for variadics were introduced in CUDA-9.0 // We still do not support generating code that actually uses variadic diff --git a/clang/test/Driver/cuda-no-threadsafe-statics.cu b/clang/test/Driver/cuda-no-threadsafe-statics.cu new file mode 100644 index 00000000000000..fd0465f175846d --- /dev/null +++ b/clang/test/Driver/cuda-no-threadsafe-statics.cu @@ -0,0 +1,10 @@ +// Check that -fno-thread-safe-statics get passed down to device-side +// compilation only. +// +// RUN: not %clang -### --target=x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s 2>&1 \ +// RUN: | FileCheck %s +// +// CHECK: "-fcuda-is-device" +// CHECK-SAME: "-fno-threadsafe-statics" +// CHECK: "-triple" "x86_64-unknown-linux-gnu" +// CHECK-NOT: "-fno-threadsafe-statics" `````````` </details> https://github.com/llvm/llvm-project/pull/117074 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits