From 9e2ac0d0bd27a8bf2c309d038b95e7925dbf67aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 25 Jan 2010 09:21:03 +0100 Subject: compiler: make ignore_native_errors also handle internal hipe errors We must also catch exits, not only errors, since the hipe compilers does an exit/1 if an internal error is found. --- lib/compiler/src/compile.erl | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'lib/compiler/src/compile.erl') diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index f0f962f3ef..d73c9cd762 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -187,9 +187,9 @@ format_error(no_crypto_key) -> format_error({native, E}) -> io_lib:fwrite("native-code compilation failed with reason: ~P.", [E, 25]); -format_error({native_crash, E}) -> - io_lib:fwrite("native-code compilation crashed with reason: ~P.", - [E, 25]); +format_error({native_crash,E,Stk}) -> + io_lib:fwrite("native-code compilation crashed with reason: ~P.\n~P\n", + [E,25,Stk,25]); format_error({open,E}) -> io_lib:format("open error '~s'", [file:format_error(E)]); format_error({epp,E}) -> @@ -1080,25 +1080,27 @@ native_compile_1(St) -> St#compile.core_code, St#compile.code, Opts) of - {ok, {_Type,Bin} = T} when is_binary(Bin) -> - {ok, embed_native_code(St, T)}; - {error, R} -> + {ok,{_Type,Bin}=T} when is_binary(Bin) -> + {ok,embed_native_code(St, T)}; + {error,R} -> case IgnoreErrors of true -> - Ws = [{St#compile.ifile,[{none,?MODULE,{native,R}}]}], - {ok, St#compile{warnings=St#compile.warnings ++ Ws}}; + Ws = [{St#compile.ifile,[{?MODULE,{native,R}}]}], + {ok,St#compile{warnings=St#compile.warnings ++ Ws}}; false -> - Es = [{St#compile.ifile,[{none,?MODULE,{native,R}}]}], - {error, St#compile{errors=St#compile.errors ++ Es}} + Es = [{St#compile.ifile,[{?MODULE,{native,R}}]}], + {error,St#compile{errors=St#compile.errors ++ Es}} end catch - error:R -> + Class:R -> + Stk = erlang:get_stacktrace(), case IgnoreErrors of true -> - Ws = [{St#compile.ifile,[{none,?MODULE,{native_crash,R}}]}], - {ok, St#compile{warnings=St#compile.warnings ++ Ws}}; + Ws = [{St#compile.ifile, + [{?MODULE,{native_crash,R,Stk}}]}], + {ok,St#compile{warnings=St#compile.warnings ++ Ws}}; false -> - exit(R) + erlang:raise(Class, R, Stk) end end. -- cgit v1.2.3