[erlang-questions] HiPE compiler

Matthew Evans mattevans123@REDACTED
Mon Jan 30 02:39:06 CET 2012

Thanks Kostis,
Calling hipe:c/1 on the beam file was exactly what I wanted. I thought you could only run it on source files.

> Date: Sun, 29 Jan 2012 22:35:23 +0200
> From: kostis@REDACTED
> To: erlang-questions@REDACTED
> Subject: Re: [erlang-questions] HiPE compiler
> On 01/29/12 19:01, Matthew Evans wrote:
> > Hi group,
> >
> > My understanding is that HiPE takes Erlang byte code beam files as the
> > input to produce modified combined HiPE + byte code beam files.
> >
> > I'm thinking of using HiPE on a project. Unfortunately the build system
> > is mixed, and I'd rather not go down the cross-compiler route. My
> > question is - is there a way to create "HiPE targets" just from beam
> > files on the target platform? The source will, obviously, not be
> > available on the target platform.
> I am not sure I understand your question well, but I'll give it a shot 
> in answering it anyway.
> Unlike BEAM byte code, the native code that the HiPE compiler generates 
> has a very strong dependence on the specifics of the Erlang runtime 
> system which is running the code.  This means that you cannot native 
> compile the code using Erlang/OTP R-X and expect it to run on R-Y where 
> X and Y are different. This holds even for minor revisions of the same 
> major release (i.e. code compiled for R14B03 cannot run on R14B03.) 
> Also obviously there is a strong dependency on the target architecture: 
> i.e. you cannot compile code for an x86 and expect it to run on an ARM.
> But you can compile your code natively and run it on another target if 
> the machine that you compile in and the target machine are running 
> exactly the same Erlang/OTP release and have the same underlying 
> architecture. In this case you can use:
> 	erlc +native FILE.erl -o FILE.beam
> and transfer these FILE.beam(s) on the target machine. I am pretty sure 
> this works.
> But what you can also do the following: compile the files to BEAM byte 
> code and transfer these files to the target machine and then native 
> compile these files on the fly (as part of the start of your 
> application) by using something like the following:
> 	lists:foreach(fun (F) -> hipe:c(F) end, BEAM_FILES)
> This will compile the BEAM files in memory, generate native code for 
> them and load them in the running system. (Obviously, you can choose to 
> compile only a subset of your files, perhaps only those that are time 
> critical.)  There is obviously a small start up cost in doing this, but 
> in most applications this should not be an issue.
> Let me know how it goes.  We can continue this perhaps offline.
> Kostis
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120129/0a7815ed/attachment.htm>

More information about the erlang-questions mailing list