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
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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits