<div dir="ltr">Hello,<div><br></div><div>I'm trying to use the -on_load() directive on NetBSD/amd64, but I'm having problems. Even this simple test file (test.erl) fails:</div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><p>-module(test).<br>-on_load(load_my_nifs/0).<br><br>load_my_nifs() -><br> io:format("Loaded module.~n"),<br> ok.<br></p>
</blockquote><div>Try to compile as byte-code and then native:</div><div><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">$ erl<br>Erlang/OTP 17 (erts-6.3) [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]<br><br>Eshell V6.3 (abort with ^G)<br>1> c(test).<br>Loaded module.<br>{ok,test}<br>2> c(test, [native]).<br><HiPE (v 3.11.2)> EXITED with reason {'trans_fun/2',on_load} @hipe_beam_to_icode:1174<br><br>=ERROR REPORT==== 18-Feb-2015::13:42:46 ===<br>Error in process <0.37.0> with exit value: {{badmatch,{'EXIT',{{hipe_beam_to_icode,1174,{'trans_fun/2',on_load}},[{hipe_beam_to_icode,trans_fun,2,[]},{hipe_beam_to_icode,trans_fun,2,[]},{hipe_beam_to_icode,trans_mfa_code,5,[]},{hipe_beam_to_icode,trans_beam_function_chunk...<br><br>test.erl: internal error in native_compile;<br>crash reason: {badmatch,{'EXIT',{{hipe_beam_to_icode,1174,{'trans_fun/2',on_load}},<br> [{hipe_beam_to_icode,trans_fun,2,[]},<br> {hipe_beam_to_icode,trans_fun,2,[]},<br> {hipe_beam_to_icode,trans_mfa_code,5,[]},<br> {hipe_beam_to_icode,trans_beam_function_chunk,2,[]},<br> {hipe_beam_to_icode,'-module/2-lc$^1/1-1-',2,[]},<br> {hipe,get_beam_icode,4,[]},<br> {hipe,'-run_compiler_1/3-fun-0-',4,[]},<br> {hipe_icode_callgraph,get_called_modules,1,[]}]}}}<br><br> in function hipe:get_beam_icode/4<br> in call from hipe:'-run_compiler_1/3-fun-0-'/4<br> in call from hipe_icode_callgraph:get_called_modules/1<br>error<br>3></blockquote>
<div><div><br></div><div>This also happens on an R16B03-1 installation. The documentation doesn't mention the directive is limited to byte-code compiles. But even if it was, the native compiler should print an error instead of crashing.</div><div><br></div><div>Are other platforms having this problem?</div><div><br></div>-- <br><div>Rich<br></div>
</div></div>