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

Fails to build on BSDs (except macOS) #2306

Closed
jbeich opened this issue May 18, 2024 · 5 comments · Fixed by #2311
Closed

Fails to build on BSDs (except macOS) #2306

jbeich opened this issue May 18, 2024 · 5 comments · Fixed by #2311
Assignees
Labels
bug Something isn't working c-iroh
Milestone

Comments

@jbeich
Copy link

jbeich commented May 18, 2024

Depends on rust-lang/libc#3711. See also downstream fix (routing untested).

$ rustc -vV
rustc 1.78.0 (9b00956e5 2024-04-29) (built from a source tarball)
binary: rustc
commit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6
commit-date: 2024-04-29
host: x86_64-unknown-freebsd
release: 1.78.0
LLVM version: 18.1.2

$ cargo build
[...]
error[E0425]: cannot find value `RTAX_GATEWAY` in crate `libc`
  --> iroh-net/src/net/interfaces/bsd.rs:36:46
   |
36 |         if let Some(gw) = rm.addrs.get(libc::RTAX_GATEWAY as usize) {
   |                                              ^^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `RTF_GATEWAY` in crate `libc`
  --> iroh-net/src/net/interfaces/bsd.rs:81:25
   |
81 |     if rm.flags & libc::RTF_GATEWAY as u32 == 0 {
   |                         ^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `RTF_IFSCOPE` in crate `libc`
  --> iroh-net/src/net/interfaces/bsd.rs:85:25
   |
85 |     if rm.flags & libc::RTF_IFSCOPE as u32 != 0 {
   |                         ^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `RTAX_NETMASK` in crate `libc`
  --> iroh-net/src/net/interfaces/bsd.rs:90:32
   |
90 |     if rm.addrs.len() <= libc::RTAX_NETMASK as usize {
   |                                ^^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `RTAX_DST` in crate `libc`
  --> iroh-net/src/net/interfaces/bsd.rs:94:40
   |
94 |     let Some(dst) = rm.addrs.get(libc::RTAX_DST as usize) else {
   |                                        ^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `RTAX_NETMASK` in crate `libc`
  --> iroh-net/src/net/interfaces/bsd.rs:97:44
   |
97 |     let Some(netmask) = rm.addrs.get(libc::RTAX_NETMASK as usize) else {
   |                                            ^^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `RTA_IFP` in crate `libc`
   --> iroh-net/src/net/interfaces/bsd.rs:282:49
    |
282 |                 if attrs as libc::c_int & libc::RTA_IFP == 0 {
    |                                                 ^^^^^^^ not found in `libc`

error[E0425]: cannot find value `probe_routing_stack` in this scope
   --> iroh-net/src/net/interfaces/bsd.rs:368:54
    |
368 | static ROUTING_STACK: Lazy<RoutingStack> = Lazy::new(probe_routing_stack);
    |                                                      ^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `RTAX_MAX` in crate `libc`
   --> iroh-net/src/net/interfaces/bsd.rs:753:46
    |
753 |     let mut addrs = Vec::with_capacity(libc::RTAX_MAX as usize);
    |                                              ^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `RTAX_MAX` in crate `libc`
   --> iroh-net/src/net/interfaces/bsd.rs:757:23
    |
757 |     for i in 0..libc::RTAX_MAX as usize {
    |                       ^^^^^^^^ not found in `libc`
    |
help: you might have meant to write `.` instead of `..`
    |
757 -     for i in 0..libc::RTAX_MAX as usize {
757 +     for i in 0.libc::RTAX_MAX as usize {
    |

error[E0425]: cannot find value `RTAX_BRD` in crate `libc`
   --> iroh-net/src/net/interfaces/bsd.rs:765:23
    |
765 |         if i <= libc::RTAX_BRD as usize {
    |                       ^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `SIZEOF_SOCKADDR_INET` in this scope
   --> iroh-net/src/net/interfaces/bsd.rs:818:26
    |
818 |             if b.len() < SIZEOF_SOCKADDR_INET {
    |                          ^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `SIZEOF_SOCKADDR_INET6` in this scope
   --> iroh-net/src/net/interfaces/bsd.rs:826:26
    |
826 |             if b.len() < SIZEOF_SOCKADDR_INET6 {
    |                          ^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `SIZEOF_SOCKADDR_INET6` in this scope
   --> iroh-net/src/net/interfaces/bsd.rs:906:36
    |
906 |     let addr = if b[0] as usize == SIZEOF_SOCKADDR_INET6 {
    |                                    ^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `SIZEOF_SOCKADDR_INET` in this scope
   --> iroh-net/src/net/interfaces/bsd.rs:922:32
    |
922 |     } else if b[0] as usize == SIZEOF_SOCKADDR_INET {
    |                                ^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `RTAX_IFP` in crate `libc`
  --> iroh-net/src/net/netmon/bsd.rs:70:53
   |
70 |             if let Some(addr) = msg.addrs.get(libc::RTAX_IFP as usize) {
   |                                                     ^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `RTAX_DST` in crate `libc`
  --> iroh-net/src/net/netmon/bsd.rs:81:53
   |
81 |             if let Some(addr) = msg.addrs.get(libc::RTAX_DST as usize) {
   |                                                     ^^^^^^^^ not found in `libc`

error[E0308]: mismatched types
   --> iroh-net/src/net/interfaces/bsd.rs:131:25
    |
131 |         Ok(res) => Some(res),
    |                    ---- ^^^ expected `Vec<RouteMessage>`, found `Vec<WireMessage>`
    |                    |
    |                    arguments to this enum variant are incorrect
    |
    = note: expected struct `Vec<RouteMessage>`
               found struct `Vec<WireMessage>`
help: the type constructed contains `Vec<WireMessage>` due to the type of the argument passed
   --> iroh-net/src/net/interfaces/bsd.rs:131:20
    |
131 |         Ok(res) => Some(res),
    |                    ^^^^^---^
    |                         |
    |                         this argument influences the type of `Some`
note: tuple variant defined here
   --> /usr/ports/lang/rust/work/rustc-1.78.0-src/library/core/src/option.rs:580:5

error[E0425]: cannot find function `is_valid_rib_type` in this scope
   --> iroh-net/src/net/interfaces/bsd.rs:378:9
    |
378 |     if !is_valid_rib_type(typ) {
    |         ^^^^^^^^^^^^^^^^^ not found in this scope

Some errors have detailed explanations: E0308, E0425.
For more information about an error, try `rustc --explain E0308`.
@dignifiedquire
Copy link
Contributor

Want to submit the patch as a PR? Or do you want to us to pull it in ourselves?

@dignifiedquire
Copy link
Contributor

Any suggestions on how to get CI setup for freebsd? It's hard to get it going with no developer on our team having experience with BSD

@dignifiedquire dignifiedquire added this to the v0.17.0 milestone May 19, 2024
@dignifiedquire dignifiedquire self-assigned this May 19, 2024
@dignifiedquire
Copy link
Contributor

found some cross images for freebsd, which should get us some baseline compat

@dignifiedquire
Copy link
Contributor

@jbeich I have a patched version compiling in #2311
unfortunately linking on 32 bit fails inside of cross and I don't have access to a running BSD system, so any testing on your side would be appreciated

@dignifiedquire dignifiedquire moved this to 🏗 In progress in iroh May 19, 2024
@jbeich
Copy link
Author

jbeich commented May 20, 2024

Want to submit the patch as a PR?

No. I'm a mere packager: don't use iroh outside of jumpy and my patch is likely incorrect on FreeBSD and incomplete for other BSDs.

Besides, FreeBSD >= 13.2 also supports AF_NETLINK similar to Linux.

Any suggestions on how to get CI setup for freebsd?

github-merge-queue bot pushed a commit that referenced this issue May 24, 2024
Adds support for `iroh`  on `NetBSD`, `FreeBSD` and `OpenBSD`.

## Status

- NetBsd
  - [x] Compiles
  - [ ] Tests passing
- [ ] Iroh: mostly passing, failures are only due to
shellrow/netdev#69
    - [x] Quinn
  - [x] Implementation adapted
- FreeBsd
  - [x] Compiles
  - [ ] Tests passing
- [ ] Iroh: mostly passing, failures are only due to
shellrow/netdev#69
    - [x] Quinn
  - [x] Implementation adapted
- OpenBsd
  - [x] Compiles
  - [ ] Tests passing
- [ ] Iroh: mostly passing, failures are only due to
shellrow/netdev#69
    - [x] Quinn
  - [x] Implementation adapted


## Caveats

- Build only in CI for now

## Related Issues

- shellrow/netdev#69
- n0-computer/quinn#9

## References

-
https://github.com/freebsd/freebsd-ports/blob/78ad38f04f51/games/jumpy/files/patch-iroh
- rust-lang/libc#3711

Closes #2306

---------

Co-authored-by: Floris Bruynooghe <[email protected]>
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in iroh May 24, 2024
matheus23 pushed a commit that referenced this issue Nov 14, 2024
Adds support for `iroh`  on `NetBSD`, `FreeBSD` and `OpenBSD`.

## Status

- NetBsd
  - [x] Compiles
  - [ ] Tests passing
- [ ] Iroh: mostly passing, failures are only due to
shellrow/netdev#69
    - [x] Quinn
  - [x] Implementation adapted
- FreeBsd
  - [x] Compiles
  - [ ] Tests passing
- [ ] Iroh: mostly passing, failures are only due to
shellrow/netdev#69
    - [x] Quinn
  - [x] Implementation adapted
- OpenBsd
  - [x] Compiles
  - [ ] Tests passing
- [ ] Iroh: mostly passing, failures are only due to
shellrow/netdev#69
    - [x] Quinn
  - [x] Implementation adapted


## Caveats

- Build only in CI for now

## Related Issues

- shellrow/netdev#69
- n0-computer/quinn#9

## References

-
https://github.com/freebsd/freebsd-ports/blob/78ad38f04f51/games/jumpy/files/patch-iroh
- rust-lang/libc#3711

Closes #2306

---------

Co-authored-by: Floris Bruynooghe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working c-iroh
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants