From 66fb52baf8ea566d1afe8437820b46876ef9b55b Mon Sep 17 00:00:00 2001 From: Michael Kefeder Date: Fri, 5 May 2023 14:26:25 +0200 Subject: [PATCH 1/2] respect OPENBLAS_{{CC, FC, HOSTCC}} env vars on linux --- openblas-build/src/build.rs | 18 ++++++++++++++++++ openblas-build/src/error.rs | 3 +++ 2 files changed, 21 insertions(+) diff --git a/openblas-build/src/build.rs b/openblas-build/src/build.rs index 6e87fe1..a2c141c 100644 --- a/openblas-build/src/build.rs +++ b/openblas-build/src/build.rs @@ -330,6 +330,23 @@ pub struct Deliverables { } impl Configure { + fn cross_compile_args(&self) -> Result, Error> { + let mut args = Vec::new(); + for name in &vec!["CC", "FC", "HOSTCC"] { + if let Ok(value) = std::env::var(format!("OPENBLAS_{}", name)) { + args.push(format!("{}={}", name, value)); + eprintln!("{}={}", name, value); + } else { + eprintln!("not found {}", name); + } + } + // for successful compile all 3 env-vars must be set + if !args.is_empty() && args.len() != 3 { + return Err(Error::MissingCrossCompileInfo); + } + Ok(args) + } + fn make_args(&self) -> Vec { let mut args = Vec::new(); if self.no_static { @@ -467,6 +484,7 @@ impl Configure { .stdout(out) .stderr(err) .args(&self.make_args()) + .args(&self.cross_compile_args()?) .args(["all"]) .env_remove("TARGET") .check_call() diff --git a/openblas-build/src/error.rs b/openblas-build/src/error.rs index e49e9e8..9ec2fef 100644 --- a/openblas-build/src/error.rs +++ b/openblas-build/src/error.rs @@ -24,6 +24,9 @@ pub enum Error { #[error("Target {} is unsupported", target)] UnsupportedTarget { target: String }, + #[error("Insufficient cross compile information, need all of OPENBLAS_{{CC, FC, HOSTCC}}")] + MissingCrossCompileInfo, + #[error("Other IO errors: {0:?}")] IOError(#[from] io::Error), } From d2553dfb846fd1c49190f2c1ba1c68f09e88760d Mon Sep 17 00:00:00 2001 From: Michael Kefeder Date: Sun, 21 May 2023 11:02:46 +0200 Subject: [PATCH 2/2] add optional support for RANLIB --- openblas-build/src/build.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openblas-build/src/build.rs b/openblas-build/src/build.rs index a2c141c..5be60d7 100644 --- a/openblas-build/src/build.rs +++ b/openblas-build/src/build.rs @@ -332,7 +332,7 @@ pub struct Deliverables { impl Configure { fn cross_compile_args(&self) -> Result, Error> { let mut args = Vec::new(); - for name in &vec!["CC", "FC", "HOSTCC"] { + for name in ["CC", "FC", "HOSTCC"] { if let Ok(value) = std::env::var(format!("OPENBLAS_{}", name)) { args.push(format!("{}={}", name, value)); eprintln!("{}={}", name, value); @@ -344,6 +344,13 @@ impl Configure { if !args.is_empty() && args.len() != 3 { return Err(Error::MissingCrossCompileInfo); } + // optional flags + for name in ["RANLIB"] { + if let Ok(value) = std::env::var(format!("OPENBLAS_{}", name)) { + args.push(format!("{}={}", name, value)); + eprintln!("{}={}", name, value); + } + } Ok(args) }