Bug 14971 - Kernel 3.10.108 fail to build in Buildroot 2022.08-rc1
Summary: Kernel 3.10.108 fail to build in Buildroot 2022.08-rc1
Status: RESOLVED FIXED
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-18 22:29 UTC by Julien Olivain
Modified: 2023-01-04 13:10 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Julien Olivain 2022-08-18 22:29:55 UTC
Hi,

During a linux-backports update, it was found that kernel v3.10.108 was failing to compile in buildroot 2022.08-rc1. See:
https://lists.buildroot.org/pipermail/buildroot/2022-August/649507.html

As reported by Yann, this was likely introduced by:
https://git.buildroot.org/buildroot/commit/?id=9b41b54be07711c10ad13ce157be272ed1cf402e

The issue can be reproduced with:

    make qemu_aarch64_virt_defconfig
    utils/config \
      --set-str LINUX_KERNEL_CUSTOM_VERSION_VALUE 3.10.108 \
      -e PACKAGE_HOST_LINUX_HEADERS_CUSTOM_3_10 \
      -d PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_15
    make olddefconfig
    make linux

After some analysis, it appears that in 3.10.108, bison does not generate the declaration 'YYLTYPE yylloc', which is also removed by the Buildroot commit 9b41b54b.  We end up with no declaration at all.  Those declaration are emitted with the dtc-parser.y contains the '%locations' directive.

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.

I'm able to workaround the failure by adding in linux/linux.mk:

define LINUX_ADD_DTC_LOCATIONS
  if test -e $(@D)/scripts/dtc/dtc-parser.y && \
      ! grep -Eq '^%locations$$' $(@D)/scripts/dtc/dtc-parser.y ; then \
    $(SED) '/^%{$$/i %locations' $(@D)/scripts/dtc/dtc-parser.y; \
  fi
endef
LINUX_POST_PATCH_HOOKS += LINUX_ADD_DTC_LOCATIONS

and add REGENERATE_PARSERS=1 into LINUX_MAKE_FLAGS. This basically adds the missing directive, if not found.

Before sending a patch, I created this bug to log my findings and collect few comments, if this is a good approach.  Any suggestions?

Thanks!
Comment 1 Peter Korsgaard 2023-01-04 13:10:22 UTC
Fixed (by yourself) by https://gitlab.com/buildroot.org/buildroot/-/commit/e75f3962084045cf50f38f0adf8bfaa8da71dfd5, thanks!