Skip to content

Commit

Permalink
Merge pull request #102 from mike-kfed/arm-cross-compile
Browse files Browse the repository at this point in the history
respect OPENBLAS_{{CC, FC, HOSTCC}} env vars on linux
  • Loading branch information
termoshtt committed Feb 3, 2024
2 parents 57b4ffe + d2553df commit 262842c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions openblas-build/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,30 @@ pub struct Deliverables {
}

impl Configure {
fn cross_compile_args(&self) -> Result<Vec<String>, Error> {
let mut args = Vec::new();
for name in ["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);
}
// 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)
}

fn make_args(&self) -> Vec<String> {
let mut args = Vec::new();
if self.no_static {
Expand Down Expand Up @@ -467,6 +491,7 @@ impl Configure {
.stdout(out)
.stderr(err)
.args(&self.make_args())
.args(&self.cross_compile_args()?)
.args(["all"])
.env_remove("TARGET")
.check_call()
Expand Down
3 changes: 3 additions & 0 deletions openblas-build/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down

0 comments on commit 262842c

Please sign in to comment.