[PATCH] D68300: [HIP] Add option -fno-link-builtin-bitcode to disable linking device lib

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 1 20:00:43 PDT 2019


yaxunl updated this revision to Diff 222746.
yaxunl retitled this revision from "[HIP] Add option -fno-hip-link-builtin-bitcode to disable linking device lib" to "[HIP] Add option -fno-link-builtin-bitcode to disable linking device lib".
yaxunl added a comment.

change the option name


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68300/new/

https://reviews.llvm.org/D68300

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/HIP.cpp
  test/Driver/hip-no-device-libs.hip


Index: test/Driver/hip-no-device-libs.hip
===================================================================
--- /dev/null
+++ test/Driver/hip-no-device-libs.hip
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -fno-link-builtin-bitcode -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-NOT: "-mlink-builtin-bitcode"
+
Index: lib/Driver/ToolChains/HIP.cpp
===================================================================
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -289,6 +289,10 @@
     CC1Args.append({"-fvisibility", "hidden"});
     CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
+
+  if (!DriverArgs.hasFlag(options::OPT_flink_builtin_bitcode,
+                          options::OPT_fno_link_builtin_bitcode, true))
+    return;
   ArgStringList LibraryPaths;
 
   // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -602,6 +602,9 @@
 def fhip_new_launch_api : Flag<["-"], "fhip-new-launch-api">,
   Flags<[CC1Option]>, HelpText<"Use new kernel launching API for HIP.">;
 def fno_hip_new_launch_api : Flag<["-"], "fno-hip-new-launch-api">;
+def flink_builtin_bitcode : Flag<["-"], "flink-builtin-bitcode">,
+  Flags<[CC1Option]>, HelpText<"Link builtin bitcode for HIP device compilation.">;
+def fno_link_builtin_bitcode : Flag<["-"], "fno-link-builtin-bitcode">;
 def libomptarget_nvptx_path_EQ : Joined<["--"], "libomptarget-nvptx-path=">, Group<i_Group>,
   HelpText<"Path to libomptarget-nvptx libraries">;
 def dD : Flag<["-"], "dD">, Group<d_Group>, Flags<[CC1Option]>,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68300.222746.patch
Type: text/x-patch
Size: 1919 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191002/ce2b09a1/attachment.bin>


More information about the cfe-commits mailing list