Skip to contentSkip to conversation

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

PATCH Superseded Yann E. MORIN 2 participants 6 messages Jan 30, 2022 – Jan 31, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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.

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 | 6 ++++++
 linux/linux.mk      | 6 ++++++
 2 files changed, 12 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 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]>
---
 boot/uboot/uboot.mk | 6 ++++++
 1 file changed, 6 insertions(+)
boot/uboot/uboot.mk +6 -0
index 574fc7089a..9415c4722a 100644
@@ -244,6 +244,12 @@ 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
+	$(SED) '/^YYLTYPE yylloc;$$/d' `grep -l -r -E '^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
#4 lore raw

PATCH 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]>
---
 linux/linux.mk | 6 ++++++
 1 file changed, 6 insertions(+)
linux/linux.mk +6 -0
index dd2eebd446..2a841ca3e6 100644
@@ -268,6 +268,12 @@ endef
 
 LINUX_POST_PATCH_HOOKS += LINUX_APPLY_LOCAL_PATCHES
 
+# Older versions break on gcc 10+ because of redefined symbols
+define LINUX_DROP_YYLLOC
+	$(SED) '/^YYLTYPE yylloc;$$/d' `grep -l -r -E '^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
In reply to Yann E. MORIN

All,

On 2022-01-30 22:10 +0100, Yann E. MORIN spake thusly:

Quoted 6 lines

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

And this does not work when the fix is not needed:

https://gitlab.com/ymorin/buildroot/-/jobs/2032545273

/bin/sed: no input files

Damned. :-(

I'll look into it soonish. In the meantime, patches marked as changs requested in Patchwork, sorry for the noise...

Regards,
Yann E. MORIN.

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
#2 lore raw

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

In reply to Yann E. MORIN
Quoted 30 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.

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]>
---
  boot/uboot/uboot.mk | 6 ++++++
  1 file changed, 6 insertions(+)
boot/uboot/uboot.mk +0 -0
index 574fc7089a..9415c4722a 100644

boot/uboot/uboot.mk endef · line 249

Quoted 6 lines
boot/uboot/uboot.mk +3 -0
@@ -244,6 +244,12 @@ 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
+	$(SED) '/^YYLTYPE yylloc;$$/d' `grep -l -r -E '^YYLTYPE yylloc;$$' $(@D)`

Why not use

	grep ... | xargs --no-run-if-empty $(SED) ...

which also avoids the "no input files" problem.

Also:
- Isn't it enough to search in $(@D)/scripts?
- I guess we should use -Z to make is 0-separated. I'm not a 100% sure, but I vaguely remember encountering a U-Boot or Linux vendor fork which had file names with spaces in them.

Regards,
Arnout

boot/uboot/uboot.mk endef · line 255

Quoted 6 lines
boot/uboot/uboot.mk +3 -0
+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] boot/uboot: fix build with host-gcc 10+

Arnout, All,

On 2022-01-31 08:42 +0100, Arnout Vandecappelle spake thusly:

Quoted 1 line · Yann E. MORIN

[--SNIP--]

Quoted 3 lines
Quoted 3 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.

[--SNIP--]

Quoted 8 lines

boot/uboot/uboot.mk endef · line 249

Quoted 3 lines
boot/uboot/uboot.mk +3 -0
+# Older versions break on gcc 10+ because of redefined symbols
+define UBOOT_DROP_YYLLOC
+	$(SED) '/^YYLTYPE yylloc;$$/d' `grep -l -r -E '^YYLTYPE yylloc;$$' $(@D)`

Why not use

	grep ... | xargs --no-run-if-empty $(SED) ...

which also avoids the "no input files" problem.

Yes, this is the obviously correct solution; I just did not have time to handle it this morning... ;-)

Quoted 2 lines

Also:
- Isn't it enough to search in $(@D)/scripts?

I was also a bit conflicted on that one. It should even be enough to look up scripts/dtc/ (kconfig was never impacted).

Quoted 3 lines

- I guess we should use -Z to make is 0-separated. I'm not a 100% sure, but I vaguely remember encountering a U-Boot or Linux vendor fork which had file names with spaces in them.

Whether that exists or not, I am now trying to always use -Z et al. when dealing with lists of files in shell.

Thanks for the input; v2 incoming shortly...

Regards,
Yann E. MORIN.

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