meson: correct bindgen_clang_argments

Follow the changes in Clang search paths and specify sysroot via the
TOOLCHAIN_OPTIONS, otherwise clang will fail to find system headers when
executed by bindgen.

For SDK packages TOOLCHAIN_OPTIONS don't contain full sysroot path, so
specify the correct directory explicitly.

(From OE-Core rev: a647a0ff4c4eb7a7c1f6ec84a574f7d7796b6178)

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Dmitry Baryshkov 2025-05-05 19:22:30 -07:00 committed by Richard Purdie
parent 251fd55c27
commit d7f705d412

View File

@ -62,6 +62,14 @@ def rust_tool(d, target_var):
cmd = [rustc, "--target", d.getVar(target_var)] + d.getVar("RUSTFLAGS").split()
return "rust = %s" % repr(cmd)
def bindgen_args(d):
args = '${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_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()
return repr(items[0] if len(items) == 1 else items)
addtask write_config before do_configure
do_write_config[vardeps] += "CC CXX AR NM STRIP READELF OBJCOPY CFLAGS CXXFLAGS LDFLAGS RUSTC RUSTFLAGS EXEWRAPPER_ENABLED"
do_write_config() {
@ -93,7 +101,7 @@ cpp_link_args = ${@meson_array('LDFLAGS', d)}
[properties]
needs_exe_wrapper = true
sys_root = '${STAGING_DIR_HOST}'
bindgen_clang_arguments = ['-target', '${@d.getVar('RUST_HOST_SYS')}', '-I${STAGING_INCDIR}']
bindgen_clang_arguments = ${@bindgen_args(d)}
[host_machine]
system = '${@meson_operating_system('HOST_OS', d)}'