rust-vmm / rust-vmm-ci

Apache License 2.0
18 stars 33 forks source link

Problems with building `vhost-device-sound` in musl #146

Open epilys opened 9 months ago

epilys commented 9 months ago
          Setting `export PKG_CONFIG_ALLOW_CROSS=1` was enough to get through that, but:
  1. I can't build pipewire with musl, it complains stdbool.h is missing. I tried installing musl-dev and setting the library path to musl's dir in .cargo/config.toml:

    [target.x86_64-unknown-linux-musl]
    linker = "ld"
    rustflags = ["-Ctarget-feature=-crt-static", "-Clink-self-contained=on", "-L/usr/lib/x86_64-linux-musl", "-Clink-args=--dynamic-linker /lib/ld-musl-x86_64.so.1"]

    but no dice. Any ideas?

  2. Disabling default features with --no-default-features gives me errors from rust-vmm crates:

Compilation errors.. ```shell Compiling vhost-user-backend v0.10.1 error[E0277]: the trait bound `::M: vm_memory::guest_memory::GuestMemory` is not satisfied --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/vhost-user-backend-0.10.1/src/vring.rs:145:23 | 145 | .add_used(self.mem.memory().deref(), desc_index, len) | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `vm_memory::guest_memory::GuestMemory` is not implemented for `::M` | | | required by a bound introduced by this call | note: required by a bound in `add_used` --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/virtio-queue-0.9.1/src/lib.rs:193:20 | 193 | fn add_used(&mut self, mem: &M, head_index: u16, len: u32) | ^^^^^^^^^^^ required by this bound in `QueueT::add_used` help: consider further restricting the associated type | 143 | pub fn add_used(&mut self, desc_index: u16, len: u32) -> Result<(), VirtQueError> where ::M: vm_memory::guest_memory::GuestMemory { | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `::M: vm_memory::guest_memory::GuestMemory` is not satisfied --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/vhost-user-backend-0.10.1/src/vring.rs:159:40 | 159 | self.queue.enable_notification(self.mem.memory().deref()) | ------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `vm_memory::guest_memory::GuestMemory` is not implemented for `::M` | | | required by a bound introduced by this call | note: required by a bound in `enable_notification` --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/virtio-queue-0.9.1/src/lib.rs:201:31 | 201 | fn enable_notification(&mut self, mem: &M) -> Result; | ^^^^^^^^^^^ required by this bound in `QueueT::enable_notification` help: consider further restricting the associated type | 158 | pub fn enable_notification(&mut self) -> Result where ::M: vm_memory::guest_memory::GuestMemory { | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `::M: vm_memory::guest_memory::GuestMemory` is not satisfied --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/vhost-user-backend-0.10.1/src/vring.rs:164:41 | 164 | self.queue.disable_notification(self.mem.memory().deref()) | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `vm_memory::guest_memory::GuestMemory` is not implemented for `::M` | | | required by a bound introduced by this call | note: required by a bound in `disable_notification` --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/virtio-queue-0.9.1/src/lib.rs:204:32 | 204 | fn disable_notification(&mut self, mem: &M) -> Result<(), Error>; | ^^^^^^^^^^^ required by this bound in `QueueT::disable_notification` help: consider further restricting the associated type | 163 | pub fn disable_notification(&mut self) -> Result<(), VirtQueError> where ::M: vm_memory::guest_memory::GuestMemory { | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `::M: vm_memory::guest_memory::GuestMemory` is not satisfied --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/vhost-user-backend-0.10.1/src/vring.rs:169:39 | 169 | self.queue.needs_notification(self.mem.memory().deref()) | ------------------ ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `vm_memory::guest_memory::GuestMemory` is not implemented for `::M` | | | required by a bound introduced by this call | note: required by a bound in `needs_notification` --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/virtio-queue-0.9.1/src/lib.rs:212:30 | 212 | fn needs_notification(&mut self, mem: &M) -> Result; | ^^^^^^^^^^^ required by this bound in `QueueT::needs_notification` help: consider further restricting the associated type | 168 | pub fn needs_notification(&mut self) -> Result where ::M: vm_memory::guest_memory::GuestMemory { | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ error[E0308]: mismatched types --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/vhost-user-backend-0.10.1/src/vring.rs:185:41 | 185 | .try_set_desc_table_address(GuestAddress(desc_table))?; | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^ expected `GuestAddress`, found a different `GuestAddress` | | | arguments to this method are incorrect | = note: `GuestAddress` and `GuestAddress` have similar names, but are actually distinct types note: `GuestAddress` is defined in crate `vm_memory` --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/vm-memory-0.12.2/src/guest_memory.rs:109:1 | 109 | pub struct GuestAddress(pub u64); | ^^^^^^^^^^^^^^^^^^^^^^^ note: `GuestAddress` is defined in crate `vm_memory` --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/vm-memory-0.13.1/src/guest_memory.rs:111:1 | 111 | pub struct GuestAddress(pub u64); | ^^^^^^^^^^^^^^^^^^^^^^^ = note: perhaps two different versions of crate `vm_memory` are being used? note: method defined here --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/virtio-queue-0.9.1/src/queue.rs:132:12 | 132 | pub fn try_set_desc_table_address(&mut self, desc_table: GuestAddress) -> Result<(), Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/vhost-user-backend-0.10.1/src/vring.rs:187:41 | 187 | .try_set_avail_ring_address(GuestAddress(avail_ring))?; | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^ expected `GuestAddress`, found a different `GuestAddress` | | | arguments to this method are incorrect | = note: `GuestAddress` and `GuestAddress` have similar names, but are actually distinct types note: `GuestAddress` is defined in crate `vm_memory` --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/vm-memory-0.12.2/src/guest_memory.rs:109:1 | 109 | pub struct GuestAddress(pub u64); | ^^^^^^^^^^^^^^^^^^^^^^^ note: `GuestAddress` is defined in crate `vm_memory` --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/vm-memory-0.13.1/src/guest_memory.rs:111:1 | 111 | pub struct GuestAddress(pub u64); | ^^^^^^^^^^^^^^^^^^^^^^^ = note: perhaps two different versions of crate `vm_memory` are being used? note: method defined here --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/virtio-queue-0.9.1/src/queue.rs:147:12 | 147 | pub fn try_set_avail_ring_address(&mut self, avail_ring: GuestAddress) -> Result<(), Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/vhost-user-backend-0.10.1/src/vring.rs:189:40 | 189 | .try_set_used_ring_address(GuestAddress(used_ring)) | ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^ expected `GuestAddress`, found a different `GuestAddress` | | | arguments to this method are incorrect | = note: `GuestAddress` and `GuestAddress` have similar names, but are actually distinct types note: `GuestAddress` is defined in crate `vm_memory` --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/vm-memory-0.12.2/src/guest_memory.rs:109:1 | 109 | pub struct GuestAddress(pub u64); | ^^^^^^^^^^^^^^^^^^^^^^^ note: `GuestAddress` is defined in crate `vm_memory` --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/vm-memory-0.13.1/src/guest_memory.rs:111:1 | 111 | pub struct GuestAddress(pub u64); | ^^^^^^^^^^^^^^^^^^^^^^^ = note: perhaps two different versions of crate `vm_memory` are being used? note: method defined here --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/virtio-queue-0.9.1/src/queue.rs:161:12 | 161 | pub fn try_set_used_ring_address(&mut self, used_ring: GuestAddress) -> Result<(), Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `::M: vm_memory::guest_memory::GuestMemory` is not satisfied --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/vhost-user-backend-0.10.1/src/vring.rs:210:23 | 210 | .used_idx(self.mem.memory().deref(), Ordering::Relaxed) | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `vm_memory::guest_memory::GuestMemory` is not implemented for `::M` | | | required by a bound introduced by this call | note: required by a bound in `used_idx` --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/virtio-queue-0.9.1/src/lib.rs:190:20 | 190 | fn used_idx(&self, mem: &M, order: Ordering) -> Result, Error>; | ^^^^^^^^^^^ required by this bound in `QueueT::used_idx` help: consider further restricting the associated type | 208 | fn queue_used_idx(&self) -> Result where ::M: vm_memory::guest_memory::GuestMemory { | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`. error: could not compile `vhost-user-backend` (lib) due to 8 previous errors ```

Originally posted by @epilys in https://github.com/rust-vmm/vhost-device/issues/493#issuecomment-1788501194

Ablu commented 9 months ago

While I am not sure what the musl support situation is for pipewire, we have other crates - like vhost-device-gpio, that just do not have musl support. So I would be all for allowing crates to opt out of musl building. In vhost-device-gpio we just #[cfg(...)] the entire main away, but building an empty daemon for musl targets makes little sense to me.

Is there a way to exclude some projects from a workspace depending on the target architecture? That would seem like the simplest way out to me...

stefano-garzarella commented 9 months ago

Is there a way to exclude some projects from a workspace depending on the target architecture? That would seem like the simplest way out to me...

@Ablu It looks like they are still discussing that: https://github.com/rust-lang/cargo/issues/6179

epilys commented 9 months ago

Exclude from CI, at least?

Ablu commented 9 months ago

Exclude from CI, at least?

I would prefer that over doing hacks that just make the daemon build a completely pointless empty binary.

stefano-garzarella commented 9 months ago

Exclude from CI, at least?

I would prefer that over doing hacks that just make the daemon build a completely pointless empty binary.

Yeah, me too. But I'm not sure if we have a way other than writing our own custom pipeline. @andreeaflorescu ^