On Wed, 24 Dec 2025, Michael Tokarev wrote:
If <libfdt.h> is installed on the system, u-boot-sam460ex gives
the following build errors:

gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -idirafter /build/pkg/build/b/u-boot-sam460ex/include -idirafter /build/pkg /build/b/u-boot-sam460ex/include2 -idirafter /build/pkg/build/b/u-boot-sam460ex/include -I /build/pkg/build/b/u-boot-sam460ex/lib/ libfdt -I /build/pkg/build/b/u-boot-sam460ex/tools -DTEXT_BASE=0xFFF80000 -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES -o default_image.
o default_image.c -c
In file included from roms/u-boot-sam460ex/include/image.h:55,
                from default_image.c:31:
/usr/include/libfdt.h:122:21: error: redefinition of ‘fdt_offset_ptr_w’
122 | static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
     |                     ^~~~~~~~~~~~~~~~
In file included from fdt_host.h:25,
                from mkimage.h:35,
                from default_image.c:30:
../include/libfdt.h:126:21: note: previous definition of ‘fdt_offset_ptr_w’ with type ‘void *(void *, int, int)’ 126 | static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
     |                     ^~~~~~~~~~~~~~~~
/usr/include/libfdt.h:266:1: error: redefinition of ‘fdt_set_magic’
 266 | fdt_set_hdr_(magic);
     | ^~~~~~~~~~~~
../include/libfdt.h:157:28: note: previous definition of ‘fdt_set_magic’ with type ‘void(void *, uint32_t)’ {aka ‘void(v
oid *, unsigned int)’}

etc.

This is because roms/u-boot-sam460ex/tools/fdt_host.h includes the
local ../include/fdt.h &Co.  While the rest of the headers include
<fdt.h> &Co.  And in version of u-boot-sam460ex in 10.2 has the
following difference compared to 10.1:

diff -u -r qemu-10.1.0/roms/u-boot-sam460ex/tools/Makefile qemu-10.2.0/roms/u-boot-sam460ex/tools/Mak>
--- qemu-10.1.3/roms/u-boot-sam460ex/tools/Makefile
+++ qemu-10.2.0/roms/u-boot-sam460ex/tools/Makefile
@@ -133,9 +133,9 @@
# Use native tools and options
# Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
#
-HOSTCPPFLAGS = -isystem $(SRCTREE)/include \
-               -isystem $(OBJTREE)/include2 \
-               -isystem $(OBJTREE)/include \
+HOSTCPPFLAGS = -idirafter $(SRCTREE)/include \
+               -idirafter $(OBJTREE)/include2 \
+               -idirafter $(OBJTREE)/include \
               -I $(SRCTREE)/lib/libfdt \
               -I $(SRCTREE)/tools \
               -DTEXT_BASE=$(TEXT_BASE) -DUSE_HOSTCC \

So in 10.1 and before, local include dir was preferred to
the system include dir, while now local include dir is checked
*after* the system one.  So when including <libfdt.h>, the
system include is found first.

I don't know why -isystem was changed to -idirafter.

This reverts it to how upstream has it. Previously we had a local fix in commit 7fb06b0 as the above but now that no longer works because then you get other include mismatches and build fails with:

/usr/bin/ld: errno: TLS definition in /lib64/libc.so.6 section .tbss mismatches 
non-TLS reference in fit_image.o

so reverted this to what upstream has which unfortunately means that you get conflict with fdt headers. So you get include conflicts either way but removing system fdt headers is easier and this matches upstream reducing local patches.

For now, in order to make it buildable, I copied
include/*fdt*.h to lib/libfdt/ so the local headers are
picked up instead of the system ones, just like in qemu 10.1.

But this needs to be addressed upstream, I'd say - either
in u-boot-sam460ex (where the bug is), or in qemu.

The actual upstream is at https://acube-systems.biz/ and I don't want to diverge from that too much as they still make updates and I want to be able to update in the future without too much porting of local fixes. So try sending patches to them or accept that this is based on and old U-Boot from 2010 and only meant to build with contemporary gcc (about version 4 or 5) so you may need that old gcc version or a container to build it (like when you build an old Linux kernel version that no longer builds with current tools). We could try to fix it but then if that breaks something it will be hard to find if it's broken upstream or introduced by a local fix so best keep as close to upstream as possible.

Regards,
BALATON Zoltan

Reply via email to