[PATCH] D57829: [CUDA][HIP] Disable emitting llvm.linker.options in device compilation
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 30 21:07:00 PDT 2019
yaxunl updated this revision to Diff 227216.
yaxunl retitled this revision from "[HIP] Disable emitting llvm.linker.options in device compilation" to "[CUDA][HIP] Disable emitting llvm.linker.options in device compilation".
yaxunl edited the summary of this revision.
yaxunl added a comment.
use -fno-autolink to disable linker option for device compilation.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57829/new/
https://reviews.llvm.org/D57829
Files:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGenCUDA/linker-options.cu
clang/test/Driver/hip-autolink.hip
Index: clang/test/Driver/hip-autolink.hip
===================================================================
--- /dev/null
+++ clang/test/Driver/hip-autolink.hip
@@ -0,0 +1,14 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+//
+// RUN: %clang --target=i386-pc-windows-msvc --cuda-gpu-arch=gfx906 -nogpulib \
+// RUN: --cuda-device-only -x hip %s -### 2>&1 | FileCheck --check-prefix=DEV %s
+// RUN: %clang --target=i386-pc-windows-msvc --cuda-gpu-arch=gfx906 -nogpulib \
+// RUN: --cuda-host-only -x hip %s -### 2>&1 | FileCheck --check-prefix=HOST %s
+
+// DEV: "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// DEV-SAME: "-fno-autolink"
+
+// HOST: "-cc1" "-triple" "i386-pc-windows-msvc{{.*}}"
+// HOST-NOT: "-fno-autolink"
Index: clang/test/CodeGenCUDA/linker-options.cu
===================================================================
--- /dev/null
+++ clang/test/CodeGenCUDA/linker-options.cu
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm -o - -fcuda-is-device -fms-extensions -x hip %s \
+// RUN: -fno-autolink | FileCheck -check-prefix=DEV %s
+// RUN: %clang_cc1 -emit-llvm -o - -fms-extensions -x hip %s \
+// RUN: | FileCheck -check-prefix=HOST %s
+
+// DEV-NOT: llvm.linker.options
+// DEV-NOT: llvm.dependent-libraries
+// HOST: llvm.linker.options
+// HOST: llvm.dependent-libraries
+#pragma comment(lib, "libcpmt")
+#pragma detect_mismatch("myLib_version", "9")
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -378,13 +378,18 @@
CmdArgs.push_back("-fexceptions");
}
-static bool ShouldDisableAutolink(const ArgList &Args, const ToolChain &TC) {
+static bool ShouldDisableAutolink(const ArgList &Args, const ToolChain &TC,
+ const JobAction &JA) {
bool Default = true;
if (TC.getTriple().isOSDarwin()) {
// The native darwin assembler doesn't support the linker_option directives,
// so we disable them if we think the .s file will be passed to it.
Default = TC.useIntegratedAs();
}
+ // The linker_option directives are intended for host compilation.
+ if (JA.isDeviceOffloading(Action::OFK_Cuda) ||
+ JA.isDeviceOffloading(Action::OFK_HIP))
+ Default = false;
return !Args.hasFlag(options::OPT_fautolink, options::OPT_fno_autolink,
Default);
}
@@ -4362,7 +4367,7 @@
if (ShouldDisableDwarfDirectory(Args, TC))
CmdArgs.push_back("-fno-dwarf-directory-asm");
- if (ShouldDisableAutolink(Args, TC))
+ if (ShouldDisableAutolink(Args, TC, JA))
CmdArgs.push_back("-fno-autolink");
// Add in -fdebug-compilation-dir if necessary.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57829.227216.patch
Type: text/x-patch
Size: 2777 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191031/e7882fe0/attachment.bin>
More information about the cfe-commits
mailing list