asg017 / sqlite-vss

A SQLite extension for efficient vector search, based on Faiss!
MIT License
1.59k stars 59 forks source link

Issues using rust crate on M2 Max #61

Open vikranthkeerthipati opened 1 year ago

vikranthkeerthipati commented 1 year ago

Not sure if anyone else on apple silicon is facing issues, but for the rust crate I had to manually add RUSTFLAGS="-L/opt/homebrew/opt/libomp/lib -L/opt/homebrew/opt/llvm/lib -lblas -llapack" in order for the linker to work properly.

Curious if this is a result of my local setup or an issue that others on silicon were facing for the rust crate

asg017 commented 1 year ago

Hey thanks for sharing! The Rust bindings are extremely new/experimental and I haven't had the chance to try on a M1 mac yet. Those flags seem right, the MacOS x64_64 and Linux builds also require similar flags.

Will try it out on my M1 and will update the docs when needed.

If you're tired to constantly defining RUSTFLAGS as a variable, consider moving it to a build.rs file:

https://github.com/asg017/sqlite-vss/blob/67aae7cbf27f8bb3fe7f20abe1d0df31a0662ba7/examples/rust/build.rs#L2-L6

ospfranco commented 2 months ago

For reference I got my app to compile using the following:

fn main() {
    if cfg!(target_os = "macos") {
        println!("cargo:rustc-link-arg=-Wl,-undefined,dynamic_lookup,-lomp,-L/opt/homebrew/opt/libomp/lib");
    } else if cfg!(target_os = "linux") {
        println!("cargo:rustc-link-arg=-Wl,-undefined,dynamic_lookup,-lstdc++");
    }
}

After installing libomp via brew