[PATCH] D100615: [RISCV][Driver] Make the ordering of CmdArgs consistent between RISCV::Linker and baremetal::Linker

ShihPo Hung via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 16 00:04:15 PDT 2021


arcbbb updated this revision to Diff 338004.
arcbbb added a comment.

Addressed @MaskRay 's comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100615

Files:
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/test/Driver/riscv-args.c


Index: clang/test/Driver/riscv-args.c
===================================================================
--- /dev/null
+++ clang/test/Driver/riscv-args.c
@@ -0,0 +1,7 @@
+// Check the arguments are correctly passed
+
+// Make sure -T is the last with gcc-toolchain option
+// RUN: %clang -### -target riscv32 \
+// RUN:   --gcc-toolchain= -Xlinker --defsym=ABC=10 -T a.lds %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LD %s
+// CHECK-LD: {{.*}} "--defsym=ABC=10" {{.*}} "-T" "a.lds"
Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===================================================================
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -181,14 +181,14 @@
     CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
   }
 
+  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
+
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs,
                   {options::OPT_T_Group, options::OPT_e, options::OPT_s,
                    options::OPT_t, options::OPT_Z_Flag, options::OPT_r});
 
-  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
-
   // TODO: add C++ includes and libs if compiling C++.
 
   if (!Args.hasArg(options::OPT_nostdlib) &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100615.338004.patch
Type: text/x-patch
Size: 1318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210416/7a316d27/attachment.bin>


More information about the cfe-commits mailing list