[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH v4 2/7] rust: add bindgen step as a meson dependency
From: |
Alex Bennée |
Subject: |
Re: [RFC PATCH v4 2/7] rust: add bindgen step as a meson dependency |
Date: |
Tue, 09 Jul 2024 11:53:57 +0100 |
Manos Pitsidianakis <manos.pitsidianakis@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.pitsidianakis@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
- [RFC PATCH v4 0/7] Add Rust support, implement ARM PL011, Manos Pitsidianakis, 2024/07/04
- [RFC PATCH v4 1/7] build-sys: Add rust feature option, Manos Pitsidianakis, 2024/07/04
- [RFC PATCH v4 3/7] rust: add crate to expose bindings and interfaces, Manos Pitsidianakis, 2024/07/04
- [RFC PATCH v4 2/7] rust: add bindgen step as a meson dependency, Manos Pitsidianakis, 2024/07/04
- Re: [RFC PATCH v4 2/7] rust: add bindgen step as a meson dependency, Paolo Bonzini, 2024/07/08
- Re: [RFC PATCH v4 2/7] rust: add bindgen step as a meson dependency,
Alex Bennée <=
- Re: [RFC PATCH v4 2/7] rust: add bindgen step as a meson dependency, Peter Maydell, 2024/07/09
- Re: [RFC PATCH v4 2/7] rust: add bindgen step as a meson dependency, Paolo Bonzini, 2024/07/09
- Re: [RFC PATCH v4 2/7] rust: add bindgen step as a meson dependency, Daniel P . Berrangé, 2024/07/09
- Re: [RFC PATCH v4 2/7] rust: add bindgen step as a meson dependency, Pierrick Bouvier, 2024/07/11
- Re: [RFC PATCH v4 2/7] rust: add bindgen step as a meson dependency, Manos Pitsidianakis, 2024/07/12
- Re: [RFC PATCH v4 2/7] rust: add bindgen step as a meson dependency, Alex Bennée, 2024/07/09
- Re: [RFC PATCH v4 2/7] rust: add bindgen step as a meson dependency, Zhao Liu, 2024/07/10
- Re: [RFC PATCH v4 2/7] rust: add bindgen step as a meson dependency, Paolo Bonzini, 2024/07/10
- Re: [RFC PATCH v4 2/7] rust: add bindgen step as a meson dependency, Zhao Liu, 2024/07/11
- Re: [RFC PATCH v4 2/7] rust: add bindgen step as a meson dependency, Alex Bennée, 2024/07/09