From f23434e31aa728e823826169e57abfbf6265d6dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 22 May 2024 13:33:30 +0200 Subject: [PATCH] Make term_to_binary on BEAM chunks deterministic --- lib/elixir/src/elixir_erl.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/elixir/src/elixir_erl.erl b/lib/elixir/src/elixir_erl.erl index 2a6e04c721..e3211a5b2f 100644 --- a/lib/elixir/src/elixir_erl.erl +++ b/lib/elixir/src/elixir_erl.erl @@ -286,7 +286,7 @@ get_module_info(Module) -> exports_md5_info(Struct, Def, Defmacro) -> %% Deprecations do not need to be part of exports_md5 because it is always %% checked by the runtime pass, so it is not really part of compilation. - Md5 = erlang:md5(erlang:term_to_binary({Def, Defmacro, Struct})), + Md5 = erlang:md5(term_to_binary({Def, Defmacro, Struct}, [deterministic])), {clause, 0, [{atom, 0, exports_md5}], [], [elixir_to_erl(Md5)]}. functions_info(Def) -> @@ -481,7 +481,7 @@ docs_chunk(Set, Module, Line, Def, Defmacro, Types, Callbacks) -> ModuleDoc, ModuleDocMeta, FunctionDocs ++ MacroDocs ++ CallbackDocs ++ TypeDocs - }, [compressed]), + }, [deterministic, compressed]), [{<<"Docs">>, DocsChunkData}]; @@ -585,7 +585,7 @@ checker_chunk(#{definitions := Definitions, deprecated := Deprecated, defines_be exports => lists:sort(behaviour_info_exports(DefinesBehaviour) ++ Exports) }, - [{<<"ExCk">>, erlang:term_to_binary({elixir_checker_v1, Contents})}]. + [{<<"ExCk">>, term_to_binary({elixir_checker_v1, Contents}, [deterministic])}]. behaviour_info_exports(true) -> [{{behaviour_info, 1}, #{kind => def, deprecated_reason => nil}}]; behaviour_info_exports(false) -> [].