[Buildroot] [PATCH 1/2 v2] boot/uboot: fix build with host-gcc 10+

Giulio Benetti giulio.benetti at benettiengineering.com
Fri Feb 4 10:40:49 UTC 2022


Hi Yann,

On 31/01/22 22:38, Yann E. MORIN wrote:
> Some older versions of U-Boot, or custom versions (like forks for some
> boards), fail to build with host-gcc 10+, because of redefined symbols:
> 
>        HOSTLD  scripts/dtc/dtc
>      /usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition
>      of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
>      collect2: error: ld returned 1 exit status
>      make[4]: *** [scripts/Makefile.host:106: scripts/dtc/dtc] E
> 
> Since this has been fixed in recent-ish versions, we can't use an
> unconditionaly patch, so we must have a conditional patch. However, a
> patch may not always apply to arbitrary U-Boot versions or forks.
> 
> Upstream just dropped that line altogether:
>      https://source.denx.de/u-boot/u-boot/-/commit/018921ee79d3f30893614b3b2b63b588d8544f73
> 
> So, we use a little sed-grep combo to do the exact same change.
> 
> Signed-off-by: Yann E. MORIN <yann.morin.1998 at free.fr>
> Cc: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
> Cc: Arnout Vandecappelle (Essensium/Mind) <arnout at mind.be>

I've extensively tested this patch while fixing Gitlab-CI build failures 
and here there is the actual situation:
https://paste.debian.net/1229530/
I've built successfully circa 20-25 cases where the problem didn't arise 
and also a couple where the problem arised.

So:
Reviewed-by: Giulio Benetti <giulio.benetti at benettiengineering.com>
Tested-by: Giulio Benetti <giulio.benetti at benettiengineering.com>

Thank you!
Best regards
-- 
Giulio Benetti
Benetti Engineering sas

> 
> ---
> Changes v1 -> v2:
>    - don't fail if no file to fix: use 'grep -Z |xargs -0 -r' (Arnout)
> ---
>   boot/uboot/uboot.mk | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
> index 574fc7089a..21db1d9d60 100644
> --- a/boot/uboot/uboot.mk
> +++ b/boot/uboot/uboot.mk
> @@ -244,6 +244,13 @@ endef
>   UBOOT_POST_EXTRACT_HOOKS += UBOOT_COPY_OLD_LICENSE_FILE
>   UBOOT_POST_RSYNC_HOOKS += UBOOT_COPY_OLD_LICENSE_FILE
>   
> +# Older versions break on gcc 10+ because of redefined symbols
> +define UBOOT_DROP_YYLLOC
> +	$(Q)grep -Z -l -r -E '^YYLTYPE yylloc;$$' $(@D) \
> +	|xargs -0 -r $(SED) '/^YYLTYPE yylloc;$$/d'
> +endef
> +UBOOT_POST_PATCH_HOOKS += UBOOT_DROP_YYLLOC
> +
>   ifneq ($(ARCH_XTENSA_OVERLAY_FILE),)
>   define UBOOT_XTENSA_OVERLAY_EXTRACT
>   	$(call arch-xtensa-overlay-extract,$(@D),u-boot)




More information about the buildroot mailing list