[PATCH u-boot 17/39] build: support building with Link Time Optimizations

Marek Behun marek.behun at nic.cz
Thu Mar 11 13:45:49 CET 2021


On Tue, 9 Mar 2021 21:30:26 +0800
Bin Meng <bmeng.cn at gmail.com> wrote:

> > +config LTO
> > +       bool "Enable Link Time Optimizations"
> > +       depends on ARCH_SUPPORTS_LTO
> > +       default n  
> 
> nits: this line is not needed as the default value is n if omitted

This is for consistency. The other options in this file also use
"default n"

> > +ifdef CONFIG_LTO
> > +       LTO_CFLAGS                      := -flto
> > +       LTO_FINAL_LDFLAGS               := -fwhole-program  
> 
> This one should not be necessary per my read of the GCC doc. Also in
> your patch, it is only used in the SPL build.

I shall do some tests.

> > +ifdef CONFIG_LTO
> > +quiet_cmd_u-boot__ ?= LTO     $@
> > +      cmd_u-boot__ ?=                                                          \
> > +               $(CC) -nostdlib -nostartfiles                                   \
> > +               $(LTO_FINAL_CFLAGS) $(c_flags)                                  \  
> 
> LTO_FINAL_CFLAGS is not defined anywhere. I guess you wanted to use
> LTO_FINAL_LDFLAGS?

THX, I forgot to change it here. We will see if this variable is needed
(since it only contains -fwhole-program, which may be dropped)
> 
> > +               $(KBUILD_LDFLAGS:%=-Wl,%) $(LDFLAGS_u-boot:%=-Wl,%) -o $@       \
> > +               -T u-boot.lds $(u-boot-init)                                    \
> > +               -Wl,--start-group -Wl,--whole-archive                           \  
> 
> --start-group should be dropped

Will test


More information about the U-Boot mailing list