Skip to content

netwatch fails to build for iOS with libc >= 0.2.190 (route constants are macOS-only now) #261

Closed

Description

@Foreverwzh

netwatch 0.19.3 / 0.20.0 fails to build for aarch64-apple-ios with libc >= 0.2.190. That libc release removed the routing socket constants (RTM_*, RTF_IFSCOPE, RTAX_*, …) from non-macOS Apple targets (rust-lang/libc#5158), and interfaces/bsd/macos.rs / netmon/bsd.rs use them on iOS too. With libc 0.2.189 it builds fine.

netdev 0.46.x had the same issue, which is fixed in netdev 0.47.0, but netwatch still requires 0.46.3.

We hit this through iroh in an iOS app and are capping libc at <0.2.190 for now.

Repro and full error list
[package]
name = "repro"
version = "0.1.0"
edition = "2024"

[dependencies]
netwatch = "=0.20.0"
libc = "=0.2.191"

# Only to get past the separate netdev error, so the netwatch errors show up.
[patch.crates-io]
netdev = { git = "https://github.com/shellrow/netdev", rev = "b3bfb0fb5595cd143bfa0b9f07d1ad6e0ef0c313" }
cargo check --target aarch64-apple-ios   # Rust 1.97.0
...
error: could not compile `netwatch` (lib) due to 22 previous errors

Missing from libc on iOS:

RTM_ADD, RTM_CHANGE, RTM_DELADDR, RTM_DELETE, RTM_DELMADDR, RTM_GET, RTM_GET2, RTM_IFINFO, RTM_IFINFO2, RTM_LOCK, RTM_LOSING, RTM_MISS, RTM_NEWADDR, RTM_NEWMADDR, RTM_NEWMADDR2, RTM_REDIRECT, RTM_RESOLVE, RTM_VERSION, RTF_IFSCOPE, RTF_GATEWAY, RTA_IFP, RTAX_BRD, RTAX_DST, RTAX_GATEWAY, RTAX_IFP, RTAX_MAX, RTAX_NETMASK

Activity

  1. Foreverwzh commented on Oct 27, 2026

    @Foreverwzh
    ContributorAuthor

    I have a fix ready, following what bsd/freebsd.rs etc. already do: define the Apple routing constants locally in bsd/macos.rs instead of taking them from libc, plus a macOS-only test asserting they match libc's values. Also bumps netdev to 0.47 (and libc to 0.2.191 in the lockfile, since the current lock is on 0.2.189 so CI doesn't see this). Checked with cargo check --target aarch64-apple-ios and the netwatch tests on macOS.

    Happy to open a PR if this approach works for you.

  2. moved this to 🚑 Needs Triage in irohon Oct 27, 2026
  3. flub commented on Oct 27, 2026

    @flub
    Collaborator

    Hey, thanks for the report. Would be great to get a PR for this. Let's upgrade to netdev 0.47 for this. Thanks!

  4. added theissue type on Oct 27, 2026
  5. added
    release needed
    on Oct 27, 2026
  6. R44VC0RP commented on Oct 31, 2026

    @R44VC0RP

    We hit this building iroh for an iOS app. One thing we found while testing: netdev 0.47 with its default gateway feature still goes through os::darwin::route::get_gateway_map on iOS, so it relies on the same Darwin routing ABI that libc stopped exposing there.

    We have a branch that sidesteps it on iOS: Network.framework (nw_path_monitor) for path changes and gateways, getifaddrs for addresses, no netdev on iOS, public API unchanged. It passes on the iOS 26.5/27 simulators and links for arm64 devices; macOS and Linux are untouched. Physical handoffs aren't tested yet.

    https://github.com/anomalyco/net-tools/tree/ios-network-framework

    Happy to open it as a PR if that direction is useful, or to keep it on our side if the netdev 0.47 route covers iOS for you.

  7. Foreverwzh commented on Nov 1, 2026

    @Foreverwzh
    ContributorAuthor

    Opened #267.

    @R44VC0RP netdev 0.47 hardcodes these constants and declares sysctl itself, so it builds on iOS again. What libc removed is the header-level definitions; the routing sysctl itself is what netwatch and netdev have been using on iOS all along. This PR does the same in netwatch. Moving iOS to Network.framework seems like a bigger change that's worth its own issue.

  8. moved this from 🚑 Needs Triage to 🏗 In progress in irohon Nov 1, 2026
  9. added a commit that references this issue on Nov 6, 2026
    aa8bb51
  10. moved this from 🏗 In progress to ✅ Done in irohon Nov 6, 2026
  11. added a commit that references this issue on Nov 10, 2026
    c8d6e3e
  12. OutThisLife commented on Nov 17, 2026

    @OutThisLife

    Is a netwatch 0.19.x patch release with #267 planned? iroh 1.4.x requires ^0.19.3, so it can't build for iOS with libc >= 0.2.190 until either that or an iroh on netwatch 0.20.1 ships. Cherry-pick onto netwatch-v0.19.3: https://github.com/OutThisLife/net-tools/tree/netwatch-0.19-ios

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-prrelease needed

    Type

    Projects

    • Status
      ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions