From 155bf064467771ae22c017c61a3ca5c6ea81ff6e Mon Sep 17 00:00:00 2001 From: Peter Hoyes Date: Wed, 22 Feb 2023 23:07:10 +0000 Subject: [PATCH] zephyr-core/zephyr-kernel: Use the upstream "cross-compile" toolchain Zephyr upstream contains CMake configuration for a "cross-compile" toolchain for "other cross compilers" which works with the Yocto-built toolchain out-of-the-box, so use this instead of the "yocto" toolchain, which requires a downstream patch to be carried. The Yocto-built toolchain does not support --print-sysroot so that toolchains can be shared between multiple builds with different sysroots, so manually set SYSROOT_DIR to the staging directory. Use the "cross-compile" toolchain by default. Signed-off-by: Peter Hoyes Signed-off-by: Naveen Saini --- .../zephyr-kernel/zephyr-kernel-common.inc | 2 +- .../zephyr-kernel/zephyr-toolchain-cross-compile.inc | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-cross-compile.inc diff --git a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc index 5c9d9e5..ba70a29 100644 --- a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc +++ b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc @@ -7,7 +7,7 @@ inherit ${ZEPHYR_INHERIT_CLASSES} # filesystem. IMAGE_NO_MANIFEST = "1" -ZEPHYR_TOOLCHAIN_VARIANT ?= "yocto" +ZEPHYR_TOOLCHAIN_VARIANT ?= "cross-compile" require zephyr-toolchain-${ZEPHYR_TOOLCHAIN_VARIANT}.inc ZEPHYR_MAKE_OUTPUT = "zephyr.elf" diff --git a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-cross-compile.inc b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-cross-compile.inc new file mode 100644 index 0000000..2f1ea37 --- /dev/null +++ b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-cross-compile.inc @@ -0,0 +1,12 @@ +# Additional definitions to use the cross-compile toolchain + +CROSS_COMPILE = "${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}" +SYSROOT_DIR="${STAGING_DIR_TARGET}" + +EXTRA_OECMAKE:append = " \ + -DCROSS_COMPILE=${CROSS_COMPILE} \ + -DSYSROOT_DIR=${SYSROOT_DIR} \ + " + +OE_TERMINAL_EXPORTS += "CROSS_COMPILE" +OE_TERMINAL_EXPORTS += "SYSROOT_DIR"