Index: lib/Driver/ToolChains/Cuda.cpp =================================================================== --- lib/Driver/ToolChains/Cuda.cpp +++ lib/Driver/ToolChains/Cuda.cpp @@ -401,6 +401,19 @@ // came with CUDA-7.0. CC1Args.push_back("-target-feature"); CC1Args.push_back("+ptx42"); + + if (DeviceOffloadingKind == Action::OFK_OpenMP) { + SmallVector LibraryPaths; + if (char *Env = ::getenv("LIBRARY_PATH")) { + StringRef CompilerPath = Env; + while (!CompilerPath.empty()) { + std::pair Split = + CompilerPath.split(llvm::sys::EnvPathSeparator); + LibraryPaths.push_back(Split.first); + CompilerPath = Split.second; + } + } + } } void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs, Index: test/Driver/openmp-offload.c =================================================================== --- test/Driver/openmp-offload.c +++ test/Driver/openmp-offload.c @@ -615,3 +615,12 @@ // CHK-FOPENMP-IS-DEVICE: clang{{.*}}.i" {{.*}}" "-fopenmp-is-device" // CHK-FOPENMP-IS-DEVICE-NEXT: clang{{.*}}.bc" {{.*}}.i" "-fopenmp-is-device" "-fopenmp-host-ir-file-path" // CHK-FOPENMP-IS-DEVICE-NEXT: clang{{.*}}.s" {{.*}}.bc" "-fopenmp-is-device" + +/// ########################################################################### + +/// Check that the lib folder pointed to by the LIBRARY_PATH is correctly passsed to the loader script. +// RUN: LIBRARY_PATH=/a/b/c/lib %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHK-LIB-PATH %s + +// CHK-LIB-PATH: ld{{.*}}.o" "-L/a/b/c/lib" +// CHK-LIB-PATH: ld{{.*}}.o" "-L/a/b/c/lib"