Skip to contentSkip to conversation

Fix conflict between host-dtc headers and kernel dtc

RFC PATCH New unixmania at gmail.com 3 participants 5 messages Nov 3, 2019 – Nov 15, 2019

lore
Share & tools
lore
#0 lore raw

cover Fix conflict between host-dtc headers and kernel dtc

From: Carlos Santos <[email protected]>

- Install libfdt headers under $(HOST_DIR)/include/libfdt
- Tell host-qemu to use that path

Carlos Santos (2):
package/dtc: install host libfdt headers in a subdirectory package/qemu: search for host-dtc (libfdt) headers at the right place

 package/dtc/dtc.mk   | 1 +
 package/qemu/qemu.mk | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)
Signature · 1 line
2.18.1
#1 lore raw

RFC PATCH 1/2 package/dtc: install host libfdt headers in a subdirectory

From: Carlos Santos <[email protected]>

Installing the libfdt headers at $(HOST_DIR)/include interferes with the build of the kernel, as in beaglebone:

2019-11-01T22:23:16 /usr/bin/make -f ./scripts/Makefile.build obj=scripts
2019-11-01T22:23:16 /usr/bin/make -f ./scripts/Makefile.build obj=scripts/dtc need-builtin=
2019-11-01T22:23:16 (cat /dev/null; ) > scripts/dtc/modules.order
2019-11-01T22:23:16 /usr/bin/gcc -O2 -I/work/beaglebone/host/include -L/work/beaglebone/host/lib -Wl,-rpath,/work/beaglebone/host/lib -Wp,-MD,scripts/dtc/libfdt/.fdt_ro.o.d -Wall -Wmissing-prototypes -Wstrict-p>
2019-11-01T22:23:16 scripts/dtc/libfdt/fdt_ro.c:92:10: error: redefinition of ?fdt_get_max_phandle?
2019-11-01T22:23:16 uint32_t fdt_get_max_phandle(const void *fdt)
2019-11-01T22:23:16 ^~~~~~~~~~~~~~~~~~~
2019-11-01T22:23:16 In file included from scripts/dtc/libfdt/fdt_ro.c:54:
2019-11-01T22:23:16 /work/beaglebone/host/include/libfdt.h:384:24: note: previous definition of ?fdt_get_max_phandle? was here
2019-11-01T22:23:16 static inline uint32_t fdt_get_max_phandle(const void *fdt)
2019-11-01T22:23:16 ^~~~~~~~~~~~~~~~~~~
2019-11-01T22:23:16 make[4]: *** [scripts/Makefile.host:107: scripts/dtc/libfdt/fdt_ro.o] Error 1
2019-11-01T22:23:16 make[3]: *** [scripts/Makefile.build:544: scripts/dtc] Error 2
2019-11-01T22:23:16 make[2]: *** [Makefile:1066: scripts] Error 2
2019-11-01T22:23:16 make[1]: *** [package/pkg-generic.mk:241: /work/beaglebone/build/linux-4dae378bbe721277b08699d1d88ffae12acc9b09/.stamp_built] Error 2

We cannot simply disable dtc support and patching the kernel makefiles is risky and error-prone, so let's just install the host-dtc headers at $(HOST_DIR)/include/libfdt to circumvent the problem.

Packages that depend on those headers (e.g. host-qemu) must be updated to user the correct path but this is small change.

---
 package/dtc/dtc.mk | 1 +
 1 file changed, 1 insertion(+)
package/dtc/dtc.mk +1 -0
index 7fde0dc968..5265640f65 100644
@@ -20,6 +20,7 @@ DTC_MAKE_OPTS = \
 
 HOST_DTC_MAKE_OPTS = \
 	PREFIX=$(HOST_DIR) \
+	INCLUDEDIR=$(HOST_DIR)/include/libfdt \
 	NO_PYTHON=1 \
 	NO_VALGRIND=1 \
 	NO_YAML=1
Signature · 1 line
2.18.1
#2 lore raw

RFC PATCH 1/2 package/dtc: install host libfdt headers in a subdirectory

Hello Carlos

Quoted 21 lines · unixmania at gmail.com

From: Carlos Santos <[email protected]>

Installing the libfdt headers at $(HOST_DIR)/include interferes with the build of the kernel, as in beaglebone:

