[erlang-bugs] R15B02 HiPE can't compile modules with on_load attribute

Kostis Sagonas kostis@REDACTED
Mon Nov 26 15:35:14 CET 2012


On 11/25/2012 08:16 PM, José Valim wrote:
> HiPE can't compile a module with on_load attribute. This sample module
> fails:
>
>     -module(foo).
>     -on_load(do_nothing/0).
>
>     %% Exporting the function doesn't affect the outcome
>     %% -exports([do_nothing/0]).
>
>     do_nothing() -> ok.
>
>
> When compiled via command line or via compile:forms.
> A snippet of the error message is:
>
> =ERROR REPORT==== 25-Nov-2012::18:48:29 ===
> Error in process <0.88.0> with exit value:
> {{badmatch,{'EXIT',{{hipe_beam_to_icode,1103,{'trans_fun/2',on_load}},[{hipe_beam_to_icode,trans_fun,2,[{file,"hipe_beam_to_icode.erl"},{line,1103}]},{hipe_beam_to_icode,trans_fun,2,[{file,"hipe_beam_to_icode.erl"},{line,253}]},{hipe_beam_to_icode...

I can easily provide a patch that makes the HiPE compiler not crash when 
it finds an "on_load" BEAM instruction, but the real fix involves 
changing the HiPE loader to trigger execution of functions specified as 
part of the on_load attribute declaration.

Perhaps somebody at OTP who is more familiar with the magic that the 
BEAM loader does when it finds BEAM code with on_load instructions can 
do this -- or at least help here.

Kostis



More information about the erlang-bugs mailing list