From ca055fc22c3b9d0ac6bbd394562933aa3e044c95 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Mon, 11 Jan 2016 14:37:35 +0100 Subject: More descriptive error message for failed command. CompCert now prints if the assembler, linker or preprocessor command failed and a hint for the user to get the full command line. Bug 17894 --- driver/Driver.ml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/driver/Driver.ml b/driver/Driver.ml index 8509e84a..352cbe41 100644 --- a/driver/Driver.ml +++ b/driver/Driver.ml @@ -60,6 +60,9 @@ let command ?stdout args = argv.(0) fn (Unix.error_message err) param; -1 +let command_error n exc = + eprintf "Error: %s command failed with exit code %d (use -v to see invocation)\n" n exc + let safe_remove file = try Sys.remove file with Sys_error _ -> () @@ -106,8 +109,10 @@ let preprocess ifile ofile = List.rev !prepro_options; [ifile] ] in - if command ?stdout:output cmd <> 0 then begin + let exc = command ?stdout:output cmd in + if exc <> 0 then begin if ofile <> "-" then safe_remove ofile; + command_error "preprocessor" exc; eprintf "Error during preprocessing.\n"; exit 2 end @@ -246,9 +251,10 @@ let assemble ifile ofile = List.rev !assembler_options; [ifile] ] in - if command cmd <> 0 then begin + let exc = command cmd in + if exc <> 0 then begin safe_remove ofile; - eprintf "Error during assembling.\n"; + command_error "assembler" exc; exit 2 end @@ -263,7 +269,11 @@ let linker exe_name files = then ["-L" ^ !stdlib_path; "-lcompcert"] else []) ] in - if command cmd <> 0 then exit 2 + let exc = command cmd in + if exc <> 0 then begin + command_error "linker" exc; + exit 2 + end (* Processing of a .c file *) -- cgit