Skip to content

Commit 807bcd8

Browse files
gmalysatrini
authored andcommitted
scripts/dtc: Fix pkg-config behavior under sysroot
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: 0535e46 ("scripts/dtc: Update to upstream version v1.7.2-35-g52f07dcca47c") Signed-off-by: Greg Malysa <malysagreg@gmail.com>
1 parent 3a97955 commit 807bcd8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/dtc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fdtoverlay-objs := $(libfdt) fdtoverlay.o util.o
1717
# Source files need to get at the userspace version of libfdt_env.h to compile
1818
HOST_EXTRACFLAGS := -I$(srctree)/$(src)/libfdt
1919

20-
ifeq ($(wildcard /usr/include/yaml.h),)
20+
ifeq ($(wildcard $(PKG_CONFIG_SYSROOT_DIR)/usr/include/yaml.h),)
2121
HOST_EXTRACFLAGS += -DNO_YAML
2222
else
2323
dtc-objs += yamltree.o

0 commit comments

Comments
 (0)