[PATCH u-boot 16/39] build: use thin archives instead of incremental linking

Bin Meng bmeng.cn at gmail.com
Mon Mar 8 12:41:13 CET 2021


On Mon, Mar 8, 2021 at 7:00 PM Pali Rohár <pali at kernel.org> wrote:
>
> On Monday 08 March 2021 18:44:58 Bin Meng wrote:
> > On Mon, Mar 8, 2021 at 6:11 PM Marek Behun <marek.behun at nic.cz> wrote:
> > >
> > > On Mon, 8 Mar 2021 17:16:03 +0800
> > > Bin Meng <bmeng.cn at gmail.com> wrote:
> > >
> > > > Hi Marek,
> > > >
> > > > On Sun, Mar 7, 2021 at 12:26 PM Marek Behún <marek.behun at nic.cz> wrote:
> > > > >
> > > > > Currently we use incremental linking (ld -r) to link several object
> > > > > files from one directory into one built-in.o object file containing the
> > > > > linked code from that directory (and its subdirectories).
> > > > >
> > > > > Linux has, some time ago, moved to thin archives instead.
> > > > >
> > > > > Thin archives are archives (.a) that do not really contain the object
> > > > > files, only references to them.
> > > > >
> > > > > Using thin archives instead of incremental linking
> > > > > - saves disk space
> > > > > - apparently works better with dead code elimination
> > > > > - makes things easier for LTO
> > > > >
> > > > > The third point is the important one for us. With incremental linking
> > > > > there are several options how to do LTO, and that would unnecessarily
> > > > > complicate things.
> > > > >
> > > > > On the other hand, by using thin archives we can make (via the
> > > > > --whole-archive use flag) the final linking behave as if we passed all
> > > > > the object files from the archives to the linking program as arguments.
> > > >
> > > > I don't think --whole-archive is required for LTO to work.
> > >
> > > It is. Linking fails if it is not used, for example for
> > > nokia_rx51_defconfig.
> >
> > Could you investigate why? Is this due to missing marking some
> > variables/functions as __used?
>
> See email Message-ID: <20210306210045.pn3vzuarh23poxuv at pali> for details.
>

Looking at <20210306210045.pn3vzuarh23poxuv at pali>, the error you
reported seemed to be caused by not passing P to ar, as Marek replied
to you.

Regards,
Bin


More information about the U-Boot mailing list