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) &&
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) &&
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits