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 <[email protected]> wrote:
> >
> > On Mon, May 25, 2026 at 09:02:02AM -0600, Simon Glass wrote:
> > > Hi,
> > >
> > > On 2026-05-22T21:27:48, Rasmus Villemoes <[email protected]> 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 <[email protected]>
> > > > Signed-off-by: Rasmus Villemoes <[email protected]>
> > > >
> > > > 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

Attachment: signature.asc
Description: PGP signature

Reply via email to