Skip to content

Commit bce6f09

Browse files
committed
respect OPENBLAS_{{CC, FC, HOSTCC}} env vars on linux
1 parent aa69a8d commit bce6f09

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

openblas-build/src/build.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,23 @@ pub struct Deliverables {
264264
}
265265

266266
impl Configure {
267+
fn cross_compile_args(&self) -> Result<Vec<String>, Error> {
268+
let mut args = Vec::new();
269+
for name in &vec!["CC", "FC", "HOSTCC"] {
270+
if let Ok(value) = std::env::var(format!("OPENBLAS_{}", name)) {
271+
args.push(format!("{}={}", name, value));
272+
eprintln!("{}={}", name, value);
273+
} else {
274+
eprintln!("not found {}", name);
275+
}
276+
}
277+
// for successful compile all 3 env-vars must be set
278+
if !args.is_empty() && args.len() != 3 {
279+
return Err(Error::MissingCrossCompileInfo);
280+
}
281+
Ok(args)
282+
}
283+
267284
fn make_args(&self) -> Vec<String> {
268285
let mut args = Vec::new();
269286
if self.no_static {
@@ -394,6 +411,7 @@ impl Configure {
394411
.stdout(out)
395412
.stderr(err)
396413
.args(&self.make_args())
414+
.args(&self.cross_compile_args()?)
397415
.args(["libs", "netlib", "shared"])
398416
.env_remove("TARGET")
399417
.check_call()

openblas-build/src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ pub enum Error {
2424
#[error("Target {} is unsupported", target)]
2525
UnsupportedTarget { target: String },
2626

27+
#[error("Insufficient cross compile information, need all of OPENBLAS_{{CC, FC, HOSTCC}}")]
28+
MissingCrossCompileInfo,
29+
2730
#[error("Other IO errors: {0:?}")]
2831
IOError(#[from] io::Error),
2932
}

0 commit comments

Comments
 (0)