All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Simon Glass <sjg@chromium.org>
Cc: "U-Boot Mailing List" <u-boot@lists.denx.de>,
	"Michal Simek" <michal.simek@xilinx.com>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Tom Rini" <trini@konsulko.com>,
	"Daniel Schwierzeck" <daniel.schwierzeck@gmail.com>,
	"Steffen Jaeckel" <jaeckel-floss@eyet-services.de>,
	"Marek Behún" <marek.behun@nic.cz>,
	"Lukas Auer" <lukas.auer@aisec.fraunhofer.de>,
	"Dennis Gilmore" <dennis@ausil.us>,
	"Masahiro Yamada" <yamada.masahiro@socionext.com>
Subject: Re: [PATCH v2 02/41] Makefile: Allow LTO to be disabled for a build
Date: Wed, 27 Oct 2021 11:50:35 +0300	[thread overview]
Message-ID: <CAC_iWjLJHi_Lhzd8U5omwDVSy8rEujZ0A7oZQsQb-3bqYDP3bA@mail.gmail.com> (raw)
In-Reply-To: <20211023232635.9195-3-sjg@chromium.org>

Hi Simon

How does this patch related to the standard boot series? Shouldn't
this be a completely separate patch?

Thanks
/Ilias

On Sun, 24 Oct 2021 at 02:26, Simon Glass <sjg@chromium.org> wrote:
>
> LTO (Link-Time Optimisation) is an very useful feature which can
> significantly reduce the size of U-Boot binaries. So far it has been
> made available for selected ARM boards and sandbox.
>
> However, incremental builds are much slower when LTO is used. For example,
> an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7
> seconds with LTO enabled.
>
> Add a LTO_BUILD=n parameter to the build, so it can be disabled during
> development if needed, for faster builds.
>
> Add some documentation about LTO while we are here.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> (no changes since v1)
>
>  Makefile                           | 18 +++++++++++++-----
>  arch/arm/config.mk                 |  4 ++--
>  arch/arm/include/asm/global_data.h |  2 +-
>  doc/build/gcc.rst                  | 17 +++++++++++++++++
>  4 files changed, 33 insertions(+), 8 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index b79b2319ff6..7057723e046 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -434,6 +434,9 @@ KBUILD_CFLAGS       += -fshort-wchar -fno-strict-aliasing
>  KBUILD_AFLAGS   := -D__ASSEMBLY__
>  KBUILD_LDFLAGS  :=
>
> +# Set this to "n" use of LTO for this build, e.g. LTO_BUILD=n
> +LTO_BUILD      ?= y
> +
>  ifeq ($(cc-name),clang)
>  ifneq ($(CROSS_COMPILE),)
>  CLANG_TARGET   := --target=$(notdir $(CROSS_COMPILE:%-=%))
> @@ -641,6 +644,11 @@ export CFLAGS_EFI  # Compiler flags to add when building EFI app
>  export CFLAGS_NON_EFI  # Compiler flags to remove when building EFI app
>  export EFI_TARGET      # binutils target if EFI is natively supported
>
> +export LTO_ENABLE
> +
> +# This is y if LTO is enabled for this build
> +LTO_ENABLE=$(if $(CONFIG_LTO),$(LTO_BUILD),)
> +
>  # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
>  # that (or fail if absent).  Otherwise, search for a linker script in a
>  # standard location.
> @@ -688,16 +696,16 @@ endif
>  LTO_CFLAGS :=
>  LTO_FINAL_LDFLAGS :=
>  export LTO_CFLAGS LTO_FINAL_LDFLAGS
> -ifdef CONFIG_LTO
> +ifeq ($(LTO_ENABLE),y)
>         ifeq ($(cc-name),clang)
> -               LTO_CFLAGS              += -flto
> +               LTO_CFLAGS              += -DLTO_ENABLE -flto
>                 LTO_FINAL_LDFLAGS       += -flto
>
>                 AR                      = $(shell $(CC) -print-prog-name=llvm-ar)
>                 NM                      = $(shell $(CC) -print-prog-name=llvm-nm)
>         else
>                 NPROC                   := $(shell nproc 2>/dev/null || echo 1)
> -               LTO_CFLAGS              += -flto=$(NPROC)
> +               LTO_CFLAGS              += -DLTO_ENABLE -flto=$(NPROC)
>                 LTO_FINAL_LDFLAGS       += -fuse-linker-plugin -flto=$(NPROC)
>
>                 # use plugin aware tools
> @@ -1717,7 +1725,7 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(ARCH)/Makefile.postlink)
>
>  # Generate linker list symbols references to force compiler to not optimize
>  # them away when compiling with LTO
> -ifdef CONFIG_LTO
> +ifeq ($(LTO_ENABLE),y)
>  u-boot-keep-syms-lto := keep-syms-lto.o
>  u-boot-keep-syms-lto_c := $(patsubst %.o,%.c,$(u-boot-keep-syms-lto))
>
> @@ -1739,7 +1747,7 @@ endif
>
>  # Rule to link u-boot
>  # May be overridden by arch/$(ARCH)/config.mk
> -ifdef CONFIG_LTO
> +ifeq ($(LTO_ENABLE),y)
>  quiet_cmd_u-boot__ ?= LTO     $@
>        cmd_u-boot__ ?=                                                          \
>                 $(CC) -nostdlib -nostartfiles                                   \
> diff --git a/arch/arm/config.mk b/arch/arm/config.mk
> index b107b1af27a..065dbec4064 100644
> --- a/arch/arm/config.mk
> +++ b/arch/arm/config.mk
> @@ -15,11 +15,11 @@ CFLAGS_NON_EFI := -fno-pic -ffixed-r9 -ffunction-sections -fdata-sections \
>                   -fstack-protector-strong
>  CFLAGS_EFI := -fpic -fshort-wchar
>
> -ifneq ($(CONFIG_LTO)$(CONFIG_USE_PRIVATE_LIBGCC),yy)
> +ifneq ($(LTO_ENABLE)$(CONFIG_USE_PRIVATE_LIBGCC),yy)
>  LDFLAGS_FINAL += --gc-sections
>  endif
>
> -ifndef CONFIG_LTO
> +ifneq ($(LTO_ENABLE),y)
>  PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
>  endif
>
> diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h
> index 085e12b5d4d..b255b195aa0 100644
> --- a/arch/arm/include/asm/global_data.h
> +++ b/arch/arm/include/asm/global_data.h
> @@ -98,7 +98,7 @@ struct arch_global_data {
>
>  #include <asm-generic/global_data.h>
>
> -#if defined(__clang__) || defined(CONFIG_LTO)
> +#if defined(__clang__) || defined(LTO_ENABLE)
>
>  #define DECLARE_GLOBAL_DATA_PTR
>  #define gd     get_gd()
> diff --git a/doc/build/gcc.rst b/doc/build/gcc.rst
> index cdd79700326..136c318727d 100644
> --- a/doc/build/gcc.rst
> +++ b/doc/build/gcc.rst
> @@ -141,6 +141,23 @@ of dtc is new enough. It also makes sure that pylibfdt is present, if needed
>  Note that the :doc:`tools` are always built with the included version of libfdt
>  so it is not possible to build U-Boot tools with a system libfdt, at present.
>
> +Link-time optimisation (LTO)
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +U-Boot supports link-time optimisation which can reduce the size of the final
> +U-Boot binaries, particularly with SPL.
> +
> +At present this can be enabled by ARM boards by adding `CONFIG_LTO=y` into the
> +defconfig file. Other architectures are not supported. LTO is enabled by default
> +for sandbox.
> +
> +This does incur a link-time penalty of several seconds. For faster incremental
> +builds during development, you can disable it by setting `LTO_BUILD` to `n`.
> +
> +.. code-block:: bash
> +
> +    LTO_BUILD=n make
> +
>  Other build targets
>  ~~~~~~~~~~~~~~~~~~~
>
> --
> 2.33.0.1079.g6e70778dc9-goog
>

  reply	other threads:[~2021-10-27  8:51 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAPnjgZ2TFOQGoQ1+Vt6LRMk+nULj9joS0C7fMMiXfg7JNien7g@mail.gmail.com>
2021-10-23 23:25 ` [PATCH v2 00/41] Initial implementation of standard boot Simon Glass
2021-10-23 23:25   ` [PATCH v2 01/41] lib: Add a way to find the postiion of a trailing number Simon Glass
2021-10-27 12:13     ` Heinrich Schuchardt
2021-10-23 23:25   ` [PATCH v2 02/41] Makefile: Allow LTO to be disabled for a build Simon Glass
2021-10-27  8:50     ` Ilias Apalodimas [this message]
2021-10-27 12:21       ` Heinrich Schuchardt
2021-10-27 13:13         ` Tom Rini
2021-10-31 23:46           ` Simon Glass
2021-11-01 21:58             ` Tom Rini
2021-11-04  2:49               ` Simon Glass
2021-11-04 14:55                 ` Tom Rini
2021-11-04 15:12                   ` Simon Glass
2021-11-04 16:44                     ` Tom Rini
2021-10-31 23:45         ` Simon Glass
2021-10-23 23:25   ` [PATCH v2 03/41] test/py: Allow passing input to a program Simon Glass
2021-10-23 23:25   ` [PATCH v2 04/41] sandbox: Support unmapping a file Simon Glass
2021-10-23 23:25   ` [PATCH v2 05/41] sandbox: mmc: Support a backing file Simon Glass
2021-10-23 23:26   ` [PATCH v2 06/41] mmc: Allow for children other than the block device Simon Glass
2021-10-23 23:26   ` [PATCH v2 07/41] mbr: Correct verification check Simon Glass
2021-10-27  7:41     ` Ilias Apalodimas
2021-11-24 22:22     ` Simon Glass
2021-10-23 23:26   ` [PATCH v2 08/41] disk: part_dos: Fix a NULL pointer error Simon Glass
2021-10-23 23:26   ` [PATCH v2 09/41] common: Allow a smaller console-recording pre-reloc Simon Glass
2021-10-23 23:26   ` [PATCH v2 10/41] dm: core: Add tests for stringlist functions Simon Glass
2021-10-23 23:26   ` [PATCH v2 11/41] dm: core: Fix handling of uclass pre_unbind method Simon Glass
2021-10-23 23:26   ` [PATCH v2 12/41] dm: core: Fix up string-function documentation Simon Glass
2021-10-23 23:26   ` [PATCH v2 13/41] dm: core: Add a way to obtain a string list Simon Glass
2021-10-26 19:20     ` Ilias Apalodimas
2021-11-24 22:22       ` Simon Glass
2021-11-24 22:23       ` Simon Glass
2021-10-23 23:26   ` [PATCH v2 14/41] dm: core: Allow finding children / uclasses by partial name Simon Glass
2021-10-23 23:26   ` [PATCH v2 15/41] dm: core: Add a way to count the devices in a uclass Simon Glass
2021-10-23 23:26   ` [PATCH v2 16/41] sandbox: Enable HEXDUMP for sandbox_flattree Simon Glass
2021-10-23 23:26   ` [PATCH v2 17/41] test/py: Relax the naming rules for unit tests Simon Glass
2021-10-23 23:26   ` [PATCH v2 18/41] test/py: Raise a ValueError if a command fails Simon Glass
2021-10-23 23:26   ` [PATCH v2 19/41] bootstd: Add the concept of a bootflow Simon Glass
2021-10-23 23:26   ` [PATCH v2 20/41] bootstd: Add the bootstd uclass and core implementation Simon Glass
2021-10-23 23:26   ` [PATCH v2 21/41] bootstd: Add the bootdev uclass Simon Glass
2021-10-23 23:26   ` [PATCH v2 22/41] bootstd: Add the bootmeth uclass and helpers Simon Glass
2021-10-23 23:26   ` [PATCH v2 23/41] bootstd: Add support for bootflows Simon Glass
2021-10-27  7:37     ` Ilias Apalodimas
2022-03-12  2:24       ` Simon Glass
2021-10-23 23:26   ` [PATCH v2 24/41] bootstd: Add a bootdev command Simon Glass
2021-10-23 23:26   ` [PATCH v2 25/41] bootstd: Add a bootflow ommand Simon Glass
2021-10-23 23:26   ` [PATCH v2 26/41] bootstd: Add a bootmeth command Simon Glass
2021-10-23 23:26   ` [PATCH v2 27/41] bootstd: Add an implementation of distro boot Simon Glass
2021-10-23 23:26   ` [PATCH v2 28/41] bootstd: mmc: Add a bootdev driver Simon Glass
2021-10-23 23:26   ` [PATCH v2 29/41] bootstd: ethernet: " Simon Glass
2021-10-23 23:26   ` [PATCH v2 30/41] bootstd: Add an implementation of distro PXE boot Simon Glass
2021-10-23 23:26   ` [PATCH v2 31/41] bootstd: Add an implementation of EFI boot Simon Glass
2021-10-27  8:35     ` Ilias Apalodimas
2021-10-27 14:09       ` Simon Glass
2021-10-27 14:47         ` Ilias Apalodimas
2021-10-27 18:34           ` Simon Glass
2021-10-29  5:45             ` Ilias Apalodimas
2021-10-29 12:39               ` Tom Rini
2021-10-29 13:42                 ` Ilias Apalodimas
2021-10-29 14:03                   ` AKASHI Takahiro
2021-10-29 14:39                     ` Ilias Apalodimas
2021-10-29 16:37                   ` Mark Kettenis
2021-10-29 17:08                     ` Ilias Apalodimas
2021-10-27 11:57     ` Heinrich Schuchardt
2021-10-27 14:08       ` Simon Glass
2021-10-23 23:26   ` [PATCH v2 32/41] bootstd: Add a system bootdev for strange boot methods Simon Glass
2021-10-23 23:26   ` [PATCH v2 33/41] bootstd: Add an implementation of EFI bootmgr Simon Glass
2021-10-23 23:26   ` [PATCH v2 34/41] bootstd: Add a sandbox bootmeth driver Simon Glass
2021-10-23 23:26   ` [PATCH v2 35/41] bootstd: usb: Add a bootdev driver Simon Glass
2021-10-23 23:26   ` [PATCH v2 36/41] test: fastboot: Avoid using mmc1 Simon Glass
2021-10-23 23:26   ` [PATCH v2 37/41] test: dm: Restart USB before assuming it is stopped Simon Glass
2021-10-23 23:26   ` [PATCH v2 38/41] bootstd: Add tests for bootstd including all uclasses Simon Glass
2021-10-23 23:26   ` [PATCH v2 39/41] bootstd: Add setup for the bootflow tests Simon Glass
2021-10-23 23:26   ` [PATCH v2 40/41] bootstd: doc: Add documentation Simon Glass
2021-10-23 23:26   ` [PATCH v2 41/41] RFC: Switch rpi over to use bootstd Simon Glass
2021-10-28 15:13     ` Tom Rini
2021-10-28 16:43     ` Tom Rini
2021-10-28 17:16       ` Simon Glass
2021-10-28 17:29         ` Tom Rini
2021-10-23 23:27   ` [PATCH v2 00/41] Initial implementation of standard boot Simon Glass
2021-10-27 11:38   ` Heinrich Schuchardt
2021-10-27 14:11     ` Simon Glass
2021-10-28 17:37       ` Peter Robinson
2021-10-28 17:47         ` Tom Rini
2021-10-28 17:50           ` Peter Robinson
2021-10-28 17:59             ` Tom Rini
2021-10-28 18:09               ` Heinrich Schuchardt
2021-10-28 18:13                 ` Tom Rini
2021-10-28 18:17               ` François Ozog
2021-10-28 18:27                 ` Tom Rini
2021-10-28 18:28                   ` François Ozog
2021-10-28 21:40           ` Mark Kettenis
2021-10-27 15:20     ` François Ozog
2021-10-27 18:33     ` Simon Glass
2021-10-28 16:27   ` Tom Rini
2021-10-28 17:29     ` Simon Glass
2021-10-28 17:52       ` Tom Rini
2021-10-28 18:13         ` Simon Glass
2021-10-28 18:36           ` Tom Rini
2021-10-28 18:48             ` Simon Glass
2021-10-28 19:19               ` Tom Rini
2021-10-28 22:22                 ` Simon Glass
2021-10-28 22:50                   ` Tom Rini
2021-10-29  1:13                     ` Simon Glass
2021-11-24 22:22   ` [PATCH v2 17/41] test/py: Relax the naming rules for unit tests Simon Glass
2021-11-24 22:22   ` [PATCH v2 18/41] test/py: Raise a ValueError if a command fails Simon Glass
2021-11-24 22:22   ` [PATCH v2 16/41] sandbox: Enable HEXDUMP for sandbox_flattree Simon Glass
2021-11-24 22:22   ` [PATCH v2 15/41] dm: core: Add a way to count the devices in a uclass Simon Glass
2021-11-24 22:22   ` [PATCH v2 14/41] dm: core: Allow finding children / uclasses by partial name Simon Glass
2021-11-24 22:22   ` [PATCH v2 11/41] dm: core: Fix handling of uclass pre_unbind method Simon Glass
2021-11-24 22:22   ` [PATCH v2 12/41] dm: core: Fix up string-function documentation Simon Glass
2021-11-24 22:22   ` [PATCH v2 08/41] disk: part_dos: Fix a NULL pointer error Simon Glass
2021-11-24 22:22   ` [PATCH v2 09/41] common: Allow a smaller console-recording pre-reloc Simon Glass
2021-11-24 22:22   ` [PATCH v2 10/41] dm: core: Add tests for stringlist functions Simon Glass
2021-11-24 22:22   ` [PATCH v2 06/41] mmc: Allow for children other than the block device Simon Glass
2021-11-24 22:22   ` [PATCH v2 05/41] sandbox: mmc: Support a backing file Simon Glass
2021-11-24 22:22   ` [PATCH v2 04/41] sandbox: Support unmapping a file Simon Glass
2021-11-24 22:22   ` [PATCH v2 03/41] test/py: Allow passing input to a program Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAC_iWjLJHi_Lhzd8U5omwDVSy8rEujZ0A7oZQsQb-3bqYDP3bA@mail.gmail.com \
    --to=ilias.apalodimas@linaro.org \
    --cc=daniel.schwierzeck@gmail.com \
    --cc=dennis@ausil.us \
    --cc=jaeckel-floss@eyet-services.de \
    --cc=lukas.auer@aisec.fraunhofer.de \
    --cc=marek.behun@nic.cz \
    --cc=michal.simek@xilinx.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.