Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating vendored dependencies breaks the build #42

Closed
dfaggioli opened this issue May 25, 2022 · 11 comments
Closed

Updating vendored dependencies breaks the build #42

dfaggioli opened this issue May 25, 2022 · 11 comments

Comments

@dfaggioli
Copy link

Hi @slp ! :-) So, just ad a foreword, I'm not yet that much into Rust myself, so forgive any inaccuracy/incorrectness of the explanation of the problem.

That said, in openSUSE, we do automatic updates of the vendored dependencies, for Rust packages (I think!). Doing that for libkrun causes some build error.

I believe you should be able to see what happens via this link:
https://build.opensuse.org/build/home:firstyear:branches:Virtualization/openSUSE_Tumbleweed/x86_64/libkrun/_log

But, just in case you don't, or if it disappears, here's what I think is the most relevant part:

[   36s] + cd libkrun-0.1.7
[   36s] + /usr/bin/xz -dc /home/abuild/rpmbuild/SOURCES/vendor.tar.xz
[   36s] + /usr/bin/tar -xof -
[   39s] + STATUS=0
[   39s] + '[' 0 -ne 0 ']'
[   39s] + /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
[   39s] + mkdir .cargo
[   39s] + cp /home/abuild/rpmbuild/SOURCES/cargo_config .cargo/config
[   39s] + RPM_EC=0
[   39s] ++ jobs -p
[   39s] + exit 0
[   39s] Executing(%build): /usr/bin/bash -e /var/tmp/rpm-tmp.V4UMJQ
[   39s] + umask 022
[   39s] + cd /home/abuild/rpmbuild/BUILD
[   39s] + /usr/bin/rm -rf /home/abuild/rpmbuild/BUILDROOT/libkrun-0.1.7-14.1.x86_64
[   39s] ++ dirname /home/abuild/rpmbuild/BUILDROOT/libkrun-0.1.7-14.1.x86_64
[   39s] + /usr/bin/mkdir -p /home/abuild/rpmbuild/BUILDROOT
[   39s] + /usr/bin/mkdir /home/abuild/rpmbuild/BUILDROOT/libkrun-0.1.7-14.1.x86_64
[   39s] + cd libkrun-0.1.7
[   39s] + export RUSTFLAGS=-Clink-arg=-Wl,-z,relro,-z,now
[   39s] + RUSTFLAGS=-Clink-arg=-Wl,-z,relro,-z,now
[   39s] + /usr/bin/make -O -j8 V=1 VERBOSE=1
[   40s] gcc -O2 -static -Wall -o init/init init/init.c
[   53s] cargo build --release
[   53s]    Compiling libc v0.2.126
[   53s]    Compiling bitflags v1.3.2
[   53s]    Compiling cfg-if v1.0.0
[   53s]    Compiling version_check v0.9.4
[   53s]    Compiling kvm-ioctls v0.11.0
[   53s]    Compiling log v0.4.17
[   53s]    Compiling once_cell v1.12.0
[   53s]    Compiling lazy_static v1.4.0
[   53s]    Compiling arch_gen v0.1.0 (/home/abuild/rpmbuild/BUILD/libkrun-0.1.7/src/arch_gen)
[   53s]    Compiling cc v1.0.73
[   53s]    Compiling virtio_gen v0.1.0 (/home/abuild/rpmbuild/BUILD/libkrun-0.1.7/src/virtio_gen)
[   53s]    Compiling ahash v0.7.6
[   53s]    Compiling libkrun v0.1.7 (/home/abuild/rpmbuild/BUILD/libkrun-0.1.7/src/libkrun)
[   53s]    Compiling vmm-sys-util v0.9.0
[   53s]    Compiling getrandom v0.2.6
[   53s]    Compiling vm-memory v0.8.0 (https://github.com/rust-vmm/vm-memory#781d300d)
[   53s]    Compiling hashbrown v0.11.2
[   53s]    Compiling utils v0.1.0 (/home/abuild/rpmbuild/BUILD/libkrun-0.1.7/src/utils)
[   53s]    Compiling kvm-bindings v0.5.0
[   53s]    Compiling logger v0.1.0 (/home/abuild/rpmbuild/BUILD/libkrun-0.1.7/src/logger)
[   53s]    Compiling polly v0.0.1 (/home/abuild/rpmbuild/BUILD/libkrun-0.1.7/src/polly)
[   53s] warning: use of deprecated associated function `std::sync::atomic::AtomicUsize::compare_and_swap`: Use `compare_exchange` or `compare_exchange_weak` instead
[   53s]    --> src/logger/src/logger.rs:318:21
[   53s]     |
[   53s] 318 |         match STATE.compare_and_swap(UNINITIALIZED, locked_state, Ordering::SeqCst) {
[   53s]     |                     ^^^^^^^^^^^^^^^^
[   53s]     |
[   53s]     = note: `#[warn(deprecated)]` on by default
[   53s] 
[   53s]    Compiling kernel v0.1.0 (/home/abuild/rpmbuild/BUILD/libkrun-0.1.7/src/kernel)
[   53s]    Compiling hvf v0.1.0 (/home/abuild/rpmbuild/BUILD/libkrun-0.1.7/src/hvf)
[   53s]    Compiling lru v0.6.6
[   53s] warning: `logger` (lib) generated 1 warning
[   53s]    Compiling arch v0.1.0 (/home/abuild/rpmbuild/BUILD/libkrun-0.1.7/src/arch)
[   53s]    Compiling cpuid v0.1.0 (/home/abuild/rpmbuild/BUILD/libkrun-0.1.7/src/cpuid)
[   53s] warning: unnecessary trailing semicolon
[   53s]    --> src/cpuid/src/brand_string.rs:225:10
[   53s]     |
[   53s] 225 |         };
[   53s]     |          ^ help: remove this semicolon
[   53s]     |
[   53s]     = note: `#[warn(redundant_semicolons)]` on by default
[   53s] 
[   53s] error[E0308]: mismatched types
[   53s]    --> src/arch/src/x86_64/msr.rs:221:19
[   53s]     |
[   53s] 221 |     vcpu.set_msrs(&msrs)
[   53s]     |                   ^^^^^ expected struct `vmm_sys_util::fam::FamStructWrapper`, found enum `std::result::Result`
[   53s]     |
[   53s]     = note: expected reference `&vmm_sys_util::fam::FamStructWrapper<kvm_msrs>`
[   53s]                found reference `&std::result::Result<vmm_sys_util::fam::FamStructWrapper<kvm_msrs>, vmm_sys_util::fam::Error>`
[   53s] 
[   53s] error[E0599]: no method named `as_fam_struct_ref` found for enum `std::result::Result` in the current scope
[   53s]    --> src/arch/src/x86_64/msr.rs:224:44
[   53s]     |
[   53s] 224 |             if msrs_written as u32 != msrs.as_fam_struct_ref().nmsrs {
[   53s]     |                                            ^^^^^^^^^^^^^^^^^ method not found in `std::result::Result<vmm_sys_util::fam::FamStructWrapper<kvm_msrs>, vmm_sys_util::fam::Error>`
[   53s] 
[   53s] Some errors have detailed explanations: E0308, E0599.
[   53s] For more information about an error, try `rustc --explain E0308`.
[   53s] error: could not compile `arch` due to 2 previous errors

And our Rust maintainer (hello @Firstyear :-D) believes this is better dealt with here, upstream. What do you think?

@Firstyear
Copy link

That's right @dfaggioli :)

You can reproduce this with:

git clone https://github.com/containers/libkrun.git
cd libkrun
git checkout v0.1.7
cargo update
cargo build
warning: use of deprecated associated function `std::sync::atomic::AtomicUsize::compare_and_swap`: Use `compare_exchange` or `compare_exchange_weak` instead
   --> src/logger/src/logger.rs:318:21
    |
318 |         match STATE.compare_and_swap(UNINITIALIZED, locked_state, Ordering::SeqCst) {
    |                     ^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default

   Compiling cpuid v0.1.0 (/home/886b45ce-98b2-4d79-9069-c9ff25bc0232/development/libkrun/src/cpuid)
warning: unnecessary trailing semicolon
   --> src/cpuid/src/brand_string.rs:225:10
    |
225 |         };
    |          ^ help: remove this semicolon
    |
    = note: `#[warn(redundant_semicolons)]` on by default

warning: `logger` (lib) generated 1 warning
   Compiling arch v0.1.0 (/home/886b45ce-98b2-4d79-9069-c9ff25bc0232/development/libkrun/src/arch)
   Compiling kernel v0.1.0 (/home/886b45ce-98b2-4d79-9069-c9ff25bc0232/development/libkrun/src/kernel)
   Compiling hvf v0.1.0 (/home/886b45ce-98b2-4d79-9069-c9ff25bc0232/development/libkrun/src/hvf)
error[E0308]: mismatched types
   --> src/arch/src/x86_64/msr.rs:221:19
    |
221 |     vcpu.set_msrs(&msrs)
    |                   ^^^^^ expected struct `vmm_sys_util::fam::FamStructWrapper`, found enum `std::result::Result`
    |
    = note: expected reference `&vmm_sys_util::fam::FamStructWrapper<kvm_msrs>`
               found reference `&std::result::Result<vmm_sys_util::fam::FamStructWrapper<kvm_msrs>, vmm_sys_util::fam::Error>`

error[E0599]: no method named `as_fam_struct_ref` found for enum `std::result::Result` in the current scope
   --> src/arch/src/x86_64/msr.rs:224:44
    |
224 |             if msrs_written as u32 != msrs.as_fam_struct_ref().nmsrs {
    |                                            ^^^^^^^^^^^^^^^^^ method not found in `std::result::Result<vmm_sys_util::fam::FamStructWrapper<kvm_msrs>, vmm_sys_util::fam::Error>`

Some errors have detailed explanations: E0308, E0599.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `arch` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
warning: `cpuid` (lib) generated 1 warning

So either you need to pin to an exact version of cpuid, or maybe there is a fix in a newer version? There seems to be a different build error on latest main.

Hope that helps!

@slp
Copy link
Contributor

slp commented May 26, 2022

Hi! Those issues should be fixed in latest upstream code. Is it also failing for you with it?

@Firstyear
Copy link

Hi there! It works with the latest upstream commits, but the problem is that on the released version it fails, and because it's a distro ... well, the maintainers prefer to use the released version. Is there a schedule for when the next release will be that we can update to?

@slp
Copy link
Contributor

slp commented May 26, 2022

I see. We're about to introduce some breaking changes in the library in 0.2.0, so I guess we can bump now the version now to 0.1.8 so you can update to this one, fix your build, and stay longer if you need to. How does that sound to you?

@slp
Copy link
Contributor

slp commented May 26, 2022

I've just tagged 0.1.8. Please let me know if that works for you.

@dfaggioli
Copy link
Author

Hey @slp ! Great, thank you very much for the tag. I'll update our packages to 0.1.8 ASAP. Hopefully, I'll move stay up to date even when you release 0.2.0, as Tumbleweed is a rolling one, but let's see (and let's fix this for now)

@Firstyear
Copy link

Thank you both for your help ❤️

@slp
Copy link
Contributor

slp commented May 27, 2022

I've just noticed Linux-aarch64 is broken on 0.1.8. I've just reverted the tag and will be pushing the fix and retagging ASAP.

@dfaggioli
Copy link
Author

Ah, ok... Just seen this only now. And in fact, I was about to report this:

[   20s] error[E0425]: cannot find function, tuple struct or tuple variant `KVM_MEMORY_ENCRYPT_OP` in this scope
[   20s]   --> /home/abuild/rpmbuild/BUILD/libkrun-0.1.8/vendor/kvm-ioctls/src/ioctls/vm.rs:75:53
[   20s]    |
[   20s] 75 |         let ret = unsafe { ioctl_with_mut_ref(self, KVM_MEMORY_ENCRYPT_OP(), cmd) };
[   20s]    |                                                     ^^^^^^^^^^^^^^^^^^^^^ not found in this scope
[   20s] 
[   20s] error[E0425]: cannot find function, tuple struct or tuple variant `KVM_MEMORY_ENCRYPT_REG_REGION` in this scope
[   20s]   --> /home/abuild/rpmbuild/BUILD/libkrun-0.1.8/vendor/kvm-ioctls/src/ioctls/vm.rs:87:40
[   20s]    |
[   20s] 87 |         let ret = ioctl_with_ref(self, KVM_MEMORY_ENCRYPT_REG_REGION(), enc_region);
[   20s]    |                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
[   20s] 
[   20s] For more information about this error, try `rustc --explain E0425`.
[   20s] error: could not compile `kvm-ioctls` due to 2 previous errors

:-)

Thanks again for helping us with this. I'll try the update again when it's fixed

@slp
Copy link
Contributor

slp commented May 27, 2022

I've created the 0.1.8 again. It should be working now on both x86_64 and aarch64. Please let me know if you find any problem.

@dfaggioli
Copy link
Author

I've created the 0.1.8 again. It should be working now on both x86_64 and aarch64. Please let me know if you find any problem.

Ok, great! I'm also done, and I confirm that both x86 and aarch64 are green. I think we can close this issue :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants