This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by arcbbb on Apr 15 2021, 8:00 PM.

Details

Summary

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.

Diff Detail

Event Timeline

arcbbb created this revision.Apr 15 2021, 8:00 PM
arcbbb requested review of this revision.Apr 15 2021, 8:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 15 2021, 8:00 PM

Few more word for this issue, the option order is matter for linker both for GNU ld and lld, in the test @arcbbb provided, ABC will treat as undefined in a.lds if the order is wrong.

MaskRay accepted this revision.Apr 15 2021, 9:03 PM

LG.

A better test should have a few more stuff, see Xlinker-args.c
Instead of saying --defsym takes precedence over T_Group options, you can say that -T is the last.

Few more word for this issue, the option order is matter for linker both for GNU ld and lld, in the test @arcbbb provided, ABC will treat as undefined in a.lds if the order is wrong.

While GNU people may not like it, I think relying on the order between --defsym and -T is highly problematic: https://sourceware.org/pipermail/libc-alpha/2020-March/111920.html

This revision is now accepted and ready to land.Apr 15 2021, 9:03 PM
This comment was removed by kito-cheng.
arcbbb updated this revision to Diff 338004.Apr 16 2021, 12:04 AM

Addressed @MaskRay 's comment