aboutsummaryrefslogtreecommitdiff
path: root/kernel/nativelib.ml
diff options
context:
space:
mode:
authorMaxime Dénès2016-06-29 11:48:49 +0200
committerMaxime Dénès2016-06-29 11:48:49 +0200
commit58b6784fee71a16719bc4f268dc42830c06a5c63 (patch)
treea9a3859746d2ff97f8c0b8106c96b49f9122a1b7 /kernel/nativelib.ml
parent0e07e69dae3f3f4a99f824533f54a3991aacac6a (diff)
parentdd8d2a1d017d20635f943af205dcb0127a992a59 (diff)
Merge branch 'warnings' into trunk
Was PR#213: New warnings machinery
Diffstat (limited to 'kernel/nativelib.ml')
-rw-r--r--kernel/nativelib.ml20
1 files changed, 13 insertions, 7 deletions
diff --git a/kernel/nativelib.ml b/kernel/nativelib.ml
index 5b92e9554f..d4a67b3999 100644
--- a/kernel/nativelib.ml
+++ b/kernel/nativelib.ml
@@ -55,6 +55,15 @@ let write_ml_code fn ?(header=[]) code =
List.iter (pp_global fmt) (header@code);
close_out ch_out
+let warn_native_compiler_failed =
+ let print = function
+ | Inl (Unix.WEXITED n) -> Pp.(strbrk "Native compiler exited with status" ++ str" " ++ int n)
+ | Inl (Unix.WSIGNALED n) -> Pp.(strbrk "Native compiler killed by signal" ++ str" " ++ int n)
+ | Inl (Unix.WSTOPPED n) -> Pp.(strbrk "Native compiler stopped by signal" ++ str" " ++ int n)
+ | Inr e -> Pp.(strbrk "Native compiler failed with error: " ++ strbrk (Unix.error_message e))
+ in
+ CWarnings.create ~name:"native-compiler-failed" ~category:"native-compiler" print
+
let call_compiler ml_filename =
let load_path = !get_load_paths () in
let load_path = List.map (fun dn -> dn / output_dir) load_path in
@@ -78,15 +87,12 @@ let call_compiler ml_filename =
let res = CUnix.sys_command (ocamlfind ()) args in
let res = match res with
| Unix.WEXITED 0 -> true
- | Unix.WEXITED n ->
- Feedback.msg_warning Pp.(str "command exited with status " ++ int n); false
- | Unix.WSIGNALED n ->
- Feedback.msg_warning Pp.(str "command killed by signal " ++ int n); false
- | Unix.WSTOPPED n ->
- Feedback.msg_warning Pp.(str "command stopped by signal " ++ int n); false in
+ | Unix.WEXITED n | Unix.WSIGNALED n | Unix.WSTOPPED n ->
+ warn_native_compiler_failed (Inl res); false
+ in
res, link_filename
with Unix.Unix_error (e,_,_) ->
- Feedback.msg_warning Pp.(str (Unix.error_message e));
+ warn_native_compiler_failed (Inr e);
false, link_filename
let compile fn code =