[Libguestfs] [libnbd PATCH v5 01/12] rust: create basic Rust bindings
Tage Johansson
tage.j.lists at posteo.net
Fri Aug 4 10:50:44 UTC 2023
On 8/4/2023 10:54 AM, Richard W.M. Jones wrote:
> I applied the first 4 patches to my local repo.
> 'make clean' now fails at:
>
> error: failed to load manifest for dependency `libnbd-sys`
> Caused by:
> failed to parse manifest at `/home/rjones/d/libnbd/rust/libnbd-sys/Cargo.toml`
> Caused by:
> no targets specified in the manifest
> either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present
> make[1]: *** [Makefile:1057: clean-local] Error 101
> make[1]: Leaving directory '/home/rjones/d/libnbd/rust'
>
> I'm not sure what that means. rust/libnbd-sys/Cargo.toml exists.
It is because rust/libnbd-sys/src/lib.rs is generated and hence does not
exist before running make the first time. I have solved that in v6.
> ./configure works which is good:
>
> checking for cargo... cargo
> checking for rustfmt... rustfmt
> checking if cargo is usable... yes
> ...
> Rust ................................... yes
>
> However the generator fails to compile with:
>
> make[3]: Entering directory '/home/rjones/d/libnbd/generator'
> ocamlc.opt -g -annot -safe-string -warn-error +C+D+E+F+L+M+P+S+U+V+Y+Z+X+52-3 -I . -I . \
> -I +str str.cma -I +unix unix.cma utils.mli utils.ml state_machine.mli state_machine.ml API.mli API.ml state_machine_generator.mli state_machine_generator.ml C.mli C.ml Python.mli Python.ml OCaml.mli OCaml.ml GoLang.mli GoLang.ml RustSys.mli RustSys.ml Rust.mli Rust.ml generator.ml -o generator
> File "generator.ml", line 65, characters 2-11:
> 65 | output_to ~formatter:(Some Rustfmt) "rust/libnbd-sys/src/lib.rs" RustSys.generate_rust_sys_bindings;
> ^^^^^^^^^
> Error: This function has type string -> (unit -> 'weak1) -> unit
> It is applied to too many arguments; maybe you forgot a `;'.
>
> This confused me for a while, but I think it's because this series
> depends on another series or needs to be rebased?
>
> I removed the ~formatter parameter to get it to compile.
Hmmm, I think there is a patch I thought was upstream, which doesn't
seem to be so. I'll include that patch in v6.
> The next problem is:
>
> /home/rjones/d/libnbd/run cargo build
> Compiling libnbd v0.1.0 (/home/rjones/d/libnbd/rust)
> error: expected one of `:`, `;`, or `=`, found `-`
> --> src/bindings.rs:116:29
> |
> 116 | pub const CONTEXT_QEMU_DIRTY-BITMAP:: &[u8] = b"qemu:dirty-bitmap:";
> | ^ expected one of `:`, `;`, or `=`
I've fixed that as well. I was not testing on the latest changes
upstream so I didn't encounter that error before.
> error[E0599]: no method named `set_debug_callback` found for struct `Handle` in the current scope
> --> src/handle.rs:38:21
> |
> 23 | pub struct Handle {
> | ----------------- method `set_debug_callback` not found for this struct
> ...
> 38 | nbd.set_debug_callback(|func_name, msg| {
> | ----^^^^^^^^^^^^^^^^^^ method not found in `Handle`
> [and some more]
>
> It might be an idea to run this command to check that the series is
> bisectable:
>
> git rebase -i HEAD~12 -x 'make clean && make && make check'
>
> It will generate a series of rebase commands which look like:
>
> pick 7475e8560a rust: create basic Rust bindings
> exec make clean && make && make check
> pick c48c7eee0f rust: Add a couple of integration tests
> exec make clean && make && make check
> pick 16debe7848 rust: Make it possible to run tests with Valgrind
> exec make clean && make && make check
> [etc]
>
> which will do a full build cycle after every patch to make sure they
> all work incrementally.
I will try that.
Best regards,
Tage
> Rich.
>
More information about the Libguestfs
mailing list