whitfin/deppie

on_load prevents HiPE compile

Closed this issue · 1 comments

xenji commented

When trying to compile my project using ERL_COMPILER_OPTIONS="[native,{hipe,[o3]}]" MIX_ENV=prod mix deps.compile, with deppie being a transitive dependency, the error mentioned below occurs. I found a post on the erlang mailing list, that using on_load might lead to this problem1.

Tested on:

  • OSX, Erlang 19, Elixir 1.3.3
  • Linux, Erlang 19, Elixir 1.3.3
==> deppie
Compiling 1 file (.ex)
<HiPE (v 3.15.1)> EXITED with reason {'trans_fun/2',on_load} @hipe_beam_to_icode:1170

== Compilation error on file lib/deppie.ex ==
** (CompileError) lib/deppie.ex: internal error in native_compile;

Detailed Stacktrace

crash reason: {badmatch,
    {'EXIT',
        {{hipe_beam_to_icode,1170,{'trans_fun/2',on_load}},
         [{hipe_beam_to_icode,trans_fun,2,
              [{file,"hipe_beam_to_icode.erl"},{line,1170}]},
          {hipe_beam_to_icode,trans_fun,2,
              [{file,"hipe_beam_to_icode.erl"},{line,278}]},
          {hipe_beam_to_icode,trans_mfa_code,5,
              [{file,"hipe_beam_to_icode.erl"},{line,149}]},
          {hipe_beam_to_icode,trans_beam_function_chunk,2,
              [{file,"hipe_beam_to_icode.erl"},{line,134}]},
          {hipe_beam_to_icode,'-module/2-lc$^1/1-1-',2,
              [{file,"hipe_beam_to_icode.erl"},{line,130}]},
          {hipe_beam_to_icode,'-module/2-lc$^1/1-1-',2,
              [{file,"hipe_beam_to_icode.erl"},{line,130}]},
          {hipe,get_beam_icode,4,[{file,"hipe.erl"},{line,600}]},
          {hipe,'-run_compiler_1/3-fun-0-',4,
              [{file,"hipe.erl"},{line,672}]}]}}}

  in function  hipe:get_beam_icode/4 (hipe.erl, line 599)
  in call from hipe:'-run_compiler_1/3-fun-0-'/4 (hipe.erl, line 672)
    (stdlib) lists.erl:1338: :lists.foreach/2
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6

could not compile dependency :deppie, "mix compile" failed. You can recompile this dependency with "mix deps.compile deppie", update it with "mix deps.update deppie" or clean it with "mix deps.clean deppie"

11:43:52.611 [error] Process #PID<0.445.0> raised an exception
** (MatchError) no match of right hand side value: {:EXIT, {{:hipe_beam_to_icode, 1170, {:"trans_fun/2", :on_load}}, [{:hipe_beam_to_icode, :trans_fun, 2, [file: 'hipe_beam_to_icode.erl', line: 1170]}, {:hipe_beam_to_icode, :trans_fun, 2, [file: 'hipe_beam_to_icode.erl', line: 278]}, {:hipe_beam_to_icode, :trans_mfa_code, 5, [file: 'hipe_beam_to_icode.erl', line: 149]}, {:hipe_beam_to_icode, :trans_beam_function_chunk, 2, [file: 'hipe_beam_to_icode.erl', line: 134]}, {:hipe_beam_to_icode, :"-module/2-lc$^1/1-1-", 2, [file: 'hipe_beam_to_icode.erl', line: 130]}, {:hipe_beam_to_icode, :"-module/2-lc$^1/1-1-", 2, [file: 'hipe_beam_to_icode.erl', line: 130]}, {:hipe, :get_beam_icode, 4, [file: 'hipe.erl', line: 600]}, {:hipe, :"-run_compiler_1/3-fun-0-", 4, [file: 'hipe.erl', line: 672]}]}}
    hipe.erl:599: :hipe.get_beam_icode/4
    hipe.erl:672: anonymous fn/4 in :hipe.run_compiler_1/3

Unfortunately I currently cannot suggest a better solution due to lack of knowledge.

Hi @xenji!

This should now be resolved in f81a884. I have no idea how I missed this for so long; my apologies.

I'll release a v1.1.0 shortly with the changes.