mrkaspa

mrkaspa

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?

Showing Posts 1 to 10

michalmuskala

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

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?

sneako

sneako

There is an ElixirSips video showing how to use HiPE https://www.dailydrip.com/topics/elixirsips/drips/native-compilation-with-hipe

ellispritchard

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 Allow mix to pass compiler options to erlang · Issue #2665 · elixir-lang/elixir · GitHub

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!

Exadra37

Exadra37

Not accurate here…

The correct is:

Both Elixir and Erlang are compiled to same byte code.

OvermindDL1

OvermindDL1

No, actually Elixir does output to Erlang code. Erlang Core it might do later, but for now it is still outputting to Erlang itself for a variety of extra ‘free’ compiler checks it gets.

Exadra37

Exadra37

Thanks for the clarification @OvermindDL1 and sorry @ellispritchard for my wrong correction.

This was caused by reading somewhere, more than once, that Elixir was compiled to the same byte code of Erlang, not translated to Erlang code.

Trying to find that sources led me to this article https://medium.com/@fxn/how-does-elixir-compile-execute-code-c1b36c9ec8cf and for what I can understand Elixir is not translated to true Erlang code as some Erlang developer would write, but instead is translated to an Erlang Abstract Format to take advantage of the mentioned BEAM optimisations.

I was not able to find the sources of my misunderstood but at least I know more about what is the compiler process now :slight_smile:

OvermindDL1

OvermindDL1

From my understanding it does output to Erlang itself, not Erlang Core, I know that translating to a lower level was eventually planned (and the new debug segments added to the BEAM facilitate making that easier), but I don’t think it’s been done yet? Would love to find out though. :slight_smile:

Exadra37

Exadra37

Well from the blog post I linked it does look like so…

Maybe I am still misunderstanding something?

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews