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

compiling on FreeBSD (a Tier 2 platform) #32

Open
igalic opened this issue Aug 4, 2023 · 2 comments
Open

compiling on FreeBSD (a Tier 2 platform) #32

igalic opened this issue Aug 4, 2023 · 2 comments

Comments

@igalic
Copy link

igalic commented Aug 4, 2023

Hi Folks,

i'm trying to develop a virtio vsock driver for FreeBSD and was looking for ways to test it when coming across this project.
unfortunately, i have no idea how to compile it.
Here's a fresh nightly installed via https://rustup.rs:

cargo build --lib
meena@defbix ~/s/vsock-rs ❯❯❯ cargo build --lib
    Updating crates.io index
  Downloaded bitflags v1.3.2
  Downloaded cfg-if v1.0.0
  Downloaded memoffset v0.6.5
  Downloaded autocfg v1.1.0
  Downloaded nix v0.24.3
  Downloaded libc v0.2.147
  Downloaded 6 crates (1005.5 KB) in 1.24s
   Compiling autocfg v1.1.0
   Compiling libc v0.2.147
   Compiling bitflags v1.3.2
   Compiling cfg-if v1.0.0
error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-unknown-linux-musl`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

error[E0463]: can't find crate for `compiler_builtins`

error[E0463]: can't find crate for `core`
   --> /home/meena/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bitflags-1.3.2/src/lib.rs:282:1
    |
282 | pub extern crate core as _core;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    |
    = note: the `x86_64-unknown-linux-musl` target may not be installed
    = help: consider downloading the target with `rustup target add x86_64-unknown-linux-musl`
    = help: consider building the standard library from source with `cargo build -Zbuild-std`

For more information about this error, try `rustc --explain E0463`.
error: could not compile `cfg-if` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `bitflags` (lib) due to 3 previous errors
meena@defbix ~/s/vsock-rs ❯❯❯

that seems odd, but after adding -Zbuild-std as suggested, the library compiles.
on to the echo server:

cargo build --manifest-path=echo_server/Cargo.toml
meena@defbix ~/s/vsock-rs ❯❯❯ cargo build --manifest-path=echo_server/Cargo.toml
   Compiling libc v0.2.147
   Compiling bitflags v1.3.2
   Compiling memoffset v0.6.5
   Compiling cfg-if v1.0.0
   Compiling unicode-width v0.1.10
   Compiling strsim v0.8.0
   Compiling ansi_term v0.12.1
   Compiling vec_map v0.8.2
error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-unknown-linux-musl`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

error[E0463]: can't find crate for `compiler_builtins`

error: requires `sized` lang_item

For more information about this error, try `rustc --explain E0463`.
error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-unknown-linux-musl`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

error: cannot find macro `vec` in this scope
   --> /home/meena/.cargo/registry/src/index.crates.io-6f17d22bba15001f/strsim-0.8.0/src/lib.rs:266:25
    |
266 |     let mut distances = vec![vec![0; b_len + 2]; a_len + 2];
    |                         ^^^

same thing.
Weird. We just built core and std, didn't we?

Let's add the same fix and see if that helps.

cargo build -Zbuild-std --manifest-path=echo_server/Cargo.toml
meena@defbix ~/s/vsock-rs ❯❯❯ cargo build -Zbuild-std --manifest-path=echo_server/Cargo.toml
   Compiling compiler_builtins v0.1.98
   Compiling core v0.0.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/core)
   Compiling libc v0.2.147
   Compiling cc v1.0.79
   Compiling memchr v2.5.0
   Compiling std v0.0.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/std)
   Compiling memoffset v0.6.5
   Compiling unwind v0.0.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/unwind)
   Compiling rustc-std-workspace-core v1.99.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/alloc)
   Compiling cfg-if v1.0.0
   Compiling adler v1.0.2
   Compiling rustc-demangle v0.1.23
   Compiling rustc-std-workspace-alloc v1.99.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/rustc-std-workspace-alloc)
   Compiling panic_unwind v0.0.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/panic_unwind)
   Compiling panic_abort v0.0.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/panic_abort)
   Compiling gimli v0.27.3
   Compiling object v0.31.1
   Compiling miniz_oxide v0.7.1
   Compiling hashbrown v0.14.0
   Compiling std_detect v0.1.5 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/stdarch/crates/std_detect)
   Compiling addr2line v0.20.0
   Compiling proc_macro v0.0.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/proc_macro)
   Compiling bitflags v1.3.2
   Compiling unicode-width v0.1.10
   Compiling textwrap v0.11.0
   Compiling ansi_term v0.12.1
   Compiling vec_map v0.8.2
   Compiling strsim v0.8.0
   Compiling nix v0.24.3
   Compiling atty v0.2.14
   Compiling clap v2.34.0
   Compiling vsock v0.3.0 (/home/meena/src/vsock-rs)
   Compiling echo_server v0.1.0 (/home/meena/src/vsock-rs/echo_server)
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/bin:/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/bin/self-contained:/home/meena/.cargo/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/meena/bin" VSLANG="1033" "cc" "-m64" "rcrt1.o" "crti.o" "crtbeginS.o" "/tmp/rustcYGPqCl/symbols.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.11wpenippf3idjrc.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.13vuz15lv5i9f3rj.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.1ay395fkn1jbl1xv.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.1gz72zvtg6e167l3.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.1j0wlu8r8pmc5911.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.1n7q1huwqlkq765a.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.1ummkieckl2glhdd.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.1zg2imapo4dy6y4a.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.25ar1020tt3aa5vu.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.27pd3zyke767f92c.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.29oxvfkhglshtjg2.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.2c3btm3mwpme5lgb.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.2ey0dlwezkzzmpyx.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.2u9n8b1ul1s5thtu.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.2xmijivwjyqxw04x.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.2y4hwwuqpers8c3.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.30poxsih60y77phg.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.30qh44fvlvl9p8mn.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.30w44jed3g3lnbh4.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.31syhz10tqrn8hk3.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.33vtabyy62zapf0c.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.350hhw3xse5ly7k3.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.3ke3mnj8fcsu55ag.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.3l4yfo2snqe1bl5u.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.3vwlkclgx5qebvob.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.3wvr42726odbiyl9.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.3x1xstw99y29bql3.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.418muzkybdif337r.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.42tpig49exc0uej4.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.45bartuf4sx26ts9.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.49ifc0vkjcs18z9a.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.4bkv9sm5vq9ey5fd.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.4dmcr6v5kc96qmdw.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.4nxkvi2ovoqw3wp2.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.4o0ulddtpsy53o11.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.4s6c8r2dwh63wq6t.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.4wk39hiu7ge79dg8.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.502s7h104uyc099k.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.5612kn4aa9fjgbk.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.56r563kqeoeat49p.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.5cvjskjh9v910jd3.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.5dx6y4y3int7bk7n.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.cgaz6qewotcgp6p.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.ftl8zzak2v47ljt.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.jlqp898mphjlg91.rcgu.o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852.3ync8i1jatbysdof.rcgu.o" "-Wl,--as-needed" "-L" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps" "-L" "/home/meena/src/vsock-rs/echo_server/target/debug/deps" "-L" "/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-linux-musl/lib" "-Wl,-Bstatic" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libvsock-c8b5023ca20fa89d.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libnix-08d4a3c493f7f221.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libmemoffset-be19a8b2d43fcc1b.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libcfg_if-d7a3ccb3d67b77c9.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libclap-8f4b21091b1359b5.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libvec_map-389005fbac225bb7.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libtextwrap-55b52274560f280a.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libunicode_width-b95e987f09871fca.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libstrsim-9e01bc512f8e1165.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libbitflags-c0896105181dc418.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libatty-d2b59344b331f884.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/liblibc-8ec20e301f5010f7.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libansi_term-a1e422806be7da76.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libstd-9095888a0924fdd4.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libpanic_unwind-403fdfbc76f1857c.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libobject-9d01a7ba9ddec2aa.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libmemchr-f51fd5d6c6e3c0a4.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libaddr2line-61322c47e8743a34.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libgimli-1f65c43fd61bb5cb.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/librustc_demangle-4416fcabc8244be4.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libstd_detect-3dbe7c807ce87fe3.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libhashbrown-fe23e53cc2702242.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/librustc_std_workspace_alloc-545d117ee17a0074.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libminiz_oxide-ca22f50877d5049a.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libadler-caa0ea92ba153d5a.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libunwind-a07b3f590ba85eee.rlib" "-lunwind" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libcfg_if-31a077c82da6fc2e.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/liblibc-ab76d830f00730f7.rlib" "-lc" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/liballoc-609b9948d625536f.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/librustc_std_workspace_core-b98b79f707351b5b.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libcore-1133c92b4392a38e.rlib" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/libcompiler_builtins-27e47751a1b5ac29.rlib" "-Wl,-Bdynamic" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-nostartfiles" "-L" "/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-linux-musl/lib" "-L" "/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained" "-o" "/home/meena/src/vsock-rs/echo_server/target/x86_64-unknown-linux-musl/debug/deps/echo_server-d249f0a83f60f852" "-Wl,--gc-sections" "-static-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "crtendS.o" "crtn.o"
  = note: cc: error: no such file or directory: 'rcrt1.o'
          cc: error: no such file or directory: 'crti.o'
          cc: error: no such file or directory: 'crtbeginS.o'
          cc: error: no such file or directory: 'crtendS.o'
          cc: error: no such file or directory: 'crtn.o'
          

error: could not compile `echo_server` (bin "echo_server") due to previous error
meena@defbix ~/s/vsock-rs ❯❯❯ 

well, this is all very nonsensical. Let's set the target explicitly:

meena@defbix ~/s/vsock-rs ❯❯❯ cargo build --target x86_64-unknown-freebsd --lib -Zbuild-std                                      master
    Updating crates.io index
  Downloaded autocfg v1.1.0
  Downloaded memoffset v0.6.5
  Downloaded cfg-if v1.0.0
  Downloaded bitflags v1.3.2
  Downloaded nix v0.24.3
  Downloaded libc v0.2.147
  Downloaded 6 crates (1005.5 KB) in 1.09s
    Updating crates.io index
  Downloaded adler v1.0.2
  Downloaded miniz_oxide v0.7.1
  Downloaded unicode-width v0.1.10
  Downloaded getopts v0.2.21
  Downloaded rustc-demangle v0.1.23
  Downloaded allocator-api2 v0.2.15
  Downloaded addr2line v0.20.0
  Downloaded cc v1.0.79
  Downloaded memchr v2.5.0
  Downloaded hashbrown v0.14.0
  Downloaded compiler_builtins v0.1.98
  Downloaded gimli v0.27.3
  Downloaded object v0.31.1
  Downloaded 13 crates (1.2 MB) in 1.20s
   Compiling compiler_builtins v0.1.98
   Compiling core v0.0.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/core)
   Compiling libc v0.2.147
   Compiling cc v1.0.79
   Compiling memchr v2.5.0
   Compiling std v0.0.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/std)
   Compiling autocfg v1.1.0
   Compiling memoffset v0.6.5
   Compiling unwind v0.0.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/unwind)
   Compiling rustc-std-workspace-core v1.99.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/alloc)
   Compiling cfg-if v1.0.0
   Compiling adler v1.0.2
   Compiling rustc-demangle v0.1.23
   Compiling rustc-std-workspace-alloc v1.99.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/rustc-std-workspace-alloc)
   Compiling panic_abort v0.0.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/panic_abort)
   Compiling panic_unwind v0.0.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/panic_unwind)
   Compiling gimli v0.27.3
   Compiling hashbrown v0.14.0
   Compiling miniz_oxide v0.7.1
   Compiling std_detect v0.1.5 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/stdarch/crates/std_detect)
   Compiling object v0.31.1
   Compiling addr2line v0.20.0
   Compiling proc_macro v0.0.0 (/home/meena/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib/rustlib/src/rust/library/proc_macro)
   Compiling bitflags v1.3.2
   Compiling nix v0.24.3
   Compiling vsock v0.3.0 (/home/meena/src/vsock-rs)
error[E0432]: unresolved imports `libc::sockaddr_vm`, `libc::AF_VSOCK`
  --> src/lib.rs:21:44
   |
21 |     accept4, ioctl, sa_family_t, sockaddr, sockaddr_vm, socklen_t, suseconds_t, timeval, AF_VSOCK,
   |                                            ^^^^^^^^^^^                                   ^^^^^^^^ no `AF_VSOCK` in the root
   |                                            |
   |                                            no `sockaddr_vm` in the root
   |                                            help: a similar name exists in the module: `sockaddr_un`

error[E0432]: unresolved imports `libc::VMADDR_CID_ANY`, `libc::VMADDR_CID_HOST`, `libc::VMADDR_CID_HYPERVISOR`, `libc::VMADDR_CID_LOCAL`
  --> src/lib.rs:40:16
   |
40 | pub use libc::{VMADDR_CID_ANY, VMADDR_CID_HOST, VMADDR_CID_HYPERVISOR, VMADDR_CID_LOCAL};
   |                ^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^ no `VMADDR_CID_LOCAL` in the root
   |                |               |                |
   |                |               |                no `VMADDR_CID_HYPERVISOR` in the root
   |                |               no `VMADDR_CID_HOST` in the root
   |                no `VMADDR_CID_ANY` in the root

error[E0432]: unresolved import `nix::sys::socket::VsockAddr`
  --> src/lib.rs:41:42
   |
41 | pub use nix::sys::socket::{SockaddrLike, VsockAddr};
   |                                          ^^^^^^^^^
   |                                          |
   |                                          no `VsockAddr` in `sys::socket`
   |                                          help: a similar name exists in the module: `SockAddr`
   |
note: found an item that was configured out
  --> /home/meena/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nix-0.24.3/src/sys/socket/mod.rs:79:42
   |
79 | pub use crate::sys::socket::addr::vsock::VsockAddr;
   |                                          ^^^^^^^^^

error[E0599]: no variant or associated item named `Vsock` found for enum `AddressFamily` in the current scope
  --> src/lib.rs:45:24
   |
45 |         AddressFamily::Vsock,
   |                        ^^^^^ variant or associated item not found in `AddressFamily`

error[E0599]: no variant or associated item named `Vsock` found for enum `AddressFamily` in the current scope
  --> src/lib.rs:75:49
   |
75 |         if addr.family() != Some(AddressFamily::Vsock) {
   |                                                 ^^^^^ variant or associated item not found in `AddressFamily`

error[E0599]: no variant or associated item named `Vsock` found for enum `AddressFamily` in the current scope
   --> src/lib.rs:196:49
    |
196 |         if addr.family() != Some(AddressFamily::Vsock) {
    |                                                 ^^^^^ variant or associated item not found in `AddressFamily`

Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `vsock` (lib) due to 6 previous errors
warning: build failed, waiting for other jobs to finish...
meena@defbix ~/s/vsock-rs ❯❯❯ 

finally, we're getting somewhere!
my /usr/include/sys/sockets.h contains AF_VSOCK:

meena@defbix ~/s/vsock-rs ❯❯❯ rg AF_VSOCK /usr/include/sys/socket.h
272:#define     AF_VSOCK        46              /* VirtIO sockets */
399:#define PF_VSOCK    AF_VSOCK

but does, indeed, not contain any of the other things constants… VMADDR_CID_ANY, VMADDR_CID_HOST, VMADDR_CID_HYPERVISOR, VMADDR_CID_LOCAL. The only one of those i can be sure of, according to the spec is VMADDR_CID_HOST.

Ignoring the breakage with cargo defaulting to x86_64-unknown-linux-musl on FreeBSD… how do I get started with making this crate compile on FreeBSD?

@qwandor
Copy link
Contributor

qwandor commented Aug 4, 2023

I suspect you're the first person to try using this crate on anything other than Linux.

The unresolved imports errors you're getting are probably due to the libc and nix crates lacking the appropriate definitions on FreeBSD. These are added manually, not generated from the C header files, so you'll need to send them PRs to add the missing items. From my experience adding Android stuff there the maintainers are generally fairly responsive and helpful.

I'm not sure how much FreeBSD differs from Linux here, but I'd hope that once the dependencies are into libc and nix then getting this crate working on FreeBSD should be fairly straightforward.

@igalic
Copy link
Author

igalic commented Aug 4, 2023

thanks for the quick response!
i looked at nix at least and it looks quite easy to adapt. way easier to adapt than go's unix module…

I'm still at very much the start of this project, and i have never done any Kernel module development from scratch, let alone one as complex as a driver that's also a socket API.
Great start to break into a new field :D

I hope that soon I'll have more to go on.
thank you very much.

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

2 participants