Skip to content

Use YRL_ERLC_OPTS instead of ERL_COMPILER_OPTIONS #14326

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

Merged

Conversation

lukebakken
Copy link
Collaborator

@lukebakken lukebakken commented Aug 1, 2025

This is a follow-up to commit 93db480

erlang.mk supports the YRL_ERLC_OPTS variable to set erlc-specific compiler options when processing .yrl and .xrl files. By using this variable, it allows make RMQ_ERLC_OPTS= to disable the +deterministic option. This allows using c() in the erl shell to recompile modules on the fly when a cluster is running.

You can see that, when make RMQ_ERLC_OPTS= is run, these generated files were produced with the +deterministic option, because their -file directives use only basenames.

  • deps/rabbit/src/rabbit_amqp_sql_lexer.erl
  • deps/rabbit/src/rabbit_amqp_sql_parser.erl
-file("rabbit_amqp_sql_parser.yrl", 0).
-module(rabbit_amqp_sql_parser).
-file("rabbit_amqp_sql_parser.erl", 3).
-export([parse/1, parse_and_scan/1, format_error/1]).
-file("rabbit_amqp_sql_parser.yrl", 122).

This commit also ignores those two files, as they will always be auto-generated.

@lukebakken lukebakken self-assigned this Aug 1, 2025
@mergify mergify bot added the make label Aug 1, 2025
@michaelklishin
Copy link
Collaborator

Should we tweak RMQ_ERLC_OPTS defaults to include deterministic?

@lukebakken
Copy link
Collaborator Author

RMQ_ERLC_OPTS already does! This change is so that if someone wants to ensure deterministic is not used anywhere (i.e. you're going to re-compile code in the rabbit app in the erl shell), they run this:

make RMQ_ERLC_OPTS=''

@lukebakken lukebakken force-pushed the lukebakken/make-deterministic-optional-again branch from 1f0a1e6 to 8917544 Compare August 12, 2025 15:35
@lukebakken lukebakken changed the title Use RMQ_ERLC_OPTS for ERL_COMPILER_OPTIONS Use YRL_ERLC_OPTS instead of ERL_COMPILER_OPTIONS Aug 12, 2025
@lukebakken lukebakken force-pushed the lukebakken/make-deterministic-optional-again branch from 8917544 to 9687d44 Compare August 12, 2025 15:36
@lukebakken lukebakken marked this pull request as ready for review August 12, 2025 15:37
@lukebakken lukebakken force-pushed the lukebakken/make-deterministic-optional-again branch from 9687d44 to 2f03d11 Compare August 12, 2025 15:38
@michaelklishin
Copy link
Collaborator

I am not fully certain I understand the potential downsides of ignoring the generated SQL lexer/parser modules but an idea of doing the same thing (gitignoring them in the repository, since they are re-generated) did cross my mind.

@lukebakken
Copy link
Collaborator Author

I am not fully certain I understand the potential downsides of ignoring the generated SQL lexer/parser modules

I think we just need to ensure that anytime a release is built, it re-generates these files, then compiles them. I don't see any reason why that wouldn't happen...

This is a follow-up to commit 93db480

`erlang.mk` supports the `YRL_ERLC_OPTS` variable to set `erlc`-specific
compiler options when processing `.yrl` and `.xrl` files. By using this
variable, it allows `make RMQ_ERLC_OPTS=` to disable the
`+deterministic` option. This allows using `c()` in the erl shell to
recompile modules on the fly when a cluster is running.

You can see that, when `make RMQ_ERLC_OPTS=` is run, these generated
files were produced with the `+deterministic` option, because their
`-file` directives use only basenames.

* `deps/rabbit/src/rabbit_amqp_sql_lexer.erl`
* `deps/rabbit/src/rabbit_amqp_sql_parser.erl`

```
-file("rabbit_amqp_sql_parser.yrl", 0).
-module(rabbit_amqp_sql_parser).
-file("rabbit_amqp_sql_parser.erl", 3).
-export([parse/1, parse_and_scan/1, format_error/1]).
-file("rabbit_amqp_sql_parser.yrl", 122).
```

This commit also ignores those two files, as they will always be
auto-generated.
@lukebakken lukebakken force-pushed the lukebakken/make-deterministic-optional-again branch from 2f03d11 to a87445c Compare August 12, 2025 19:00
@ansd
Copy link
Member

ansd commented Aug 13, 2025

Thank you @lukebakken. This is a great change!

I am not fully certain I understand the potential downsides of ignoring the generated SQL lexer/parser modules

@michaelklishin This approach is fine. In fact, this is what is done in by the Elixir parser.
Elixir grammar:
https://github.com/elixir-lang/elixir/blob/v1.19.0-rc.0/lib/elixir/src/elixir_parser.yrl
The generated .erl file is ignored:
https://github.com/elixir-lang/elixir/blob/v1.19.0-rc.0/.gitignore#L9

@ansd ansd merged commit b6dcca0 into rabbitmq:main Aug 13, 2025
281 of 283 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants