Skip to contentSkip to conversation

linux|uboot: fix build with host-gcc 10+ for older versions (branch yem/yylloc)

PATCH Applied Yann E. MORIN 5 participants 9 messages Jan 31, 2022 – Feb 27, 2022

lore
Share & tools
lore
#0 lore raw

v2 cover linux|uboot: fix build with host-gcc 10+ for older versions (branch yem/yylloc)

Hello All!

This two-patch series aims at side-stepping the multiple symbol declaration in older Linux and U-Boot, where the infamous yylloc is defined more than once.

Like we have a fix for the perl timeconst issue in linux, do s similar tweak for yylloc in the two packages known to be affected, Linux and U-Boot.

Here is a pipeline with all the defconfig builds:

    https://gitlab.com/ymorin/buildroot/-/pipelines/460207930

There are still some failures, but none relate to the yylloc issue:

- too long build time or not space left on device (I am only using elastic runners)

- defconfig not up-to-date (e.g. using kernel headers version since removed)

- missing host dependencies for kernel (openssl, libelf) or uboot (python)

- another host-gcc 10+ symbol redefinition issue (galileo [0])

- make 4.3 issues. For example: amarula_a64_relic_defconfig
https://gitlab.com/ymorin/buildroot/-/jobs/2035820886

DTC arch/arm/dts/sun50i-a64-amarula-relic.dtb
Error: arch/arm/dts/.sun50i-a64-amarula-relic.dtb.pre.tmp:66.1-10 syntax error FATAL ERROR: Unable to parse input tree

This is caused by make 4.3 that no longer treats '#' as special in macros, and shall no longer be escaped:
https://lwn.net/Articles/810071/

This causes '\#include "something"' to be injected as-is at the end of the temporary DTS, and of course, dtc does not cope nicely with that... [1]

Unfortuantely, I don't think we can do a generic fixup for that one...

- some other issues (e.g. deprecated 'partition-type' for geniamge..)

[0] this was fixed in 2014 in the kernel:
- eeeda4cd06e828b331b15741a204ff9f5874d28d
[1] this was fixed in 2018 in uboot:
- e5e701c2b8470de044c5c71d2a54ecfc72680d59
- 0c544115379ed77c1843a194e26960e5b8f3d369

Changes v1 -> v2:
- don't fail if no file to fix: use 'grep -Z |xargs -0 -r' (Arnout)
- extend cover-ltter with a pipeline reference and analysese of remaining build failures

Regards,
Yann E. MORIN.

----------------------------------------------------------------
Yann E. MORIN (2):
boot/uboot: fix build with host-gcc 10+
linux: fix build with host-gcc 10+

 boot/uboot/uboot.mk | 7 +++++++
 linux/linux.mk      | 7 +++++++
 2 files changed, 14 insertions(+)
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

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

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]>

---
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(+)
boot/uboot/uboot.mk +7 -0
index 574fc7089a..21db1d9d60 100644
@@ -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)
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Reviewed-by Tested-by on v2 1/2
#2 lore raw

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

Hi Yann,

Quoted 13 lines · Yann E. MORIN

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.

Quoted 8 lines

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]>

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:

Thank you!
Best regards

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 16 lines

---
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(+)
boot/uboot/uboot.mk +0 -0
index 574fc7089a..21db1d9d60 100644
@@ -244,6 +244,13 @@ endef
  UBOOT_POST_EXTRACT_HOOKS += UBOOT_COPY_OLD_LICENSE_FILE
  UBOOT_POST_RSYNC_HOOKS += UBOOT_COPY_OLD_LICENSE_FILE
 

boot/uboot/uboot.mk endef · line 256

Quoted 10 lines
boot/uboot/uboot.mk +7 -0
+# 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

#3 lore raw

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

In reply to Yann E. MORIN
Quoted 20 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

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.

Quoted 7 lines
Cc Thomas Petazzoni <[email protected]>
Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>

---
Changes v1 -> v2:
- don't fail if no file to fix: use 'grep -Z |xargs -0 -r' (Arnout)

Committed to 2021.02.x and 2021.11.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

PATCH v2 2/2 linux: fix build with host-gcc 10+

In reply to Yann E. MORIN

Some older versions of linux, 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

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://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e33a814e772cdc36436c8c188d8c42d019fda639

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]>

---
Changes v1 -> v2:
- don't fail if no file to fix: use 'grep -Z |xargs -0 -r' (Arnout)

---
 linux/linux.mk | 7 +++++++
 1 file changed, 7 insertions(+)
linux/linux.mk +7 -0
index dd2eebd446..410b714360 100644
@@ -268,6 +268,13 @@ endef
 
 LINUX_POST_PATCH_HOOKS += LINUX_APPLY_LOCAL_PATCHES
 
+# Older versions break on gcc 10+ because of redefined symbols
+define LINUX_DROP_YYLLOC
+	$(Q)grep -Z -l -r -E '^YYLTYPE yylloc;$$' $(@D) \
+	|xargs -0 -r $(SED) '/^YYLTYPE yylloc;$$/d'
+endef
+LINUX_POST_PATCH_HOOKS += LINUX_DROP_YYLLOC
+
 # Older linux kernels use deprecated perl constructs in timeconst.pl
 # that were removed for perl 5.22+ so it breaks on newer distributions
 # Try a dry-run patch to see if this applies, if it does go ahead
Signature · 6 lines
2.25.1

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

Re: [Buildroot] [PATCH 2/2 v2] linux: fix build with host-gcc 10+

Hello Yann,

one nitpick...

Quoted 11 lines · Yann E. MORIN

Some older versions of linux, 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

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.

s/U-Boot/Linux kernel/

Regards,
Peter

Quoted 25 lines

Upstream just dropped that line altogether:

    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e33a814e772cdc36436c8c188d8c42d019fda639

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]>

---
Changes v1 -> v2:
- don't fail if no file to fix: use 'grep -Z |xargs -0 -r' (Arnout)

---
 linux/linux.mk | 7 +++++++
 1 file changed, 7 insertions(+)
linux/linux.mk +0 -0
index dd2eebd446..410b714360 100644
@@ -268,6 +268,13 @@ endef
 
 LINUX_POST_PATCH_HOOKS += LINUX_APPLY_LOCAL_PATCHES
 

linux/linux.mk endef · line 280

Quoted 10 lines
linux/linux.mk +7 -0
+# Older versions break on gcc 10+ because of redefined symbols
+define LINUX_DROP_YYLLOC
+	$(Q)grep -Z -l -r -E '^YYLTYPE yylloc;$$' $(@D) \
+	|xargs -0 -r $(SED) '/^YYLTYPE yylloc;$$/d'
+endef
+LINUX_POST_PATCH_HOOKS += LINUX_DROP_YYLLOC
+
 # Older linux kernels use deprecated perl constructs in timeconst.pl
 # that were removed for perl 5.22+ so it breaks on newer distributions
 # Try a dry-run patch to see if this applies, if it does go ahead

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

Reviewed-by Tested-by on v2 2/2
#6 lore raw

Re: [Buildroot] [PATCH 2/2 v2] linux: fix build with host-gcc 10+

In reply to Yann E. MORIN

Hi Yann,

Quoted 12 lines · Yann E. MORIN

Some older versions of linux, 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

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.

Quoted 8 lines

Upstream just dropped that line altogether:

     https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e33a814e772cdc36436c8c188d8c42d019fda639

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]>

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:

Thank you!
Best regards

Signature · 2 lines
Giulio Benetti
Benetti Engineering sas
Quoted 25 lines

---
Changes v1 -> v2:
- don't fail if no file to fix: use 'grep -Z |xargs -0 -r' (Arnout)

---
  linux/linux.mk | 7 +++++++
  1 file changed, 7 insertions(+)
linux/linux.mk +7 -0
index dd2eebd446..410b714360 100644
@@ -268,6 +268,13 @@ endef
 
  LINUX_POST_PATCH_HOOKS += LINUX_APPLY_LOCAL_PATCHES
 
+# Older versions break on gcc 10+ because of redefined symbols
+define LINUX_DROP_YYLLOC
+	$(Q)grep -Z -l -r -E '^YYLTYPE yylloc;$$' $(@D) \
+	|xargs -0 -r $(SED) '/^YYLTYPE yylloc;$$/d'
+endef
+LINUX_POST_PATCH_HOOKS += LINUX_DROP_YYLLOC
+
  # Older linux kernels use deprecated perl constructs in timeconst.pl
  # that were removed for perl 5.22+ so it breaks on newer distributions
  # Try a dry-run patch to see if this applies, if it does go ahead
Signature · 6 lines
Giulio Benetti
Benetti Engineering sas
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#7 lore raw

Re: [Buildroot] [PATCH 2/2 v2] linux: fix build with host-gcc 10+

In reply to Yann E. MORIN
Quoted 19 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Some older versions of linux, 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

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://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e33a814e772cdc36436c8c188d8c42d019fda639

So, we use a little sed-grep combo to do the exact same change.

Quoted 7 lines
Cc Thomas Petazzoni <[email protected]>
Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>

---
Changes v1 -> v2:
- don't fail if no file to fix: use 'grep -Z |xargs -0 -r' (Arnout)

Committed to 2021.02.x and 2021.11.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#8 lore raw
In reply to Yann E. MORIN
Quoted 44 lines · Yann E. MORIN

Hello All!

This two-patch series aims at side-stepping the multiple symbol declaration in older Linux and U-Boot, where the infamous yylloc is defined more than once.

Like we have a fix for the perl timeconst issue in linux, do s similar tweak for yylloc in the two packages known to be affected, Linux and U-Boot.

Here is a pipeline with all the defconfig builds:

     https://gitlab.com/ymorin/buildroot/-/pipelines/460207930

There are still some failures, but none relate to the yylloc issue:

- too long build time or not space left on device (I am only using elastic runners)

- defconfig not up-to-date (e.g. using kernel headers version since removed)

- missing host dependencies for kernel (openssl, libelf) or uboot (python)

- another host-gcc 10+ symbol redefinition issue (galileo [0])

- make 4.3 issues. For example: amarula_a64_relic_defconfig
https://gitlab.com/ymorin/buildroot/-/jobs/2035820886

DTC arch/arm/dts/sun50i-a64-amarula-relic.dtb
Error: arch/arm/dts/.sun50i-a64-amarula-relic.dtb.pre.tmp:66.1-10 syntax error FATAL ERROR: Unable to parse input tree

This is caused by make 4.3 that no longer treats '#' as special in macros, and shall no longer be escaped:
https://lwn.net/Articles/810071/

This causes '\#include "something"' to be injected as-is at the end of the temporary DTS, and of course, dtc does not cope nicely with that... [1]

Unfortuantely, I don't think we can do a generic fixup for that one...

Quoted 7 lines

- some other issues (e.g. deprecated 'partition-type' for geniamge..)

[0] this was fixed in 2014 in the kernel:
- eeeda4cd06e828b331b15741a204ff9f5874d28d
[1] this was fixed in 2018 in uboot:
- e5e701c2b8470de044c5c71d2a54ecfc72680d59
- 0c544115379ed77c1843a194e26960e5b8f3d369

Applied to master, thanks.

Regards,
Arnout

Quoted 10 lines

Changes v1 -> v2:
- don't fail if no file to fix: use 'grep -Z |xargs -0 -r' (Arnout)
- extend cover-ltter with a pipeline reference and analysese of remaining build failures

Regards,
Yann E. MORIN.

Quoted 9 lines

----------------------------------------------------------------
Yann E. MORIN (2):
boot/uboot: fix build with host-gcc 10+
linux: fix build with host-gcc 10+

  boot/uboot/uboot.mk | 7 +++++++
  linux/linux.mk      | 7 +++++++
  2 files changed, 14 insertions(+)

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