Message ID | 20220822221430.355066-1-ju.o@free.fr |
---|---|
State | Accepted |
Headers | show |
Series | [RFC,next,1/2] linux: fix builds for kernels < 5.6 and host-gcc >= 10 | expand |
Julien, All, On 2022-08-23 00:14 +0200, Julien Olivain spake thusly: > During a linux-backports update, it was found that kernel v3.10.108 was > failing to compile. See: > https://lists.buildroot.org/pipermail/buildroot/2022-August/649507.html > > This issue was introduced by commit 9b41b54be07711c10ad13ce157be272ed1cf402e > "linux: fix build with host-gcc 10+", which removes all declarations of > "yylloc" symbols in the dtc parser. This symbol is generated by bison, if the > "%locations" directive is provided in the parser. See: > https://git.savannah.gnu.org/cgit/bison.git/tree/doc/bison.texi?h=v3.8.2#n5984 > > Kernel versions < 5.6 did not include this directive, so removing all > yylloc declararions in the parser also was failing for those version. > > In the kernel, dtc was updated to v1.5.1-22-gc40aeb60b47a in: > https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0cec114e36606412908a35695a5db944cec2e3db > This commit is included in kernel v5.6. > > This dtc update include the dtc commit: > https://git.kernel.org/pub/scm/utils/dtc/dtc.git/commit/?id=7150286225476345bd6e7312331e3baf4d621c32 > which adds the '%locations' directive. > > This commit fixes the issue by programmatically adding the '%locations' > Bison directive, if it's not found in the parser file. > > Fixes: > - https://bugs.busybox.net/show_bug.cgi?id=14971 > > Signed-off-by: Julien Olivain <ju.o@free.fr> I eventually took some time to look into that issue, and I can't think of a better solution than what you proposed. Applied to master, thanks. Regards, Yann E. MORIN. > --- > Tested by: > - Building a recent kernel: > qemu_aarch64_virt_defconfig (Kernel v5.15.18) > - Building an old kernel: > qemu_arm_vexpress_defconfig with kernel 3.10.108 > --- > linux/linux.mk | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/linux/linux.mk b/linux/linux.mk > index 3d9ac37959..f3eb9c32cb 100644 > --- a/linux/linux.mk > +++ b/linux/linux.mk > @@ -155,6 +155,7 @@ LINUX_MAKE_FLAGS = \ > INSTALL_MOD_PATH=$(TARGET_DIR) \ > CROSS_COMPILE="$(TARGET_CROSS)" \ > WERROR=0 \ > + REGENERATE_PARSERS=1 \ > DEPMOD=$(HOST_DIR)/sbin/depmod > > ifeq ($(BR2_REPRODUCIBLE),y) > @@ -286,6 +287,19 @@ define LINUX_DROP_YYLLOC > endef > LINUX_POST_PATCH_HOOKS += LINUX_DROP_YYLLOC > > +# Kernel version < 5.6 breaks if host-gcc version is >= 10 and > +# 'yylloc' symbol is removed in previous hook, due to missing > +# '%locations' bison directive in dtc-parser.y. See: > +# https://bugs.busybox.net/show_bug.cgi?id=14971 > +define LINUX_ADD_DTC_LOCATIONS > + $(Q)DTC_PARSER=$(@D)/scripts/dtc/dtc-parser.y; \ > + if test -e "$${DTC_PARSER}" \ > + && ! grep -Eq '^%locations$$' "$${DTC_PARSER}" ; then \ > + $(SED) '/^%{$$/i %locations' "$${DTC_PARSER}"; \ > + fi > +endef > +LINUX_POST_PATCH_HOOKS += LINUX_ADD_DTC_LOCATIONS > + > # 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 > -- > 2.37.2 > > _______________________________________________ > buildroot mailing list > buildroot@buildroot.org > https://lists.buildroot.org/mailman/listinfo/buildroot
>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes: > Julien, All, > On 2022-08-23 00:14 +0200, Julien Olivain spake thusly: >> During a linux-backports update, it was found that kernel v3.10.108 was >> failing to compile. See: >> https://lists.buildroot.org/pipermail/buildroot/2022-August/649507.html >> >> This issue was introduced by commit 9b41b54be07711c10ad13ce157be272ed1cf402e >> "linux: fix build with host-gcc 10+", which removes all declarations of >> "yylloc" symbols in the dtc parser. This symbol is generated by bison, if the >> "%locations" directive is provided in the parser. See: >> https://git.savannah.gnu.org/cgit/bison.git/tree/doc/bison.texi?h=v3.8.2#n5984 >> >> Kernel versions < 5.6 did not include this directive, so removing all >> yylloc declararions in the parser also was failing for those version. >> >> In the kernel, dtc was updated to v1.5.1-22-gc40aeb60b47a in: >> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0cec114e36606412908a35695a5db944cec2e3db >> This commit is included in kernel v5.6. >> >> This dtc update include the dtc commit: >> https://git.kernel.org/pub/scm/utils/dtc/dtc.git/commit/?id=7150286225476345bd6e7312331e3baf4d621c32 >> which adds the '%locations' directive. >> >> This commit fixes the issue by programmatically adding the '%locations' >> Bison directive, if it's not found in the parser file. >> >> Fixes: >> - https://bugs.busybox.net/show_bug.cgi?id=14971 >> >> Signed-off-by: Julien Olivain <ju.o@free.fr> > I eventually took some time to look into that issue, and I can't think > of a better solution than what you proposed. > Applied to master, thanks. Committed to 2022.11.x and 2022.02.x, thanks.
diff --git a/linux/linux.mk b/linux/linux.mk index 3d9ac37959..f3eb9c32cb 100644 --- a/linux/linux.mk +++ b/linux/linux.mk @@ -155,6 +155,7 @@ LINUX_MAKE_FLAGS = \ INSTALL_MOD_PATH=$(TARGET_DIR) \ CROSS_COMPILE="$(TARGET_CROSS)" \ WERROR=0 \ + REGENERATE_PARSERS=1 \ DEPMOD=$(HOST_DIR)/sbin/depmod ifeq ($(BR2_REPRODUCIBLE),y) @@ -286,6 +287,19 @@ define LINUX_DROP_YYLLOC endef LINUX_POST_PATCH_HOOKS += LINUX_DROP_YYLLOC +# Kernel version < 5.6 breaks if host-gcc version is >= 10 and +# 'yylloc' symbol is removed in previous hook, due to missing +# '%locations' bison directive in dtc-parser.y. See: +# https://bugs.busybox.net/show_bug.cgi?id=14971 +define LINUX_ADD_DTC_LOCATIONS + $(Q)DTC_PARSER=$(@D)/scripts/dtc/dtc-parser.y; \ + if test -e "$${DTC_PARSER}" \ + && ! grep -Eq '^%locations$$' "$${DTC_PARSER}" ; then \ + $(SED) '/^%{$$/i %locations' "$${DTC_PARSER}"; \ + fi +endef +LINUX_POST_PATCH_HOOKS += LINUX_ADD_DTC_LOCATIONS + # 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
During a linux-backports update, it was found that kernel v3.10.108 was failing to compile. See: https://lists.buildroot.org/pipermail/buildroot/2022-August/649507.html This issue was introduced by commit 9b41b54be07711c10ad13ce157be272ed1cf402e "linux: fix build with host-gcc 10+", which removes all declarations of "yylloc" symbols in the dtc parser. This symbol is generated by bison, if the "%locations" directive is provided in the parser. See: https://git.savannah.gnu.org/cgit/bison.git/tree/doc/bison.texi?h=v3.8.2#n5984 Kernel versions < 5.6 did not include this directive, so removing all yylloc declararions in the parser also was failing for those version. In the kernel, dtc was updated to v1.5.1-22-gc40aeb60b47a in: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0cec114e36606412908a35695a5db944cec2e3db This commit is included in kernel v5.6. This dtc update include the dtc commit: https://git.kernel.org/pub/scm/utils/dtc/dtc.git/commit/?id=7150286225476345bd6e7312331e3baf4d621c32 which adds the '%locations' directive. This commit fixes the issue by programmatically adding the '%locations' Bison directive, if it's not found in the parser file. Fixes: - https://bugs.busybox.net/show_bug.cgi?id=14971 Signed-off-by: Julien Olivain <ju.o@free.fr> --- Tested by: - Building a recent kernel: qemu_aarch64_virt_defconfig (Kernel v5.15.18) - Building an old kernel: qemu_arm_vexpress_defconfig with kernel 3.10.108 --- linux/linux.mk | 14 ++++++++++++++ 1 file changed, 14 insertions(+)