diff options
author | Yaxun Liu <Yaxun.Liu@amd.com> | 2019-05-28 21:18:59 +0000 |
---|---|---|
committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2019-05-28 21:18:59 +0000 |
commit | b02a79e8d08f9feeba075e41162adf1566f0cbbc (patch) | |
tree | e353a31fcda6aa21d690a91e30b49de4801f703d /lib/CodeGen/CodeGenModule.cpp | |
parent | 1580041963802152a3548dc06305921082bdd9d7 (diff) | |
download | clang-b02a79e8d08f9feeba075e41162adf1566f0cbbc.tar.gz |
[CUDA][HIP] Emit dependent libs for host only
Recently D60274 was introduced to allow lld to handle dependent libs. However current
usage of dependent libs (e.g. pragma comment(lib, *) in windows header files) are intended
for host only. Emitting the metadata in device IR causes link error in device path.
Until there is a way to different it dependent libs for device or host, metadata for dependent
libs should be emitted for host only. This patch enforces that.
Differential Revision: https://reviews.llvm.org/D62483
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@361880 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 6daea41928..8c9e240a68 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/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); |