diff mbox series

[meta-zephyr,1/2] zephyr-core/zephyr-kernel: Use the upstream "cross-compile" toolchain

Message ID 20230222230711.689631-1-peter.hoyes@arm.com
State New
Headers show
Series [meta-zephyr,1/2] zephyr-core/zephyr-kernel: Use the upstream "cross-compile" toolchain | expand

Commit Message

Peter Hoyes Feb. 22, 2023, 11:07 p.m. UTC
From: Peter Hoyes <Peter.Hoyes@arm.com>

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 <Peter.Hoyes@arm.com>
---
 .../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 mbox series

Patch

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"