Skip to content

Commit 1a7543b

Browse files
committed
Output error log of make when failed
1 parent 3258734 commit 1a7543b

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

openblas-build/src/build.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,32 @@ impl Configure {
230230
let out = fs::File::create(out_dir.join("out.log")).expect("Cannot create log file");
231231
let err = fs::File::create(out_dir.join("err.log")).expect("Cannot create log file");
232232

233-
// This will automatically run in parallel without `-j` flag
234-
Command::new("make")
233+
// Run `make` as an subprocess
234+
//
235+
// - This will automatically run in parallel without `-j` flag
236+
// - The `make` of OpenBLAS outputs 30k lines,
237+
// which will be redirected into `out.log` and `err.log`.
238+
match Command::new("make")
235239
.current_dir(out_dir)
236240
.stdout(unsafe { Stdio::from_raw_fd(out.into_raw_fd()) }) // this works only for unix
237241
.stderr(unsafe { Stdio::from_raw_fd(err.into_raw_fd()) })
238242
.args(&self.make_args())
239-
.check_call()?;
243+
.status()
244+
{
245+
Ok(status) => {
246+
if !status.success() {
247+
let err =
248+
fs::read_to_string(out_dir.join("err.log")).expect("Cannot read log file");
249+
bail!("`make` returns non-zero status {}:\n{}", status, err);
250+
}
251+
}
252+
Err(error) => {
253+
bail!(
254+
"Cannot start subprocess ({}). Maybe `make` does not exist.",
255+
error
256+
);
257+
}
258+
}
240259

241260
let make_conf = MakeConf::new(out_dir.join("Makefile.conf"))?;
242261

0 commit comments

Comments
 (0)