From 8d87cd67aa8f987d3b2a8b1439c95a635ec17e33 Mon Sep 17 00:00:00 2001 From: Tom Davies Date: Thu, 28 Apr 2022 06:19:09 -0700 Subject: compiler: Make compiler forward +determinsitic flag to epp Makes compile pass along the +deterministic flag for epp to utilise. --- lib/compiler/src/compile.erl | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/compiler/src') diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index 54b1cd3141..7ef37a6082 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -1020,6 +1020,7 @@ do_parse_module(DefEncoding, #compile{ifile=File,options=Opts,dir=Dir}=St) -> R = epp:parse_file(File, [{includes,[".",Dir|inc_paths(Opts)]}, {source_name, SourceName}, + {deterministic, member(deterministic, Opts)}, {macros,pre_defs(Opts)}, {default_encoding,DefEncoding}, {location,StartLocation}, -- cgit v1.2.1 From da001d9d75f2cac4ebc577d362a21ebff58080c6 Mon Sep 17 00:00:00 2001 From: Tom Davies Date: Thu, 28 Apr 2022 06:31:02 -0700 Subject: make: Allow OTP to be built deterministically Add a --enable-deterministic-build to the configure script, which sets ERL_DETERMINISTIC=yes throughout the relevant Makefiles, which then invoke the relevant build stages with the +deterministic option. This addresses absolute paths being included in generated .erl files and compiled .beam files that resulted in builds from different source directories generating different artefacts (which is a component of the issue in erlang#4482). I think it would make sense to make this the default at some stage, but I've put the change behind a flag for now to decouple making deterministic OTP builds possible from making them the default. Having +deterministic set results in compiler options being removed from the module info for modules where this options was used. This may have other implications for users of OTP. For tests themselves, +determinism is not set, since many test cases depend on accessing the test module's compilation options, or other features not available in deterministic mode, in order to configure themselves. For tests of the determinism feature specifically, +deterministic must be explicitly passed to the compiler within the relevant test cases. --- lib/compiler/src/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/compiler/src') diff --git a/lib/compiler/src/Makefile b/lib/compiler/src/Makefile index a9027b3ad8..d801d6baa0 100644 --- a/lib/compiler/src/Makefile +++ b/lib/compiler/src/Makefile @@ -138,6 +138,12 @@ ERL_COMPILE_FLAGS += -Werror ERL_COMPILE_FLAGS += +inline +warn_unused_import \ -I../../stdlib/include -I$(EGEN) -W +warn_missing_spec +ifeq ($(ERL_DETERMINISTIC),yes) + DETERMINISM_FLAG = +deterministic +else + DETERMINISM_FLAG = +endif + # ---------------------------------------------------- # Targets # ---------------------------------------------------- -- cgit v1.2.1