On 9/4/2024 7:01 PM, Paolo Bonzini wrote:
On Wed, Aug 28, 2024 at 6:12 AM Manos Pitsidianakis
<manos.pitsidiana...@linaro.org> wrote:

Add rust/qemu-api, which exposes rust-bindgen generated FFI bindings and
provides some declaration macros for symbols visible to the rest of
QEMU.

The only comment I have is that I would drop the allocator support
completely. It adds complications and, at least initially, we can
plan/hope that all cross-language allocations go through a constructor
function like error_setg() or object_new().

In the case of QOM, if we wanted to allocate objects in a Box rather
than malloc-ed memory, we could also put in the object a free function
that calls

    mem::drop(Box::from_raw(p))

Fixing rust.bindgen() to use the right CLANG_PATH/LIBCLANG_PATH should
probably be done in meson itself. The (not too hard) alternative is to
just use a custom_target.

To unblock this series at the moment a custom_target() is the only way. Fixes to either meson or clang-sys crate will take some time before they are available in a public release.

The ideal fix to me is that clang-sys always find clang and libclang of the same version. I can take a look at that crate and think about how that can be done.

Meanwhile, I opened a PR [1] to discuss this with the meson community. The PR itself adds the env argument to rust.bindgen(), but as you suggested meson can do more, e.g., when given a native clang executable, meson can search for the corresponding libclang and sets CLANG_PATH/LIBCLANG_PATH accordingly. I'll keep collecting their feedback and refining the changes in that PR.

[1] https://github.com/mesonbuild/meson/pull/13631


Paolo


Reply via email to