[RFC PATCH 2/9] linker_lists: Do not set "unused" attribute
Tom Rini
trini at konsulko.com
Mon May 25 17:46:23 CEST 2026
On Mon, May 25, 2026 at 09:33:24AM -0600, Simon Glass wrote:
> Hi Tom,
>
> On Mon, 25 May 2026 at 09:22, Tom Rini <trini at konsulko.com> wrote:
> >
> > On Mon, May 25, 2026 at 09:02:02AM -0600, Simon Glass wrote:
> > > Hi,
> > >
> > > On 2026-05-22T21:27:48, Rasmus Villemoes <ravi at prevas.dk> wrote:
> > > > linker_lists: Do not set 'unused' attribute
> > > >
> > > > Whenever we declare something to be in a linker list, we want it to be
> > > > included. This is why all of our linker scripts have a line similar to:
> > > > KEEP(*(SORT(__u_boot_list*)));
> > > > to ensure that any linker list found in any of the archives we are
> > > > linking together makes it to the final object. Remove the places where
> > > > we set an attribute saying that it is unused, or maybe_unused.
> > > >
> > > > Signed-off-by: Tom Rini <trini at konsulko.com>
> > > > Signed-off-by: Rasmus Villemoes <ravi at prevas.dk>
> > > >
> > > > include/linker_lists.h | 9 +++------
> > > > 1 file changed, 3 insertions(+), 6 deletions(-)
> > >
> > > > diff --git a/include/linker_lists.h b/include/linker_lists.h
> > > > @@ -69,7 +69,6 @@
> > > > */
> > > > #define ll_entry_declare(_type, _name, _list) \
> > > > _type _u_boot_list_2_##_list##_2_##_name __aligned(4) \
> > > > - __attribute__((unused)) \
> > > > __section('__u_boot_list_2_'#_list'_2_'#_name)
> > >
> > > The commit message conflates two unrelated things:
> > > __attribute__((unused)) and __maybe_unused are purely warning
> > > suppressions; they do not affect whether the symbol is emitted, kept
> > > by the linker, or seen by LTO. The thing that prevents removal is
> > > __used (and at the linker stage, KEEP()).
> > >
> > > The real reason removal is safe is that none of these declarations
> > > would have warned anyway - ll_entry_declare()/ll_entry_declare_list()
> > > produce non-static externals (no -Wunused-variable for those),
> > > ll_entry_start()/ll_entry_end() take the address of start[]/end[]
> > > inside the same statement expression, and the symbols from
> > > ll_start_decl()/ll_end_decl() are referenced by the caller (cmd_ut.c
> > > is currently the only one). Please reword the commit message along
> > > those lines; the KEEP() stuff belongs more naturally with patch 3.
> >
> > I don't think your analysis is correct. They are not unrelated things,
> > they're very much related and were really incorrect at introduction a
> > decade+ ago (and pre LTO) but I don't think it was worth adding a Fixes
> > tag.
>
> I mean that the compiler will warn if you declare a static symbol but
> then don't use it in the same TU (hence the need for 'unused').
> warning != inclusion/removal. I haven't quite figured out whether
> those warnings have gone away, or something else has changed. It will
> be easier to see when I can build this branch.
It has always been incorrect to have these, and there's no real value in
having more commits removing incorrect code.
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20260525/016d6547/attachment.sig>
More information about the U-Boot
mailing list