Skip to content

Sort generated functions for deterministic builds - #500

Merged
whatyouhide merged 1 commit into
elixir-mint:mainfrom
fhunleth:deterministic-build
Aug 11, 2026
Merged

Sort generated functions for deterministic builds#500
whatyouhide merged 1 commit into
elixir-mint:mainfrom
fhunleth:deterministic-build

Conversation

@fhunleth

Copy link
Copy Markdown
Contributor

When rebuilding frame.ex without any source code changes, the resulting
.beam file changed. This was due to functions being reordered in the
compiled .beam file depending on the ordering of several maps. The fix
is to sort the maps to make the order deterministic.

When rebuilding frame.ex without any source code changes, the resulting
.beam file changed. This was due to functions being reordered in the
compiled .beam file depending on the ordering of several maps. The fix
is to sort the maps to make the order deterministic.
@fhunleth

Copy link
Copy Markdown
Contributor Author

Just to provide some more context here, it's pretty easy to see that something changed in the build products with Nerves since firmware images get referred to by their checksums. This was found by building the same project twice and noticing an unexpected change to the final firmware. On inspection, this was a harmless change, but it's nice when you don't have to look through a .beam file to figure that out. Plus getting rid of the change reduces the size of delta firmware updates by a little bit. I'm hoping that deterministic builds are helpful to others too.

@fhunleth

Copy link
Copy Markdown
Contributor Author

Last note, when I ran the unit tests on macOS, I had 16 failures, but those tests failed before and after the change so I think I'm not running the tests correctly.

@whatyouhide

Copy link
Copy Markdown
Contributor

This is great, thank you Frank 馃

@whatyouhide
whatyouhide merged commit 312574b into elixir-mint:main Aug 11, 2026
3 checks passed
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