All of lore.kernel.org
 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

* Re: [OE-core] [PATCH] bindgen-cli: set CLANG_PATH in native wrapper to native clang
       [not found] <18BDF101D1878987.114350@lists.openembedded.org>
@ 2026-07-08  6:23 ` Tyagi, Yogesh
  0 siblings, 0 replies; 6+ messages in thread
From: Tyagi, Yogesh @ 2026-07-08  6:23 UTC (permalink / raw)
  To: openembedded-core@lists.openembedded.org, Tyagi, Yogesh
  Cc: raj.khem@gmail.com

[-- Attachment #1: Type: text/plain, Size: 3388 bytes --]

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: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> on behalf of Yogesh Tyagi via lists.openembedded.org <yogesh.tyagi=intel.com@lists.openembedded.org>
Sent: Wednesday, July 1, 2026 12:30 AM
To: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org>
Cc: raj.khem@gmail.com <raj.khem@gmail.com>
Subject: [OE-core] [PATCH] bindgen-cli: set CLANG_PATH in native wrapper to native clang

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


[-- Attachment #2: Type: text/html, Size: 5802 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH] bindgen-cli: set CLANG_PATH in native wrapper to native clang
  2026-06-30 19:00 [PATCH] bindgen-cli: set CLANG_PATH in native wrapper to native clang yogesh.tyagi
@ 2026-07-08 12:41 ` 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
  1 sibling, 2 replies; 6+ messages in thread
From: Bruce Ashfield @ 2026-07-08 12:41 UTC (permalink / raw)
  To: openembedded-core, yogesh.tyagi; +Cc: raj.khem

On Tue, Jul 1, 2026, Yogesh Tyagi wrote:
> 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.

The reasoning is sound, and beyond the mesa rusticl case this also helps
the rust-in-kernel build: kernel-yocto-rust.bbclass pulls in both
clang-native and bindgen-cli-native, so native bindgen can hit the same
target-clang-via-llvm-config lookup. Pinning CLANG_PATH to the native
clang that matches the native libclang is the consistent thing to do
there too, so:

Reviewed-by: Bruce Ashfield <bruce.ashfield@gmail.com>

One thing while you're here: the recipe is BBCLASSEXTEND = "native
nativesdk", but the wrapper fix is do_install:append:class-native() only.
Unless I'm misreading it, that leaves the nativesdk bindgen wrapper with
just LIBCLANG_PATH and no CLANG_PATH, so an SDK that runs bindgen (e.g.
rust kernel-module development in the SDK, which is being wired up
separately) would still hit the identical "could not run executable
.../clang-NN" failure. If that's right, could you extend the CLANG_PATH
export to the nativesdk wrapper as well? A shared helper (or a
class-native/class-nativesdk pair pointing at the respective
STAGING_BINDIR) would cover both. If nativesdk is already handled some
other way, ignore me.

Bruce


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH] bindgen-cli: set CLANG_PATH in native wrapper to native clang
  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
  1 sibling, 0 replies; 6+ messages in thread
From: Böszörményi Zoltán @ 2026-07-09  6:28 UTC (permalink / raw)
  To: bruce.ashfield, openembedded-core, yogesh.tyagi; +Cc: raj.khem

2026. 07. 08. 14:41 keltezéssel, Bruce Ashfield via lists.openembedded.org írta:
> On Tue, Jul 1, 2026, Yogesh Tyagi wrote:
>> 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.
> The reasoning is sound, and beyond the mesa rusticl case this also helps
> the rust-in-kernel build: kernel-yocto-rust.bbclass pulls in both
> clang-native and bindgen-cli-native, so native bindgen can hit the same
> target-clang-via-llvm-config lookup. Pinning CLANG_PATH to the native
> clang that matches the native libclang is the consistent thing to do
> there too, so:
>
> Reviewed-by: Bruce Ashfield <bruce.ashfield@gmail.com>

Tested-by: Zoltán Böszörményi <zboszor@gmail.com>

> One thing while you're here: the recipe is BBCLASSEXTEND = "native
> nativesdk", but the wrapper fix is do_install:append:class-native() only.
> Unless I'm misreading it, that leaves the nativesdk bindgen wrapper with
> just LIBCLANG_PATH and no CLANG_PATH, so an SDK that runs bindgen (e.g.
> rust kernel-module development in the SDK, which is being wired up
> separately) would still hit the identical "could not run executable
> .../clang-NN" failure. If that's right, could you extend the CLANG_PATH
> export to the nativesdk wrapper as well? A shared helper (or a
> class-native/class-nativesdk pair pointing at the respective
> STAGING_BINDIR) would cover both. If nativesdk is already handled some
> other way, ignore me.
>
> Bruce
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#240483): https://lists.openembedded.org/g/openembedded-core/message/240483
> Mute This Topic: https://lists.openembedded.org/mt/120052346/3617728
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [zboszor@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH] bindgen-cli: set CLANG_PATH in native wrapper to native clang
  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
  1 sibling, 0 replies; 6+ messages in thread
From: Tyagi, Yogesh @ 2026-07-11 15:44 UTC (permalink / raw)
  To: openembedded-core@lists.openembedded.org,
	bruce.ashfield@gmail.com
  Cc: raj.khem@gmail.com

