Skip to content

bug(rvf-runtime): macOS link failure — hard-coded glibc __errno_location in locking.rs #746

Description

@aepod

Summary

rvf-runtime declares a glibc-only extern "C" fn __errno_location() in locking.rs under #[cfg(unix)]. On macOS (and other non-glibc Unix), the libc errno accessor is __error, not __errno_location, so any binary/test that links rvf-runtime fails with an undefined symbol.

cargo check / rlib builds succeed; failure appears only at final link of an executable.

Affected versions

  • Confirmed: 0.2.0 (src/locking.rs ~277–294)
  • Confirmed still present: 0.3.0 (locking.rs ~304 / ~324)
  • crates.io max at report time: 0.3.2 (please re-check)

Repro (macOS)

# Cargo.toml
[dependencies]
rvf-runtime = { version = "0.2", default-features = false, features = ["std"] }
tempfile = "3"
use rvf_runtime::{DistanceMetric, RvfOptions, RvfStore};

fn main() {
    let dir = tempfile::tempdir().unwrap();
    let path = dir.path().join("t.rvf");
    let opts = RvfOptions {
        dimension: 4,
        metric: DistanceMetric::L2,
        ..Default::default()
    };
    let _ = RvfStore::create(&path, opts).expect("create");
    let _ = RvfStore::open(&path).expect("open");
}
cargo build
# ld: Undefined symbols: ___errno_location

Expected

Portable errno access via the libc crate or per-OS cfg (__error on macOS/BSD, __errno_location on Linux).

Suggested fix

fn libc_errno() -> *mut i32 {
    // libc crate provides a portable surface
    unsafe { libc::__errno_location() }
}

or:

#[cfg(target_os = "linux")]
extern "C" { fn __errno_location() -> *mut i32; }
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))]
extern "C" { fn __error() -> *mut i32; }

Downstream impact

WeftOS / clawft (clawft-cow-memory) ships a #[no_mangle] shim that exports __errno_locationlibc::__error() so macOS CI and local tests can link. That is a fragile single-definition symbol (fat-LTO multiplies duplicates). An upstream fix lets all consumers drop the shim.

Reported from WeftOS ticket WEFT-662. Full write-up with two sibling bugs:
https://github.com/ (local doc: docs/research/rvf-runtime-0.2-upstream-bugs.md in weftos).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions