[PATCH] D142595: [Driver][AVR] Don't emit default '-Tdata' when '-T' is specified

Ben Shi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 30 18:43:21 PST 2023


benshi001 added a comment.

In D142595#4091176 <https://reviews.llvm.org/D142595#4091176>, @MaskRay wrote:

> In D142595#4089391 <https://reviews.llvm.org/D142595#4089391>, @benshi001 wrote:
>
>> In D142595#4089124 <https://reviews.llvm.org/D142595#4089124>, @MaskRay wrote:
>>
>>> OK. If this doesn't add `-Tdata=` driver options, I'm fine with it.
>>> But why is default `-Tdata` added in the first place?
>>>
>>> Most linker scripts are added as `-Wl,-T,a.lds` (`-Wl,` values are opaque to the driver), so the driver cannot really know whether a linker script is used.
>>
>> So how about change to
>>
>> 1. move the default `-Tdata` to a later position.
>> 2. clang driver just checks `-T` but omits `-Wl`, this can not 100% fix the issue, but at least improve it. Current most users are from avr-gcc, who have get used to `-T`.
>>
>> A good solution is using default linker script provided by the avr-libc, which will be overwritten by user's explicit specification.
>>
>> I will do that solution in a different patch, it needs more extra work. Currently we just guarantee avr-gcc users's `-T` option will not be broken.
>
> I think checking whether there is a linker script in any way is not a right solution.
> GNU ld supports `-dT` which lld doesn't support. A linker script can be used without a -T/-dT option as well (it gets appended).
> Any chance to remove `-Tdata=` and require the user to specify a `-Tdata=`?

@MaskRay

Newer avr-gcc's solution is adding a default linker script (provided by binutils, locates at $binutils-gdb/ld/scripttempl/avr.sc). And user can specifies his own one, which will win against the default one.

How do you think about this solution ?


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

https://reviews.llvm.org/D142595



More information about the cfe-commits mailing list