Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] bindgen-cli: set CLANG_PATH in native wrapper to native clang
@ 2026-06-30 19:00 yogesh.tyagi
  2026-07-08 12:41 ` [OE-core] " Bruce Ashfield
  2026-07-12  5:43 ` [PATCH v2] bindgen-cli: set CLANG_PATH in native and nativesdk wrappers to matching clang yogesh.tyagi
  0 siblings, 2 replies; 6+ messages in thread
From: yogesh.tyagi @ 2026-06-30 19:00 UTC (permalink / raw)
  To: openembedded-core; +Cc: raj.khem

From: Yogesh Tyagi <yogesh.tyagi@intel.com>

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 <yogesh.tyagi@intel.com>
---
 .../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



^ permalink raw reply related	[flat|nested] 6+ messages in thread
[parent not found: <18BDF101D1878987.114350@lists.openembedded.org>]

end of thread, other threads:[~2026-07-12  5:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30 19:00 [PATCH] bindgen-cli: set CLANG_PATH in native wrapper to native clang yogesh.tyagi
2026-07-08 12:41 ` [OE-core] " Bruce Ashfield
2026-07-09  6:28   ` Böszörményi Zoltán
2026-07-11 15:44   ` Tyagi, Yogesh
2026-07-12  5:43 ` [PATCH v2] bindgen-cli: set CLANG_PATH in native and nativesdk wrappers to matching clang yogesh.tyagi
     [not found] <18BDF101D1878987.114350@lists.openembedded.org>
2026-07-08  6:23 ` [OE-core] [PATCH] bindgen-cli: set CLANG_PATH in native wrapper to native clang Tyagi, Yogesh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox