Manos Pitsidianakis <manos.pitsidiana...@linaro.org> writes:

> Add mechanism to generate rust hw targets that depend on a custom
> bindgen target for rust bindings to C.
>
> This way bindings will be created before the rust crate is compiled.
>
> The bindings will end up in BUILDDIR/{target}-generated.rs and have the same 
> name
> as a target:
>
> ninja aarch64-softmmu-generated.rs
>
> The way the bindings are generated is:
>
> 1. All required C headers are included in a single file, in our case
>    rust/wrapper.h for convenience. Otherwise we'd have to provide a list
>    of headers every time to the bindgen tool.
>
> 2. Meson creates a generated_rs target that runs bindgen making sure
>    the architecture etc header dependencies are present.
>
> 3. The generated_rs target takes a list of files, type symbols,
>    function symbols to block from being generated. This is not necessary
>    for the bindings to work, but saves us time and space.
>
> 4. Meson creates rust hardware target dependencies from the rust_targets
>    dictionary defined in rust/meson.build.
>
>    Since we cannot declare a dependency on generated_rs before it is
>    declared in meson.build, the rust crate targets must be defined after
>    the generated_rs target for each target architecture is defined. This
>    way meson sets up the dependency tree properly.
>
> 5. After compiling each rust crate with the cargo_wrapper.py script,
>    its static library artifact is linked as a `whole-archive` with the
>    final binary.
>
> Signed-off-by: Manos Pitsidianakis <manos.pitsidiana...@linaro.org>
<snip>
> +
> +msrv = {
> +  'rustc': '1.77.2',
> +  'cargo': '1.77.2',
> +  'bindgen': '0.69.4',
> +}

This is still pretty bleeding edge (it even tripped up on the
.cargo/bin/cargo I have installed). This needs to be set to the
baseline which from:

  https://wiki.qemu.org/RustInQemu/2022

Looks to be 1.24.0 for rustc and I guess even lower for cargo (Debian
says 0.66.0). While it might make sense to delay merging if we are
waiting for one distro to produce a new LTS we shouldn't be needing
rustup by default.


-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro

Reply via email to