On Wed, 2026-07-08 at 05:41 -0700, Bruce Ashfield wrote:
> On Tue, Jul 1, 2026, Yogesh Tyagi wrote:
> > 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.
> 
> The reasoning is sound, and beyond the mesa rusticl case this also
> helps
> the rust-in-kernel build: kernel-yocto-rust.bbclass pulls in both
> clang-native and bindgen-cli-native, so native bindgen can hit the
> same
> target-clang-via-llvm-config lookup. Pinning CLANG_PATH to the native
> clang that matches the native libclang is the consistent thing to do
> there too, so:
> 
> Reviewed-by: Bruce Ashfield <bruce.ashfield@gmail.com>
> 
> One thing while you're here: the recipe is BBCLASSEXTEND = "native
> nativesdk", but the wrapper fix is do_install:append:class-native()
> only.
> Unless I'm misreading it, that leaves the nativesdk bindgen wrapper
> with
> just LIBCLANG_PATH and no CLANG_PATH, so an SDK that runs bindgen
> (e.g.
> rust kernel-module development in the SDK, which is being wired up
> separately) would still hit the identical "could not run executable
> .../clang-NN" failure. If that's right, could you extend the
> CLANG_PATH
> export to the nativesdk wrapper as well? A shared helper (or a
> class-native/class-nativesdk pair pointing at the respective
> STAGING_BINDIR) would cover both. If nativesdk is already handled
> some
> other way, ignore me.


Thanks Bruce, good catch — you're right that the SDK case was
uncovered.

One clarification: in v1 the recipe only had do_install:append:class-
native(), so the nativesdk bindgen had no wrapper at all — not even
LIBCLANG_PATH. Same failure mode, just with nothing set rather than
only CLANG_PATH missing.

v2 adds a class-nativesdk wrapper. I went with an explicit class-
native/class-nativesdk pair rather than a shared helper, because the
staging dirs aren't symmetric between the two classes and a shared
"point at the respective STAGING_BINDIR" helper actually breaks:

native uses STAGING_*_NATIVE, which sits entirely under base_prefix, so
create_wrapper's relocation rewrites it cleanly.
nativesdk's STAGING_LIBDIR/STAGING_BINDIR are STAGING_DIR_HOST (recipe-
sysroot, i.e. TMPDIR) + the SDK path. create_wrapper only relocates the
base_prefix substring, so the recipe-sysroot prefix stays baked into
the shipped wrapper. I hit exactly that: do_package_qa failed with
contains reference to TMPDIR [buildpaths].
So the nativesdk wrapper uses the plain on-target ${libdir}/${bindir}
instead, which relocate fully. Verified by building both variants:
bindgen-cli-native and nativesdk-bindgen-cli both build and pass
package QA, and both generated wrappers come out relocatable as
CLANG_PATH=$realdir/../../usr/bin/clang.

Since the patch grew a new task, I dropped your Reviewed-by from v2 —
happy to carry it if you're good with the nativesdk addition.

> 
> Bruce

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] bindgen-cli: set CLANG_PATH in native and nativesdk wrappers to matching clang
  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-12  5:43 ` yogesh.tyagi
  1 sibling, 0 replies; 6+ messages in thread
From: yogesh.tyagi @ 2026-07-12  5:43 UTC (permalink / raw)
  To: openembedded-core

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 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, and when building rust-in-kernel via
kernel-yocto-rust.bbclass, which pulls in clang-native and
bindgen-cli-native.

Set CLANG_PATH to the clang that matches the wrapped libclang so
clang-sys uses the runnable binary first, short-circuiting the
llvm-config lookup. The wrapper already exports LIBCLANG_PATH the same
way.

The recipe is BBCLASSEXTEND = "native nativesdk", but only the native
variant had a wrapper. Add the equivalent nativesdk wrapper so an SDK
that runs bindgen (e.g. rust kernel-module development in the SDK) does
not hit the identical target-clang failure. The native wrapper uses
STAGING_*_NATIVE; the nativesdk wrapper uses the on-target ${libdir}/
${bindir} so create_wrapper's relocation rewrites the full path and the
shipped wrapper carries no build-time (TMPDIR) reference.

Signed-off-by: Yogesh Tyagi <yogesh.tyagi@intel.com>
---
v2:
 - Add the missing nativesdk bindgen wrapper (v1 only wrapped native),
   so an SDK that runs bindgen does not hit the same target-clang failure.
 - The nativesdk wrapper uses the on-target ${libdir}/${bindir} rather
   than STAGING_LIBDIR/STAGING_BINDIR: the latter include the recipe
   sysroot (TMPDIR) prefix, which create_wrapper's relocation does not
   strip, so the shipped wrapper failed do_package_qa with a buildpaths
   (reference to TMPDIR) error.

 .../bindgen-cli/bindgen-cli_0.72.1.bb         | 19 ++++++++++++++++++-
 1 file changed, 18 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..2ef797c156 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,25 @@ 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"
+}
+
+do_install:append:class-nativesdk() {
+	create_wrapper ${D}/${bindir}/bindgen \
+		LIBCLANG_PATH="${libdir}" \
+		CLANG_PATH="${bindir}/clang"
 }
 
 BBCLASSEXTEND = "native nativesdk"
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.