Skip to content

Commit 27edaee

Browse files
committed
[RISCV][Driver] Make the ordering of CmdArgs consistent between RISCV::Linker and baremetal::Linker
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. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D100615
1 parent 8969762 commit 27edaee

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

clang/lib/Driver/ToolChains/RISCVToolchain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,14 @@ void RISCV::Linker::ConstructJob(Compilation &C, const JobAction &JA,
181181
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
182182
}
183183

184+
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
185+
184186
Args.AddAllArgs(CmdArgs, options::OPT_L);
185187
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
186188
Args.AddAllArgs(CmdArgs,
187189
{options::OPT_T_Group, options::OPT_e, options::OPT_s,
188190
options::OPT_t, options::OPT_Z_Flag, options::OPT_r});
189191

190-
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
191-
192192
// TODO: add C++ includes and libs if compiling C++.
193193

194194
if (!Args.hasArg(options::OPT_nostdlib) &&

clang/test/Driver/riscv-args.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Check the arguments are correctly passed
2+
3+
// Make sure -T is the last with gcc-toolchain option
4+
// RUN: %clang -### -target riscv32 \
5+
// RUN: --gcc-toolchain= -Xlinker --defsym=FOO=10 -T a.lds %s 2>&1 \
6+
// RUN: | FileCheck -check-prefix=CHECK-LD %s
7+
// CHECK-LD: {{.*}} "--defsym=FOO=10" {{.*}} "-T" "a.lds"

0 commit comments

Comments
 (0)