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.
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.
Thanks,
/mjt