Skip to content

Commit c3ba797

Browse files
igerberclaude
andcommitted
Fix Ubuntu CI: link system OpenBLAS directly via build.rs
The openblas-src -> openblas-build -> ureq -> native-tls dependency chain fails to compile on Ubuntu CI because native-tls 0.2.17 is incompatible with the latest Rust stable (missing Protocol::Tlsv13 match arm). Replace blas-src/openblas with a build.rs that emits `cargo:rustc-link-lib=openblas` directly, linking the system library (libopenblas-dev) without any download infrastructure. The accelerate feature (macOS) continues using blas-src as before. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1dabaea commit c3ba797

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extension-module = ["pyo3/extension-module"]
1717
# Platform BLAS backends (optional, activated for pre-built wheels)
1818
# When enabled, ndarray's .dot() and general_mat_vec_mul dispatch to BLAS dgemv/dgemm
1919
accelerate = ["ndarray/blas", "dep:blas-src", "blas-src/accelerate"]
20-
openblas = ["ndarray/blas", "dep:blas-src", "blas-src/openblas"]
20+
openblas = ["ndarray/blas"]
2121

2222
[dependencies]
2323
# PyO3 0.22 supports Python 3.8-3.13

rust/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// Build script for diff_diff_rust.
2+
///
3+
/// When the `openblas` feature is enabled, links against the system OpenBLAS
4+
/// library directly. This avoids the `openblas-src` -> `openblas-build` ->
5+
/// `ureq` -> `native-tls` dependency chain, which has Rust compiler
6+
/// compatibility issues. Requires `libopenblas-dev` (Ubuntu) or
7+
/// `openblas-devel` (CentOS/manylinux) to be installed.
8+
fn main() {
9+
if std::env::var("CARGO_FEATURE_OPENBLAS").is_ok() {
10+
println!("cargo:rustc-link-lib=openblas");
11+
}
12+
}

rust/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
//! This module provides optimized implementations of computationally
44
//! intensive operations used in difference-in-differences analysis.
55
6-
// Pull in BLAS linker flags when platform features are enabled.
6+
// Pull in BLAS linker flags for macOS Accelerate.
77
// blas-src is a linker-only crate — extern crate is required to ensure
8-
// the Accelerate framework (macOS) or OpenBLAS (Linux) is actually linked.
9-
#[cfg(any(feature = "accelerate", feature = "openblas"))]
8+
// the Accelerate framework is actually linked.
9+
// For OpenBLAS (Linux), linking is handled by build.rs instead of blas-src
10+
// to avoid the openblas-src -> ureq -> native-tls dependency chain.
11+
#[cfg(feature = "accelerate")]
1012
extern crate blas_src;
1113

1214
use pyo3::prelude::*;

0 commit comments

Comments
 (0)