[Libguestfs] [libnbd PATCH v5 01/12] rust: create basic Rust bindings

Eric Blake eblake at redhat.com
Fri Aug 4 14:02:45 UTC 2023


On Fri, Aug 04, 2023 at 10:50:44AM +0000, Tage Johansson wrote:
> 
> 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.

Yeah, I've been committing things that will definitely affect Rust
bindings (as I had to touch all the other languages), with more to
land soon.  Resolving merge conflicts during rebasing to latest
changes is, for good or bad, a necessary part of open source
programming (the more active a project, the more likely you have
people submitting work in parallel that needs to be resolved
together).  If you have questions about my recent additions, I'm happy
to answer.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org


More information about the Libguestfs mailing list