package/dtc: fix include guards for older kernel/u-boot
authorLothar Felten <lothar.felten@gmail.com>
Mon, 8 Oct 2018 11:51:46 +0000 (13:51 +0200)
committerArnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Sat, 20 Oct 2018 11:35:03 +0000 (12:35 +0100)
commitc7ffd8a75d55e24d793106eabbb80964ab91081f
tree2e1ed67fc1a2ce25f2e24104ce7c65d96fc749a2
parent963f824511b68104469cfda6d8874df0651ed9bb
package/dtc: fix include guards for older kernel/u-boot

U-Boot has a copy of dtc in-tree. However, it has a bug in its build
system which could result in both one of the in-tree dtc include files
and the same host-installed include file to be #included.

Normally, that wouldn't be a problem, because (a) the two include files
are compatible, so it doesn't matter which one you include, and (b) the
include guards are the same in both, so only one of them really does
get included. However, upstream dtc has changed the include guards,
removing the leading underscore. Therefore, now the header file does
get included twice, which leads to multiple definitions like:

/builds/buildroot.org/buildroot/output/host/include/libfdt.h:1790:19: error: redefinition of 'fdt_appendprop_cell'
 static inline int fdt_appendprop_cell(void *fdt, int nodeoffset,
                   ^~~~~~~~~~~~~~~~~~~
In file included from tools/fdt_host.h:11:0,
                 from tools/imagetool.h:24,
                 from tools/atmelimage.c:8:
tools/../include/libfdt.h:1656:19: note: previous definition of 'fdt_appendprop_cell' was here
 static inline int fdt_appendprop_cell(void *fdt, int nodeoffset,
                   ^~~~~~~~~~~~~~~~~~~

To fix this, patch (host) dtc to accept the old include guard as well,
which restores the old behaviour. This patch is probably not
upstreamable, since it's really a hack to work around an issue in
U-Boot.  Note that it has been fixed upstream, but Buildroot supports
building older versions of U-Boot as well.

Note that the problem may still occur if you have libdtc-dev installed
on the host. However, now there is a simple workaround: enable
BR2_TARGET_UBOOT_NEEDS_DTC.

Note that a similar problem also occurs with the beaglebone fork of the
kernel. It's not clear if it has been fixed there.

Signed-off-by: Lothar Felten <lothar.felten@gmail.com>
[Arnout: rewrite commit message, rewrap patch commit message]
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
package/dtc/0001-Fix-include-guards-for-older-kernel-u-boot-sources.patch [new file with mode: 0644]