[erlang-questions] What are the differences between beam files produced by c(...) and erlc?

Max Lapshin max.lapshin@REDACTED
Sat Jun 15 18:27:59 CEST 2013


1> beam_lib:info("c_hello_world.beam").
[{file,"c_hello_world.beam"},
 {module,hello_world},
 {chunks,[{"Atom",20,61},
          {"Code",92,79},
          {"StrT",180,0},
          {"ImpT",188,40},
          {"ExpT",236,40},
          {"LitT",284,38},
          {"LocT",332,4},
          {"Attr",344,40},
          {"CInf",392,141},
          {"Abst",544,0},
          {"Line",552,22}]}]

2> beam_lib:info("erlc_hello_world.beam").
[{file,"erlc_hello_world.beam"},
 {module,hello_world},
 {chunks,[{"Atom",20,61},
          {"Code",92,79},
          {"StrT",180,0},
          {"ImpT",188,40},
          {"ExpT",236,40},
          {"LitT",284,38},
          {"LocT",332,4},
          {"Attr",344,40},
          {"CInf",392,205},
          {"Abst",608,0},
          {"Line",616,22}]}]


CInf are different.

6> {ok, {hello_world,[{"CInf",CHelloWorld}]}} =
beam_lib:chunks("c_hello_world.beam", ["CInf"]).
{ok,{hello_world,[{"CInf",
                   <<131,108,0,0,0,4,104,2,100,0,7,111,112,116,105,111,
                     110,115,106,104,2,100,...>>}]}}
7> erlang:binary_to_term(CHelloWorld).
[{options,[]},
 {version,"4.9.1"},
 {time,{2013,6,15,16,19,23}},
 {source,"/home/ysg/Documents/Development/tweann/source/hello_world.erl"}]




8> {ok, {hello_world,[{"CInf",ERLCHelloWorld}]}} =
beam_lib:chunks("erlc_hello_world.beam", ["CInf"]).
{ok,{hello_world,[{"CInf",
                   <<131,108,0,0,0,4,104,2,100,0,7,111,112,116,105,111,
                     110,115,108,0,0,0,...>>}]}}
9> erlang:binary_to_term(ERLCHelloWorld).
[{options,[{outdir,"/home/ysg/Documents/Development/tweann/source"}]},
 {version,"4.9.1"},
 {time,{2013,6,15,16,18,33}},
 {source,"/home/ysg/Documents/Development/tweann/source/hello_world.erl"}]


So, here is the difference: erlc variant has different compile options
and include outdir.



More information about the erlang-questions mailing list