[PATCH u-boot v4 21/36] ARM: make gd a function call for LTO and set via set_gd()

Simon Glass sjg at chromium.org
Thu May 20 19:52:01 CEST 2021


On Thu, 20 May 2021 at 05:25, Marek Behún <marek.behun at nic.cz> wrote:
>
> On ARM, the gd pointer is stored in registers r9 / x18. For this the
> -ffixed-r9 / -ffixed-x18 flag is used when compiling, but using global
> register variables causes errors when building with LTO, and these
> errors are very difficult to overcome.
>
> Richard Biener says [1]:
>   Note that global register vars shouldn't be used with LTO and if they
>   are restricted to just a few compilation units the recommended fix is
>   to build those CUs without -flto.
>
> We cannot do this for U-Boot since all CUs use -ffixed-reg flag.
>
> It seems that with LTO we could in fact store the gd pointer differently
> and gain performance or size benefit by allowing the compiler to use
> r9 / x18. But this would need more work.
>
> So for now, when building with LTO, go the clang way, and instead of
> declaring gd a global register variable, we make it a function call via
> macro.
>
> [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68384
>
> Signed-off-by: Marek Behún <marek.behun at nic.cz>
> ---
>  arch/arm/cpu/arm926ejs/mxs/spl_boot.c |  2 +-
>  arch/arm/include/asm/global_data.h    |  2 +-
>  arch/arm/mach-exynos/spl_boot.c       |  2 +-
>  arch/arm/mach-imx/imx8m/soc.c         |  2 +-
>  arch/arm/mach-imx/spl_imx_romapi.c    | 16 ++++++++--------
>  5 files changed, 12 insertions(+), 12 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>


More information about the U-Boot mailing list