diff mbox series

meson: Apply clang specific OVERRIDES for bindgen

Message ID 20260629-fix-rust-bindgen-for-big-little-arch-v1-1-7f7d70c9d593@schnwalter.eu
State New
Headers show
Series meson: Apply clang specific OVERRIDES for bindgen | expand

Commit Message

Walter Werner Schneider June 29, 2026, 8:48 p.m. UTC
The Rust bindgen uses libclang to parse target headers, so the arguments
passed to bindgen_clang_arguments must be valid clang arguments.

Changing TCOVERRIDE to toolchain-clang applies various fixes to those
arguments, including big.LITTLE architecture values fix for -mcpu.

Note that the target attribute depends on the system beeing built for,
it is either the host system, the target system or the SDK system.

Fixes: a647a0ff4c4e ("meson: correct bindgen_clang_argments")
Signed-off-by: Walter Werner Schneider <contact@schnwalter.eu>
---
 meta/classes-recipe/meson.bbclass | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)


---
base-commit: 4a72f62d32e3fd3a88c2b92671f6dd75ef35fc44
change-id: 20260604-fix-rust-bindgen-for-big-little-arch-34788066c4ae

Best regards,
diff mbox series

Patch

diff --git a/meta/classes-recipe/meson.bbclass b/meta/classes-recipe/meson.bbclass
index 9bed293603..8a37aa45ed 100644
--- a/meta/classes-recipe/meson.bbclass
+++ b/meta/classes-recipe/meson.bbclass
@@ -59,11 +59,14 @@  def rust_tool(d, target_var):
     return "rust = %s" % repr(cmd)
 
 def bindgen_args(d):
-    args = '${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}'
+    args = '${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} --target=${HOST_SYS}'
     # For SDK packages TOOLCHAIN_OPTIONS don't contain full sysroot path
     if bb.data.inherits_class("nativesdk", d):
         args += ' --sysroot=${STAGING_DIR_HOST}${SDKPATHNATIVE}${prefix_nativesdk}'
-    items = d.expand(args).split()
+    # Rust bindgen uses libclang under the hood. Apply variable overrides for
+    # clang; Fixes big.LITTLE -mcpu values.
+    localdata = d.createCopy()\n    localdata.setVar('TCOVERRIDE', 'toolchain-clang');
+    items = localdata.expand(args).split()
     return repr(items[0] if len(items) == 1 else items)
 
 addtask write_config before do_configure