public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] scripts/dtc: Fix pkg-config behavior under sysroot
@ 2026-01-22  9:28 Greg Malysa
  2026-01-25 19:43 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Greg Malysa @ 2026-01-22  9:28 UTC (permalink / raw)
  To: u-boot; +Cc: Greg Malysa, Ilias Apalodimas, Marek Vasut, Sughosh Ganu,
	Tom Rini

When building with a toolchain that uses a modified sysroot (such as a
Yocto-generated SDK) that does not include libyaml, on a host that does
have libyaml, building dtc will fail with errors like:

  HOSTLD  scripts/dtc/dtc
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld:
scripts/dtc/yamltree.o: in function `yaml_propval_int':
yamltree.c:(.text+0x167): undefined reference to
`yaml_sequence_start_event_initialize'
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld:
yamltree.c:(.text+0x172): undefined reference to `yaml_emitter_emit'
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld:
yamltree.c:(.text+0x1e8): undefined reference to
`yaml_scalar_event_initialize'
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld:
yamltree.c:(.text+0x1f5): undefined reference to `yaml_emitter_emit'

(... rest of errors truncated ...)

This happens because the test looks for the file in the default path but
uses pkg-config, which is affected by changing sysroot, to determine the
correct linker arguments. This does not happen when building entirely
within yocto, as pseudo will intercept and rewrite the file path when
trying to test for /usr/include/yaml.h to match the sysroot and thus
generate consistent behavior.

This commit adds the PKG_CONFIG_SYSROOT_DIR prefix to the file path
in order to test against the same conditions that are used to resolve
the build flags for libyaml.

In linux commit ef8795f3f1c ("dt-bindings: kbuild: Use DTB files for
validation"), including yaml is disabled again anyway because of other
problems that it causes, so this problem can also be addressed by
partially backporting that commit instead and simply disabling the yaml
support.

Fixes: 0535e46d55d7 ("scripts/dtc: Update to upstream version v1.7.2-35-g52f07dcca47c")
Signed-off-by: Greg Malysa <malysagreg@gmail.com>

---

 scripts/dtc/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile
index 53f94e5a48d..6f309b37e08 100644
--- a/scripts/dtc/Makefile
+++ b/scripts/dtc/Makefile
@@ -17,7 +17,7 @@ fdtoverlay-objs	:= $(libfdt) fdtoverlay.o util.o
 # Source files need to get at the userspace version of libfdt_env.h to compile
 HOST_EXTRACFLAGS := -I$(srctree)/$(src)/libfdt
 
-ifeq ($(wildcard /usr/include/yaml.h),)
+ifeq ($(wildcard $(PKG_CONFIG_SYSROOT_DIR)/usr/include/yaml.h),)
 HOST_EXTRACFLAGS += -DNO_YAML
 else
 dtc-objs	+= yamltree.o
-- 
2.49.1

base-commit: 04b37257c034f5d7ad877f72e03b12a806114ac9
branch: dev/sc5xx-boards-v4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scripts/dtc: Fix pkg-config behavior under sysroot
  2026-01-22  9:28 [PATCH] scripts/dtc: Fix pkg-config behavior under sysroot Greg Malysa
@ 2026-01-25 19:43 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2026-01-25 19:43 UTC (permalink / raw)
  To: u-boot, Greg Malysa; +Cc: Ilias Apalodimas, Marek Vasut, Sughosh Ganu

On Thu, 22 Jan 2026 04:28:53 -0500, Greg Malysa wrote:

> When building with a toolchain that uses a modified sysroot (such as a
> Yocto-generated SDK) that does not include libyaml, on a host that does
> have libyaml, building dtc will fail with errors like:
> 
>   HOSTLD  scripts/dtc/dtc
> /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld:
> scripts/dtc/yamltree.o: in function `yaml_propval_int':
> yamltree.c:(.text+0x167): undefined reference to
> `yaml_sequence_start_event_initialize'
> /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld:
> yamltree.c:(.text+0x172): undefined reference to `yaml_emitter_emit'
> /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld:
> yamltree.c:(.text+0x1e8): undefined reference to
> `yaml_scalar_event_initialize'
> /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld:
> yamltree.c:(.text+0x1f5): undefined reference to `yaml_emitter_emit'
> 
> [...]

Applied to u-boot/master, thanks!

[1/1] scripts/dtc: Fix pkg-config behavior under sysroot
      commit: 807bcd844afeadbfe47ac132524cc7e3b699bc46
-- 
Tom



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-01-25 19:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-22  9:28 [PATCH] scripts/dtc: Fix pkg-config behavior under sysroot Greg Malysa
2026-01-25 19:43 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox