diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 7 | ||||
-rw-r--r-- | clang/test/CodeGenCUDA/dependent-libs.cu | 6 |
2 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 6daea419281..8c9e240a680 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -457,7 +457,12 @@ void CodeGenModule::Release() { // that ELF linkers tend to handle libraries in a more complicated fashion // than on other platforms. This forces us to defer handling the dependent // libs to the linker. - if (!ELFDependentLibraries.empty()) { + // + // CUDA/HIP device and host libraries are different. Currently there is no + // way to differentiate dependent libraries for host or device. Existing + // usage of #pragma comment(lib, *) is intended for host libraries on + // Windows. Therefore emit llvm.dependent-libraries only for host. + if (!ELFDependentLibraries.empty() && !Context.getLangOpts().CUDAIsDevice) { auto *NMD = getModule().getOrInsertNamedMetadata("llvm.dependent-libraries"); for (auto *MD : ELFDependentLibraries) NMD->addOperand(MD); diff --git a/clang/test/CodeGenCUDA/dependent-libs.cu b/clang/test/CodeGenCUDA/dependent-libs.cu new file mode 100644 index 00000000000..6f59e667d3b --- /dev/null +++ b/clang/test/CodeGenCUDA/dependent-libs.cu @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -emit-llvm -o - -fcuda-is-device -x hip %s | FileCheck --check-prefix=DEV %s +// RUN: %clang_cc1 -emit-llvm -o - -x hip %s | FileCheck --check-prefix=HOST %s + +// DEV-NOT: llvm.dependent-libraries +// HOST: llvm.dependent-libraries +#pragma comment(lib, "libabc") |