bindgen-cli: set CLANG_PATH in native wrapper to native clang
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hello,
I wanted to follow up on this patch. Could you please let me know whether it looks suitable for merging, or if there are any changes you'd like me to make before it can be accepted?
Thanks,
Yogesh
________________________________
From: [email protected] <[email protected]> on behalf of Yogesh Tyagi via lists.openembedded.org <[email protected]>
Sent: Wednesday, July 1, 2026 12:30 AM
To: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>
Subject: [OE-core] [PATCH] bindgen-cli: set CLANG_PATH in native wrapper to native clang
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.
--- .../bindgen-cli/bindgen-cli_0.72.1.bb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
meta/recipes-devtools/bindgen-cli/bindgen-cli_0.72.1.bb +12 -1
@@ -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