[PATCH] D59028: [OpenMP] Enable on device linking with NVLINK to ignore dynamic libraries

Gheorghe-Teodor Bercea via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 6 08:51:58 PST 2019


gtbercea created this revision.
gtbercea added reviewers: ABataev, Hahnfeld, caomhin.
Herald added subscribers: cfe-commits, jdoerfert, guansong.
Herald added a project: clang.

NVLINK does not support dynamic linking so passing dynamic libraries to NVLINK should be avoided.

This patch fixes a bug whereby an explicit passing of the dynamic library via it's full path will result in it being treated like an input.


Repository:
  rC Clang

https://reviews.llvm.org/D59028

Files:
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload-gpu.c


Index: test/Driver/openmp-offload-gpu.c
===================================================================
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -278,3 +278,12 @@
 // RUN:   | FileCheck -check-prefix=CUDA_RED_RECS %s
 // CUDA_RED_RECS: clang{{.*}}"-cc1"{{.*}}"-triple" "nvptx64-nvidia-cuda"
 // CUDA_RED_RECS-SAME: "-fopenmp-cuda-teams-reduction-recs-num=2048"
+
+/// ###########################################################################
+
+/// Check NVLINK ignores dynamic libraries.
+// RUN:   touch %t-dynlib.so
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t-dynlib.so %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NVLINK-IGNORE-DYNLIB %s
+
+// CHK-NVLINK-IGNORE-DYNLIB-NOT: nvlink{{.*}}dynlib
Index: lib/Driver/ToolChains/Cuda.cpp
===================================================================
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -704,6 +704,10 @@
       const char *StaticLibName =
           C.getArgs().MakeArgString(II.getFilename());
       CmdArgs.push_back(StaticLibName);
+    } else if (OrigInputFileName.endswith(".so")) {
+      // Only static libraries are supported.
+      // Dynamic libraries are ignored.
+      continue;
     } else {
       // If the original input is not an object file then it means the
       // assembly step has actually produced a cubin so we need to


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59028.189517.patch
Type: text/x-patch
Size: 1444 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190306/40c4eafa/attachment-0001.bin>


More information about the cfe-commits mailing list