meson.bbclass builds the bindgen arguments as:

    def bindgen_args(d):
        args = '${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} --target=${TARGET_SYS}'

TOOLCHAIN_OPTIONS carries --sysroot, which is enough for C headers. It is not
enough for C++: when clang cross-compiles against a GCC sysroot it does not
infer the libstdc++ include directories from --sysroot alone, so any recipe
running bindgen over a C++ header fails to find the standard library.

mesa hits this with PACKAGECONFIG opencl, which turns on gallium-rusticl and
runs bindgen over rusticl_llvm_bindings.hpp with -x c++ -std=c++17:

    FAILED: src/gallium/frontends/rusticl/rusticl_llvm_bindings.rs
    .../recipe-sysroot/usr/include/llvm/ADT/DenseMapInfo.h:17:10:
        fatal error: 'cassert' file not found
    Unable to generate bindings: clang diagnosed error

Seen on mesa 26.0.5 with oe-core wrynose, aarch64 target, LLVM 22.1.3.

The missing arguments are the staged C++ headers:

    -I${STAGING_INCDIR}/c++/<version>
    -I${STAGING_INCDIR}/c++/<version>/${TARGET_SYS}

Our downstream workaround appends them to bindgen_clang_arguments in
meson.cross from a mesa bbappend, which works but is recipe-specific and
hardcodes a realpath glob over the staged header directory. It also has to run
after do_prepare_recipe_sysroot, since the glob is empty on a clean build.

Reporting rather than sending a patch because the right fix is a design call:
bindgen_args() is generic, so this affects any meson recipe doing C++ bindgen,
not just mesa. Options seem to be teaching bindgen_args() about the C++ include
paths unconditionally, gating it on whether the recipe does C++ bindgen, or
having clang-native resolve the GCC sysroot properly. A maintainer is better
placed to pick.

Happy to test a proposed fix on aarch64.
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#246276): 
https://lists.openembedded.org/g/openembedded-core/message/246276
Mute This Topic: https://lists.openembedded.org/mt/121353089/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to