Skip to contentSkip to conversation

boot/uboot: fix build with host-gcc 10+

Buildroot Peter Korsgaard 1 participant 1 message Feb 27, 2022

lore
Share & tools
lore
#0 lore raw

commit: https://git.buildroot.net/buildroot/commit/?id=701ce0ad69580854076df85eaa1b8db3da51e20f
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2021.11.x

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.

Cc Thomas Petazzoni <[email protected]>
Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>
(cherry picked from commit 3b3859cc7df8edce10e5b4dad9005bd05342c8c3)
---
 boot/uboot/uboot.mk | 7 +++++++
 1 file changed, 7 insertions(+)
boot/uboot/uboot.mk +7 -0
index 9661f901ea..0765e66c4a 100644
@@ -238,6 +238,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)

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot