mrkaspa
Is there a guide about how to use HIPE in elixir?
I have some questions about this:
- Is everything compiled and ran by mix already using hipe, after running iex I see that hipe shows on the message
iex
Erlang/OTP 19 [erts-8.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Interactive Elixir (1.3.2) - press Ctrl+C to exit (type h() ENTER for help)
-
How can I compile only an specific module in erlang I can add the attribute module -compile()
-
Is there a guide about when we should use HIPE and how to use it on elixir?
Most Liked
michalmuskala
The primary reason to use Erlang Abstract Format instead of Core Erlang is tooling. Using that we get, basically for free dialyzer, cover, debugger and erl_eval. Compiling to Core is also a bit awkward since it’s a moving target - it’s treated as an internal detail of the Erlang compiler and changing rather frequently between releases.
sneako
There is an ElixirSips video showing how to use HiPE https://www.dailydrip.com/topics/elixirsips/drips/native-compilation-with-hipe
ellispritchard
For the record, you can set the env-var ERLC_COMPILER_OPTIONS with options to be passed to erlc when compiling Erlang and Elixir code (because Elixir code gets translated to Erlang).
See https://github.com/elixir-lang/elixir/issues/2665
e…g. to compile only your deps native:
ERL_COMPILER_OPTIONS="native" mix deps.compile
You know it’s working if compiling takes much longer!
michalmuskala
You use hipe exactly the same way you do it in erlang - with a module attribute. The syntax in elixir is @compile .... The hipe bit in the VM manifest is merely stating that this VM has support for hipe-compiled programs.
Hipe doesn’t work too good if you have a code that switches often between hipe and non-hipe code - the switches are expensive.
NobbZ
I never used HiPE per module attribute in erlang, but using {erl_opts, [{native, o3}]} in my rebar.config.
So could you please provide a full example of how to activate HiPE for a single module, and for the complete project as well?








