Skip to content

Commit 262842c

Browse files
authored
Merge pull request #102 from mike-kfed/arm-cross-compile
respect OPENBLAS_{{CC, FC, HOSTCC}} env vars on linux
2 parents 57b4ffe + d2553df commit 262842c

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

openblas-build/src/build.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,30 @@ pub struct Deliverables {
330330
}
331331

332332
impl Configure {
333+
fn cross_compile_args(&self) -> Result<Vec<String>, Error> {
334+
let mut args = Vec::new();
335+
for name in ["CC", "FC", "HOSTCC"] {
336+
if let Ok(value) = std::env::var(format!("OPENBLAS_{}", name)) {
337+
args.push(format!("{}={}", name, value));
338+
eprintln!("{}={}", name, value);
339+
} else {
340+
eprintln!("not found {}", name);
341+
}
342+
}
343+
// for successful compile all 3 env-vars must be set
344+
if !args.is_empty() && args.len() != 3 {
345+
return Err(Error::MissingCrossCompileInfo);
346+
}
347+
// optional flags
348+
for name in ["RANLIB"] {
349+
if let Ok(value) = std::env::var(format!("OPENBLAS_{}", name)) {
350+
args.push(format!("{}={}", name, value));
351+
eprintln!("{}={}", name, value);
352+
}
353+
}
354+
Ok(args)
355+
}
356+
333357
fn make_args(&self) -> Vec<String> {
334358
let mut args = Vec::new();
335359
if self.no_static {
@@ -467,6 +491,7 @@ impl Configure {
467491
.stdout(out)
468492
.stderr(err)
469493
.args(&self.make_args())
494+
.args(&self.cross_compile_args()?)
470495
.args(["all"])
471496
.env_remove("TARGET")
472497
.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)