diff --git a/rust/lance-linalg/build.rs b/rust/lance-linalg/build.rs index fee023cf742..10385e35431 100644 --- a/rust/lance-linalg/build.rs +++ b/rust/lance-linalg/build.rs @@ -76,7 +76,14 @@ fn main() -> Result<(), String> { build_f16_with_flags("lsx", &["-mlsx"]).unwrap(); build_f16_with_flags("lasx", &["-mlasx"]).unwrap(); } else { - return Err("Unable to build f16 kernels on given target_arch. Please use x86_64 or aarch64 or remove the fp16kernels feature".to_string()); + // Only error if fp16kernels was explicitly requested on unsupported platform. + // This allows builds on iOS, Android, etc. when the feature is disabled. + // + // Note: We use CARGO_FEATURE_* env var instead of cfg!() because cfg!() + // checks the build script's features, not the library's features. + if env::var("CARGO_FEATURE_FP16KERNELS").is_ok() { + return Err("Unable to build f16 kernels on given target_arch. Please use x86_64 or aarch64 or remove the fp16kernels feature".to_string()); + } } Ok(()) }