[PATCH] D70919: [Hexagon] Avoid passing unsupported options to lld when -fuse-ld=lld is used

Sid Manning via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 5 10:05:35 PST 2019


sidneym updated this revision to Diff 232374.
sidneym added a comment.

Remove quotes around check-not.

-fuse-ld=lld is the correct usage.  -fuse-ld=ld.lld results in an error message:
error: invalid linker name in argument '-fuse-ld=ld.lld'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70919

Files:
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/test/Driver/hexagon-toolchain-elf.c


Index: clang/test/Driver/hexagon-toolchain-elf.c
===================================================================
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -536,3 +536,25 @@
 // RUN:   | FileCheck -check-prefix=CHECK080 %s
 // CHECK080:      "-cc1"
 // CHECK080:      "-Wreturn-type"
+
+// -----------------------------------------------------------------------------
+// Default, not passing -fuse-ld
+// -----------------------------------------------------------------------------
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK081 %s
+// CHECK081:      "-march=hexagon"
+// CHECK081:      "-mcpu=hexagonv60"
+// -----------------------------------------------------------------------------
+// Passing -fuse-ld=lld
+// -----------------------------------------------------------------------------
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   -fuse-ld=lld \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK082 %s
+// CHECK082-NOT:      -march=
+// CHECK082-NOT:      -mcpu=
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -209,7 +209,9 @@
   bool IncStartFiles = !Args.hasArg(options::OPT_nostartfiles);
   bool IncDefLibs = !Args.hasArg(options::OPT_nodefaultlibs);
   bool UseG0 = false;
+  bool UseLLD = Args.getLastArgValue(options::OPT_fuse_ld_EQ).startswith("lld");
   bool UseShared = IsShared && !IsStatic;
+  StringRef CpuVer = toolchains::HexagonToolChain::GetTargetCPUVersion(Args);
 
   //----------------------------------------------------------------------------
   // Silence warnings for various options
@@ -232,9 +234,10 @@
   for (const auto &Opt : HTC.ExtraOpts)
     CmdArgs.push_back(Opt.c_str());
 
-  CmdArgs.push_back("-march=hexagon");
-  StringRef CpuVer = toolchains::HexagonToolChain::GetTargetCPUVersion(Args);
-  CmdArgs.push_back(Args.MakeArgString("-mcpu=hexagon" + CpuVer));
+  if (!UseLLD) {
+    CmdArgs.push_back("-march=hexagon");
+    CmdArgs.push_back(Args.MakeArgString("-mcpu=hexagon" + CpuVer));
+  }
 
   if (IsShared) {
     CmdArgs.push_back("-shared");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70919.232374.patch
Type: text/x-patch
Size: 2502 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191205/b2ca2383/attachment-0001.bin>


More information about the cfe-commits mailing list