I believe that mix can no longer pass erl compiler options

246 views
Skip to first unread message

Josh Adams

unread,
Jul 28, 2015, 8:45:55 PM7/28/15
to elixir-l...@googlegroups.com
There was a previous github issue that discussed passing compiler options to erlang, in https://github.com/elixir-lang/elixir/issues/2665.  At that time, this worked, because the elixir code server explicitly supported it: https://github.com/elixir-lang/elixir/blob/3cf3eee2ea6db6de83770ab77cdf82e3acf425ad/lib/elixir/src/elixir_code_server.erl#L162

A quick grep through master does not show this as a thing that occurs any longer: https://gist.github.com/knewter/6d3e22db3ed73082ecf3

If you pass invalid ERL_COMPILER_OPTIONS, erlang clearly sees it:

[jadams:~/elixir/rules_engine] master(+29/-21)* ± ERL_COMPILER_OPTIONS="-foo" mix compile --force
Ignoring bad term in ERL_COMPILER_OPTIONS

Also, if you pass ELIXIR_ERL_OPTIONS to the raw elixir or elixirc scripts, they are passed on to the invocation of the erl binary.  https://github.com/elixir-lang/elixir/blob/master/bin/elixir#L109

There is documentation that suggests that this environment variable affects the mix compile task, but invoking the documented command does not produce any more output, which is expected by my reading of the documentation in question: https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/kernel/special_forms.ex#L358

I no longer see a way to pass erl options to the elixir compiler.  I ran into this as I'd like to compile everything using HiPE, because benchmarks of using HiPE for a couple of modules showed *worse* performance than non-HiPE, and Dmytro Lytovchenko suggested in #erlang that that could be caused by a mix of hipe and non-hipe modules:

<kvakvs> jadams: when not all modules in your app are compiled with hipe and it has to switch many times between hipe, erlang and bifs/nifs
<kvakvs> jadams: there is stat you can check, somewhere in process or vm info, context switches
<kvakvs> erlang:statistics/1 with arg 'context_switches'
<kvakvs> if it grows fast, you're in trouble with different hipe/non hipe modules coexisting in a busy app

At any rate, my need to do this is unrelated to the core issue, which is that I believe we no longer have the ability to pass options to the erlang compiler that will be used for elixir source files when using `mix compile`

If I'm incorrect on this point, then I'd love to know how, but I'm not here for support.  I'm here because I believe I've found a regression.  Thanks for reading this far! :)

--
Josh Adams

José Valim

unread,
Jul 29, 2015, 2:02:25 AM7/29/15
to elixir-l...@googlegroups.com
Do you have rebar dependencies? I am thinking that rebar and make deps actually never supported configuring this and that's the source of the issue.

You can use module_name.module_info(:compile) to find out if a module was compiled with native or not. If you known exactly which ones are not, it will help us find out the root cause.



--


José Valim
Skype: jv.ptec
Founder and Director of R&D

Josh Adams

unread,
Jul 29, 2015, 8:02:48 AM7/29/15
to elixir-l...@googlegroups.com
I feel like an idiot, because as it turns out this seems to be working fine if you just call it as suggested: `ERL_COMPILER_OPTIONS="[native,{hipe, [verbose, o3]}]" mix compile`

I did not know I could use module_info(:compile) to test this, which is helpful (I was testing by comparing file sizes last night).  This is a completely bogus report apparently, and I thought I was very thorough :-\

Sorry for the noise.  Still no clue how I goofed this up last night.

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2B83u6E6OH-dNLy%2B7ctSRZ_%3DoJbcUFnm6E%2BTLO5z6h8gA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Josh Adams
Reply all
Reply to author
Forward
0 new messages