[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
Thu Apr 15 20:00:42 PDT 2021
arcbbb created this revision.
arcbbb added reviewers: asb, craig.topper, frasercrmck, rogfer01, jrtc27, mgrang.
Herald added subscribers: vkmr, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, abidh, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar.
arcbbb requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.
In baremetal::Linker::ConstructJob, LinkerInput is handled prior to T_Group options,
but on the other side in RISCV::Linker::ConstructJob, it is opposite.
We want it to be consistent whether users are using RISCV::Linker or baremetal::Linker.
Repository:
rG LLVM Github Monorepo
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,5 @@
+// Make sure --defsym takes precedence over T_Group options
+// 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.337968.patch
Type: text/x-patch
Size: 1277 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210416/a5e130d8/attachment.bin>
More information about the cfe-commits
mailing list