Skip to content

Commit 66fb52b

Browse files
committed
respect OPENBLAS_{{CC, FC, HOSTCC}} env vars on linux
1 parent 57b4ffe commit 66fb52b

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
@@ -330,6 +330,23 @@ 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 &vec!["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+
Ok(args)
348+
}
349+
333350
fn make_args(&self) -> Vec<String> {
334351
let mut args = Vec::new();
335352
if self.no_static {
@@ -467,6 +484,7 @@ impl Configure {
467484
.stdout(out)
468485
.stderr(err)
469486
.args(&self.make_args())
487+
.args(&self.cross_compile_args()?)
470488
.args(["all"])
471489
.env_remove("TARGET")
472490
.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)