Skip to content

Sort @standard_token_types for reproducible compilation - #75

Merged
josevalim merged 1 commit into
elixir-makeup:masterfrom
bmwiedemann:sort
Jul 27, 2026
Merged

Sort @standard_token_types for reproducible compilation#75
josevalim merged 1 commit into
elixir-makeup:masterfrom
bmwiedemann:sort

Conversation

@bmwiedemann

Copy link
Copy Markdown
Contributor

@standard_token_types captures Map.keys/1 of a 70-key map at compile time. On modern Erlang/OTP the iteration order of maps with more than 32 keys depends on the atom-table indexes of the keys, which vary between VM instances (atom creation order is racy under the parallel compiler). The unsorted key list is embedded as a literal in Elixir.Makeup.Token.Utils.beam, making it the one module in the ex_doc escript that differs between two builds.

Sorting the keys makes the literal deterministic; no caller depends on the order.

This helps with erlang/otp#4417

See https://reproducible-builds.org/ for why this is good.

This patch was done while working on reproducible builds for openSUSE.

@standard_token_types captures Map.keys/1 of a 70-key map at compile
time. On modern Erlang/OTP the iteration order of maps with more than
32 keys depends on the atom-table indexes of the keys, which vary
between VM instances (atom creation order is racy under the parallel
compiler). The unsorted key list is embedded as a literal in
Elixir.Makeup.Token.Utils.beam, making it the one module in the ex_doc
escript that differs between two builds.

Sorting the keys makes the literal deterministic; no caller depends on
the order.

See https://reproducible-builds.org/ for why this is good.

This patch was done while working on reproducible builds for openSUSE.
@josevalim
josevalim merged commit 5220946 into elixir-makeup:master Jul 27, 2026
@josevalim

Copy link
Copy Markdown
Collaborator

💚 💙 💜 💛 ❤️

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants