[clang] 96c2d5e - [HIP] Ignore invalid ar linker options
Aaron En Ye Shi via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 6 10:39:55 PDT 2020
Author: Aaron En Ye Shi
Date: 2020-08-06T17:39:41Z
New Revision: 96c2d5e99e32340be1379959977f2d6247788db6
URL: https://github.com/llvm/llvm-project/commit/96c2d5e99e32340be1379959977f2d6247788db6
DIFF: https://github.com/llvm/llvm-project/commit/96c2d5e99e32340be1379959977f2d6247788db6.diff
LOG: [HIP] Ignore invalid ar linker options
Instead of accepting the same arguments as regular linker,
the static linker will only accept input files.
Reviewed By: yaxunl
Differential Revision: https://reviews.llvm.org/D85442
Added:
Modified:
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/hip-link-static-library.hip
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 9ca674511dab..d423a71b5cca 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -341,12 +341,17 @@ void tools::gnutools::StaticLibTool::ConstructJob(
// 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.
diff --git a/clang/test/Driver/hip-link-static-library.hip b/clang/test/Driver/hip-link-static-library.hip
index 55c5a5acc5ca..e670980fa486 100644
--- a/clang/test/Driver/hip-link-static-library.hip
+++ b/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}}"
More information about the cfe-commits
mailing list