From 787634eef00ffdcc7559d2ac5893fa2579cb5fd7 Mon Sep 17 00:00:00 2001 From: Dave Rigby Date: Tue, 3 Dec 2024 12:38:30 +0000 Subject: [PATCH] faiss-sys: Link to 'omp' on macOS instead of 'gomp' The OpenMP library is named differently on macOS vs Linux - link to 'libomp' on non-Linux platforms instead of 'libgomp'. --- faiss-sys/build.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/faiss-sys/build.rs b/faiss-sys/build.rs index aee4b76..4081053 100644 --- a/faiss-sys/build.rs +++ b/faiss-sys/build.rs @@ -1,3 +1,5 @@ +use std::env; + fn main() { #[cfg(feature = "static")] static_link_faiss(); @@ -7,6 +9,8 @@ fn main() { #[cfg(feature = "static")] fn static_link_faiss() { + let target = env::var("TARGET").expect("TARGET not set"); + let mut cfg = cmake::Config::new("faiss"); cfg.define("FAISS_ENABLE_C_API", "ON") .define("BUILD_SHARED_LIBS", "OFF") @@ -33,7 +37,12 @@ fn static_link_faiss() { println!("cargo:rustc-link-lib=static=faiss_c"); println!("cargo:rustc-link-lib=static=faiss"); link_cxx(); - println!("cargo:rustc-link-lib=gomp"); + + if !target.contains("msvc") && !target.contains("apple") { + println!("cargo:rustc-link-lib=gomp"); + } else { + println!("cargo:rustc-link-lib=omp"); + } println!("cargo:rustc-link-lib=blas"); println!("cargo:rustc-link-lib=lapack"); if cfg!(feature = "gpu") {