From: Yogesh Tyagi <[email protected]>

bindgen uses the clang-sys crate to locate a 'clang' executable for
querying default include paths. clang-sys's search order is CLANG_PATH,
then libclang's directory, then 'llvm-config --bindir', then PATH.

When clang is used as the toolchain, the crossscripts llvm-config wrapper
honours YOCTO_ALTERNATE_EXE_PATH and reports the target sysroot bindir.
clang-sys's 'llvm-config --bindir' step then resolves to a target clang
that cannot execute on the build host, so native bindgen fails with:

  could not run executable .../recipe-sysroot/usr/bin/clang-NN:
  No such file or directory (os error 2)

This is hit, for example, when building mesa with the rusticl/opencl
PACKAGECONFIG, whose do_compile runs the native bindgen against
rusticl_mesa_bindings.h.

Set CLANG_PATH to the native clang in the bindgen wrapper so clang-sys
uses the runnable host binary first, short-circuiting the llvm-config
lookup. The native wrapper already exports LIBCLANG_PATH the same way.

Signed-off-by: Yogesh Tyagi <[email protected]>
---
 .../bindgen-cli/bindgen-cli_0.72.1.bb               | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-devtools/bindgen-cli/bindgen-cli_0.72.1.bb 
b/meta/recipes-devtools/bindgen-cli/bindgen-cli_0.72.1.bb
index 72dadfe52f..1e2b901aab 100644
--- a/meta/recipes-devtools/bindgen-cli/bindgen-cli_0.72.1.bb
+++ b/meta/recipes-devtools/bindgen-cli/bindgen-cli_0.72.1.bb
@@ -11,8 +11,19 @@ SRCREV = "d874de8d646d9b8a3e7ba2db2bcd52f2fba8f1f5"
 
 require ${BPN}-crates.inc
 
+# bindgen uses the clang-sys crate to locate a 'clang' executable for querying
+# default include paths. clang-sys's search order is: CLANG_PATH, libclang's 
dir,
+# 'llvm-config --bindir', then PATH. When clang is the toolchain, the 
crossscripts
+# llvm-config wrapper honours YOCTO_ALTERNATE_EXE_PATH and reports the target
+# sysroot bindir, so clang-sys's 'llvm-config --bindir' step resolves to a 
target
+# clang that cannot run on the build host (native bindgen then fails with
+# "could not run executable .../clang-NN: No such file or directory", e.g. when
+# building mesa with the rusticl/opencl PACKAGECONFIG). Set CLANG_PATH to the
+# native clang so the runnable host binary is used first.
 do_install:append:class-native() {
-       create_wrapper ${D}/${bindir}/bindgen 
LIBCLANG_PATH="${STAGING_LIBDIR_NATIVE}"
+       create_wrapper ${D}/${bindir}/bindgen \
+               LIBCLANG_PATH="${STAGING_LIBDIR_NATIVE}" \
+               CLANG_PATH="${STAGING_BINDIR_NATIVE}/clang"
 }
 
 BBCLASSEXTEND = "native nativesdk"
-- 
2.43.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#239913): 
https://lists.openembedded.org/g/openembedded-core/message/239913
Mute This Topic: https://lists.openembedded.org/mt/120052346/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to