[PATCH] D85442: [HIP] Ignore invalid ar linker options

Aaron Enye Shi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 6 10:40:02 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG96c2d5e99e32: [HIP] Ignore invalid ar linker options (authored by ashi1).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85442

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/hip-link-static-library.hip


Index: clang/test/Driver/hip-link-static-library.hip
===================================================================
--- clang/test/Driver/hip-link-static-library.hip
+++ clang/test/Driver/hip-link-static-library.hip
@@ -25,3 +25,14 @@
 
 // NORDC-NOT: offload bundler
 // NORDC: # "x86_64-unknown-linux-gnu" - "GNU::StaticLibTool", inputs: ["{{.*o}}"], output: "a.out"
+
+// RUN: %clang --hip-link -### -target x86_64-linux-gnu \
+// RUN:   --emit-static-lib -lgcc \
+// RUN:   -Wl,--enable-new-dtags -Wl,--rpath=/opt \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 -fgpu-rdc %t.o\
+// RUN: 2>&1 | FileCheck -check-prefix=NOFLAG %s
+
+// NOFLAG-NOT: .*lgcc
+// NOFLAG-NOT: .*enable-new-dtags
+// NOFLAG-NOT: .*rpath=/opt
+// NOFLAG: "{{.*}}llvm-ar{{.*}}" "rcsD" "{{.*}}.out" "{{.*o}}" "{{.*o}}"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -341,12 +341,17 @@
   // Silence warnings when linking C code with a C++ '-stdlib' argument.
   Args.ClaimAllArgs(options::OPT_stdlib_EQ);
 
-  // GNU ar tool command "ar <options> <output_file> <input_files>".
+  // ar tool command "llvm-ar <options> <output_file> <input_files>".
   ArgStringList CmdArgs;
   // Create and insert file members with a deterministic index.
   CmdArgs.push_back("rcsD");
   CmdArgs.push_back(Output.getFilename());
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
+
+  for (const auto &II : Inputs) {
+    if (II.isFilename()) {
+       CmdArgs.push_back(II.getFilename());
+    }
+  }
 
   // Delete old output archive file if it already exists before generating a new
   // archive file.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85442.283657.patch
Type: text/x-patch
Size: 1741 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200806/45519b41/attachment.bin>


More information about the cfe-commits mailing list