2019-11-01T22:23:16 /usr/bin/make -f ./scripts/Makefile.build obj=scripts
2019-11-01T22:23:16 /usr/bin/make -f ./scripts/Makefile.build obj=scripts/dtc need-builtin=
2019-11-01T22:23:16 (cat /dev/null; ) > scripts/dtc/modules.order
2019-11-01T22:23:16 /usr/bin/gcc -O2 -I/work/beaglebone/host/include -L/work/beaglebone/host/lib -Wl,-rpath,/work/beaglebone/host/lib -Wp,-MD,scripts/dtc/libfdt/.fdt_ro.o.d -Wall -Wmissing-prototypes -Wstrict-p>
2019-11-01T22:23:16 scripts/dtc/libfdt/fdt_ro.c:92:10: error: redefinition of ?fdt_get_max_phandle?
2019-11-01T22:23:16 uint32_t fdt_get_max_phandle(const void *fdt)
2019-11-01T22:23:16 ^~~~~~~~~~~~~~~~~~~
2019-11-01T22:23:16 In file included from scripts/dtc/libfdt/fdt_ro.c:54:
2019-11-01T22:23:16 /work/beaglebone/host/include/libfdt.h:384:24: note: previous definition of ?fdt_get_max_phandle? was here
2019-11-01T22:23:16 static inline uint32_t fdt_get_max_phandle(const void *fdt)
2019-11-01T22:23:16 ^~~~~~~~~~~~~~~~~~~
2019-11-01T22:23:16 make[4]: *** [scripts/Makefile.host:107: scripts/dtc/libfdt/fdt_ro.o] Error 1
2019-11-01T22:23:16 make[3]: *** [scripts/Makefile.build:544: scripts/dtc] Error 2
2019-11-01T22:23:16 make[2]: *** [Makefile:1066: scripts] Error 2
2019-11-01T22:23:16 make[1]: *** [package/pkg-generic.mk:241: /work/beaglebone/build/linux-4dae378bbe721277b08699d1d88ffae12acc9b09/.stamp_built] Error 2
Quoted 3 lines

We cannot simply disable dtc support and patching the kernel makefiles is risky and error-prone, so let's just install the host-dtc headers at $(HOST_DIR)/include/libfdt to circumvent the problem.

I agree with you, this sounds reasonable.

I'm away from my computer most of the time these days, so I didn't have much time to look at the possibility of preventing the Kernel from building its own dtc without hacking the Makefiles.

Quoted 3 lines

Packages that depend on those headers (e.g. host-qemu) must be updated to user the correct path but this is small change.

Again, sounds reasonable.

Quoted 12 lines
---
  package/dtc/dtc.mk | 1 +
  1 file changed, 1 insertion(+)
package/dtc/dtc.mk +0 -0
index 7fde0dc968..5265640f65 100644

package/dtc/dtc.mk DTC_MAKE_OPTS = \ · line 26

Quoted 7 lines
package/dtc/dtc.mk +1 -0
@@ -20,6 +20,7 @@ DTC_MAKE_OPTS = \
 
  HOST_DTC_MAKE_OPTS = \
  	PREFIX=$(HOST_DIR) \
+	INCLUDEDIR=$(HOST_DIR)/include/libfdt \
  	NO_PYTHON=1 \
  	NO_VALGRIND=1 \
  	NO_YAML=1

Best regards,

Titouan

#3 lore raw

RFC PATCH 2/2 package/qemu: search for host-dtc (libfdt) headers at the right place

In reply to unixmania at gmail.com

From: Carlos Santos <[email protected]>

The libfdt headers are installed at $(HOST_DIR)/include/libfdt now, to prevent conflicts with the kernel dtc code. Pass that path to the qemu configure script, otherwise it uses its bundled copy of libfdt.

---
 package/qemu/qemu.mk | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
package/qemu/qemu.mk +4 -1
index a91f9d3eeb..1a5c642726 100644
@@ -246,9 +246,12 @@ endif
 endif
 HOST_QEMU_SYS_ARCH ?= $(HOST_QEMU_ARCH)
 
+HOST_QEMU_CFLAGS = $(HOST_CFLAGS)
+
 ifeq ($(BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE),y)
 HOST_QEMU_TARGETS += $(HOST_QEMU_SYS_ARCH)-softmmu
 HOST_QEMU_OPTS += --enable-system --enable-fdt
+HOST_QEMU_CFLAGS += -I$(HOST_DIR)/include/libfdt
 HOST_QEMU_DEPENDENCIES += host-dtc
 else
 HOST_QEMU_OPTS += --disable-system
@@ -297,7 +300,7 @@ define HOST_QEMU_CONFIGURE_CMDS
 		--interp-prefix=$(STAGING_DIR) \
 		--cc="$(HOSTCC)" \
 		--host-cc="$(HOSTCC)" \
-		--extra-cflags="$(HOST_CFLAGS)" \
+		--extra-cflags="$(HOST_QEMU_CFLAGS)" \
 		--extra-ldflags="$(HOST_LDFLAGS)" \
 		$(HOST_QEMU_OPTS)
 endef
Signature · 1 line
2.18.1
#4 lore raw

cover Fix conflict between host-dtc headers and kernel dtc

In reply to unixmania at gmail.com
Quoted 3 lines · On Sun, 3 Nov 2019 12:12:56 -0300 unixmania at gmail.com wrote:

Carlos Santos (2):
package/dtc: install host libfdt headers in a subdirectory package/qemu: search for host-dtc (libfdt) headers at the right place

Thanks, looks like a good idea, so I've applied both patches to the next branch.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com