aboutsummaryrefslogtreecommitdiffhomepage
path: root/kernel/nativelib.ml
diff options
context:
space:
mode:
authorGravatar Maxime Dénès <mail@maximedenes.fr>2015-06-13 00:36:02 +0200
committerGravatar Maxime Dénès <mail@maximedenes.fr>2015-06-15 14:06:21 +0200
commitc78e8d35d6431fa9119c863c3b58aed1f53ed4a5 (patch)
treefc09038bf3ab54daad223db51d585ec8902b7caa /kernel/nativelib.ml
parent41d63ab4c702457556d2a0680940d04cd4e33179 (diff)
Native compiler: do not catch exceptions not related to dynlink.
Was making the study of bugs like #4139 painful. Now printing a better error message when a compiled file is missing.
Diffstat (limited to 'kernel/nativelib.ml')
-rw-r--r--kernel/nativelib.ml21
1 files changed, 11 insertions, 10 deletions
diff --git a/kernel/nativelib.ml b/kernel/nativelib.ml
index 29b6bf6de..7cb01b695 100644
--- a/kernel/nativelib.ml
+++ b/kernel/nativelib.ml
@@ -105,22 +105,23 @@ let compile_library dir code fn =
r
(* call_linker links dynamically the code for constants in environment or a *)
-(* conversion test. Silently fails if the file does not exist in bytecode *)
-(* mode, since the standard library is not compiled to bytecode with default *)
-(* settings. *)
+(* conversion test. *)
let call_linker ?(fatal=true) prefix f upds =
rt1 := dummy_value ();
rt2 := dummy_value ();
- if Dynlink.is_native || Sys.file_exists f then
+ if not (Sys.file_exists f) then
+ let msg = "Cannot find native compiler file " ^ f in
+ if fatal then Errors.error msg
+ else Pp.msg_warning (Pp.str msg)
+ else
(try
if Dynlink.is_native then Dynlink.loadfile f else !load_obj f;
register_native_file prefix
- with | Dynlink.Error e ->
- let msg = "Dynlink error, " ^ Dynlink.error_message e in
- if fatal then anomaly (Pp.str msg) else Pp.msg_warning (Pp.str msg)
- | e when Errors.noncritical e ->
- if fatal then anomaly (Errors.print e)
- else Pp.msg_warning (Errors.print_no_report e));
+ with Dynlink.Error e as exn ->
+ let exn = Errors.push exn in
+ let msg = "Dynlink error, " ^ Dynlink.error_message e in
+ if fatal then (Pp.msg_error (Pp.str msg); iraise exn)
+ else Pp.msg_warning (Pp.str msg));
match upds with Some upds -> update_locations upds | _ -> ()
let link_library ~prefix ~dirname ~basename =