Index: clang/lib/Driver/ToolChains/HIP.cpp =================================================================== --- clang/lib/Driver/ToolChains/HIP.cpp +++ clang/lib/Driver/ToolChains/HIP.cpp @@ -39,6 +39,8 @@ SmallString<128> Path(LibraryPath); llvm::sys::path::append(Path, BCName); FullName = Path; + if (FullName.startswith("-L")) + FullName = FullName.substr(2); if (llvm::sys::fs::exists(FullName)) { CmdArgs.push_back("-mlink-builtin-bitcode"); CmdArgs.push_back(Args.MakeArgString(FullName)); Index: clang/test/Driver/hip-device-libs.hip =================================================================== --- clang/test/Driver/hip-device-libs.hip +++ clang/test/Driver/hip-device-libs.hip @@ -19,6 +19,13 @@ // RUN: %S/Inputs/hip_multiple_inputs/b.hip \ // RUN: 2>&1 | FileCheck %s --check-prefixes=COM,NOFLUSHD +// Test environment variable HIP_DEVICE_LIB_PATH + +// RUN: HIP_DEVICE_LIB_PATH=%S/Inputs/hip_dev_lib \ +// RUN: %clang -### -target x86_64-linux-gnu \ +// RUN: -x hip --cuda-gpu-arch=gfx900 \ +// RUN: %S/Inputs/hip_multiple_inputs/b.hip \ +// RUN: 2>&1 | FileCheck %s --check-prefixes=COM // COM: {{"[^"]*clang[^"]*"}} // COM-SAME: "-mlink-builtin-bitcode" "{{.*}}hip.amdgcn.bc"