diff mbox series

[meta-zephyr,v1] zephyr-sdk: replace pre-built host tool of zephyr-sdk with Native packages

Message ID 20241219022036.561047-1-jamin_lin@aspeedtech.com
State New
Headers show
Series [meta-zephyr,v1] zephyr-sdk: replace pre-built host tool of zephyr-sdk with Native packages | expand

Commit Message

Jamin Lin Dec. 19, 2024, 2:20 a.m. UTC
It installed pre-built host tool of zephyr-sdk into build environment at the
host side. However, the pre-built host tool of zephyr-sdk linked the
"ld-linux-x86-64.so.2" from the hardcode SDK installation path.

Used "ldd recipe-sysroot-native/usr/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/dtc"
command to show the linker information of pre-built dtc tool.

```
/XXX/build/tmp/work/x86_64-linux/zephyr-sdk-native/0.16.9/XXX/build/tmp/work/x86_64-linux/zephyr-sdk-native/0.16.9/recipe-sysroot-native/usr/zephyr-sdk/sysroots/x86_64-pokysdk-linux/lib/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
```

The pre-built host dtc tool linked "${D}${ZEPHYR_SDK_DIR}/recipe-sysroot-native/usr/zephyr-sdk/sysroots/x86_64-pokysdk-linux/lib/ld-linux-x86-64.so.2"
However, the hardcode link path causes the pre-built host tools cannot be
executed if users set sstate-cache build.

How to reproduce it:
1. Setup a new build environment A and build zephyr image by "bitbake zephyr-helloworld"
2. Save and copy the "build/sstate-cache" directory to ${HOME} directory.
3. Remove a completely build environment A.
4. Setup a new build environment B and set SSTATE_DIR variable to "${HOME}/sstate-cache".
5. Build zephyr image by "bitbake zephyr-helloworld". The pre-built host tool
   from zephyr-sdk cannot be executed.

   ```
   ./recipe-sysroot-native/usr/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/dtc -h
   No such file or directory
   ```

To fix it, replace pre-built host tool of zephyr-sdk with Yocto Native packages.
Append "dtc-natvie" in the DEPENDS variable in zephyr-kernel-common.inc.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
 .../recipes-devtools/zephyr-sdk/zephyr-sdk_0.16.9.bb           | 3 ---
 .../recipes-kernel/zephyr-kernel/zephyr-kernel-common.inc      | 2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/meta-zephyr-core/recipes-devtools/zephyr-sdk/zephyr-sdk_0.16.9.bb b/meta-zephyr-core/recipes-devtools/zephyr-sdk/zephyr-sdk_0.16.9.bb
index 57fe777..3d9e628 100644
--- a/meta-zephyr-core/recipes-devtools/zephyr-sdk/zephyr-sdk_0.16.9.bb
+++ b/meta-zephyr-core/recipes-devtools/zephyr-sdk/zephyr-sdk_0.16.9.bb
@@ -28,9 +28,6 @@  ZEPHYR_SDK_DIR = "${prefix}/zephyr-sdk"
 do_install() {
     install -d ${D}${prefix}
     cp -r ${UNPACKDIR}/zephyr-sdk-${PV} ${D}${ZEPHYR_SDK_DIR}
-
-    # Install host tools
-    ${D}${ZEPHYR_SDK_DIR}/setup.sh -h
 }
 
 SYSROOT_DIRS += "${ZEPHYR_SDK_DIR}"
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 6544475..77d1cfa 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
@@ -29,7 +29,7 @@  EXTRA_OECMAKE:append = "  -DZEPHYR_EXTRA_MODULES=${ZEPHYR_EXTRA_MODULES}"
 
 export ZEPHYR_BASE="${S}/zephyr"
 
-DEPENDS += "gperf-native"
+DEPENDS += "gperf-native dtc-native"
 
 DEPENDS:append:qemuall = " qemu-native qemu-helper-native"