Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Erlang/OTP 25 new features #11220

Closed
9 tasks done
josevalim opened this issue Aug 31, 2021 · 13 comments
Closed
9 tasks done

Support Erlang/OTP 25 new features #11220

josevalim opened this issue Aug 31, 2021 · 13 comments

Comments

@josevalim
Copy link
Member

josevalim commented Aug 31, 2021

To be implemented when Erlang 25 is released:

To be implemented when we require Erlang 25 exclusively:

  • Use "undefined" as node name for remote/rpc and document -start_epmd false -erl_epmd_port 6789 on both vm.args/remote.vm.args if you need epmdless
  • Use :erlang.float_to_binary([:short]) in Float.to_string/1 instead of private API
  • Use new format_status/1 callback for GenServer
  • Remove the calling_self clause in GenServer.call as that is now in Erlang/OTP
  • Use new system certificates

Please do not send PRs for those, as it will take a while until we can effectively accept them.

@hauleth
Copy link
Contributor

hauleth commented Sep 30, 2021

Erlang 25 will also support reconfiguration of logger, which will allow us to use config :kernel, :logger, […] in development and releases without need for restarting whole init (erlang/otp#5186).

@nathany-copia
Copy link

Do you want a separate issue for compiling with OTP 25? This is from GitHub CI, and I tried clearing the CI cache, but it may be related to a NIF?

Running mix local.rebar,--force
  /home/runner/work/_temp/.setup-beam/elixir/bin/mix local.rebar --force
  
  Error: 7.616 [error] beam/beam_load.c(86): Error loading module 'Elixir.Code.Formatter':
  Warning:   lambda already defined for label 749. To fix this, please recompile this module with an OTP 25 compiler.
  
  Error: 7.616 [error] Loading of /home/runner/work/_temp/.setup-beam/elixir/bin/../lib/elixir/ebin/Elixir.Code.Formatter.beam failed: :badfile
  
  ** (UndefinedFunctionError) function Code.Formatter.locals_without_parens/0 is undefined (module Code.Formatter is not available)
      (elixir 1.13.4) Code.Formatter.locals_without_parens()
      (elixir 1.13.4) lib/code/normalizer.ex:22: Code.Normalizer.normalize/2
  Warning:     (elixir 1.13.4) lib/code.ex:1107: Code.quoted_to_algebra/2
  Error: The process '/home/runner/work/_temp/.setup-beam/elixir/bin/mix' failed with exit code 1

@josevalim
Copy link
Member Author

You are using a precompiled Elixir version. It is just a matter of time until we have precompiled versions for OTP 25. It is usually tackled automatically by build tools. You can also compile it yourself.

@nathany-copia
Copy link

Thanks. I've opened an issue with erlef/setup-beam.

erlef/setup-beam#117

@dvic
Copy link
Contributor

dvic commented Jul 18, 2022

I noticed there were also changes to the gen_server application (among others): erlang/otp#5792 Is this something that we need to pull into Elixir as well?

@josevalim
Copy link
Member Author

Our goal is to use the task API for that. We will see how it will go once we support it in OTP 24.

@henrythebuilder
Copy link
Contributor

Note for compile attribute -nifs:

reference: erlang/otp pull request 'compiler: Start all potential nif functions with a nif_start #6193', merged on erlang/otp:master

the pull request change the way attribute -nifs is considered (optional ?):

...
Due to backwards compatibility, the nifs attribute is not required,
so when a module containing a call to erlang:load_nif/2 is
encountered, the compiler is forced to conservatively assume that in
such a module, all functions are potential nifs ...
...
This patch extends the v3_core-pass to make all functions start with a
nif_start instruction when the nifs attribute isn't present in the
module but a call to erlang:load_nif/2 is.
...

@michalmuskala
Copy link
Member

Would it make sense to add support for the -nifs attribute already?

I believe it would be fine to always emit it as a persisted attribute - it would be just ignored on older OTP releases.

I had to do some ugly hacks to get the support in the current version https://github.com/spawnfest/json_native/blob/main/lib/jason_native.ex#L10-L13

@josevalim
Copy link
Member Author

Yes, we can definitely support it. A PR is welcome!

@michalmuskala
Copy link
Member

I looked into this a bit. It's not particularly complicated, but we do need to port validation rules from erl_lint (since Elixir skips running the checks there). In particular, it collects information if there's a call to erlang:load_nif anywhere inside the module

@LostKobrakai
Copy link
Contributor

I'm wondering why the following task requires "OTP 25 exclusively"? Afaik the functionality had been in OTP since 23.

Use "undefined" as node name for remote/rpc and document -start_epmd false -erl_epmd_port 6789 on both vm.args/remote.vm.args if you need epmdless

@josevalim
Copy link
Member Author

I don't remember the details but I tried to add it on main and ran into issues for the RPC case. The rest of the support is already in and you can use undefined in main.

@josevalim
Copy link
Member Author

Next Elixir version will depend on OTP 25+26+27, so we can start tackling this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

7 participants