diff mbox series

[yocto-patches,meta-zephyr,master,blacksail,wrynose] zephyr-toolchain-zephyr: Unexport Yocto toolchain variables

Message ID 20260916150036.1839867-1-sandeep.gundlupet-raju@amd.com
State New
Headers show
Series [yocto-patches,meta-zephyr,master,blacksail,wrynose] zephyr-toolchain-zephyr: Unexport Yocto toolchain variables | expand

Commit Message

Sandeep Gundlupet Raju Sept. 16, 2026, 3 p.m. UTC
When ZEPHYR_TOOLCHAIN_VARIANT is "zephyr", INHIBIT_DEFAULT_DEPS is set
and no Yocto cross toolchain is built for the recipe. BitBake still
exports CC, LD, AR and friends into the task environment, where they
reference aarch64-yocto-elf-* binaries that do not exist.

Zephyr ignores these and uses the SDK, but external module build systems
invoked from the Zephyr build do not. Trusted Firmware-A is built by its
own Makefile, which prefers CC/LD/AR from the environment over the
CROSS_COMPILE value pointing at the Zephyr SDK. Its tool detection then
fails and expands a multi-line warning macro into the tool identifier
variable, leaving embedded newlines that break a later conditional:

  lib/libfdt/libfdt.mk:16: *** invalid syntax in conditional.  Stop.

Set the unexport flag on the toolchain variables so they are unset in
the task environment and TF-A falls back to CROSS_COMPILE.

AI-Generated: GitHub Copilot (Claude Opus 5)

Signed-off-by: Sandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com>
---
 .../zephyr-kernel/zephyr-toolchain-zephyr.inc       | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-zephyr.inc b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-zephyr.inc
index e265883..8fa3e09 100644
--- a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-zephyr.inc
+++ b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-zephyr.inc
@@ -18,5 +18,18 @@  EXTRA_OECMAKE:append = " -DUSER_CACHE_DIR=${ZEPHYR_USER_CACHE_DIR}"
 INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
 INHIBIT_PACKAGE_STRIP = "1"
 
+# INHIBIT_DEFAULT_DEPS means no Yocto cross toolchain is built for this recipe,
+# so the exported CC/LD/AR/... point at binaries which do not exist. Zephyr
+# itself ignores them and uses the SDK, but external module build systems
+# invoked by Zephyr (for example Trusted Firmware-A, which is built with its own
+# Makefile) honour them and fail instead of using the SDK passed through
+# CROSS_COMPILE. Keep them out of the task environment.
+ZEPHYR_UNEXPORT_TOOLS = "AR AS CC CPP CXX LD NM OBJCOPY OBJDUMP RANLIB STRIP"
+
+python () {
+    for tool in d.getVar("ZEPHYR_UNEXPORT_TOOLS").split():
+        d.setVarFlag(tool, "unexport", "1")
+}
+
 # Set Zephyr work directory to describe toolchain accurately
 MULTIMACH_TARGET_SYS = "${ZEPHYR_BOARD}-zephyr"