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