summaryrefslogtreecommitdiff
path: root/lib/asn1
diff options
context:
space:
mode:
authorTom Davies <todavies5@gmail.com>2022-04-28 06:31:02 -0700
committerTom Davies <tomdavies@fb.com>2022-06-24 19:10:47 -0700
commitda001d9d75f2cac4ebc577d362a21ebff58080c6 (patch)
tree05c1b71f82bae64bfb5de91c9529e1f61aec2164 /lib/asn1
parenta22b140e4f456a0b872f3205e59f8f0d4ced7114 (diff)
downloaderlang-da001d9d75f2cac4ebc577d362a21ebff58080c6.tar.gz
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.
Diffstat (limited to 'lib/asn1')
-rw-r--r--lib/asn1/src/Makefile12
-rw-r--r--lib/asn1/src/asn1ct_gen.erl6
-rw-r--r--lib/asn1/test/Makefile1
3 files changed, 13 insertions, 6 deletions
diff --git a/lib/asn1/src/Makefile b/lib/asn1/src/Makefile
index 6d02075576..9e13d02c8a 100644
--- a/lib/asn1/src/Makefile
+++ b/lib/asn1/src/Makefile
@@ -102,7 +102,13 @@ ERL_COMPILE_FLAGS += \
-I$(ERL_TOP)/lib/stdlib \
-Werror
-YRL_FLAGS =
+ifeq ($(ERL_DETERMINISTIC),yes)
+ YRL_FLAGS = +deterministic
+ DETERMINISM_FLAG = +deterministic
+else
+ YRL_FLAGS =
+ DETERMINISM_FLAG =
+endif
# ----------------------------------------------------
# Targets
@@ -182,10 +188,10 @@ asn1ct_rtt.erl: prepare_templates.$(EMULATOR) $(RT_TEMPLATES_TARGET)
$(RT_TEMPLATES_TARGET)
prepare_templates.$(EMULATOR): prepare_templates.erl
- $(V_ERLC) prepare_templates.erl
+ $(V_ERLC) $(DETERMINISM_FLAG) prepare_templates.erl
asn1rtt_%.$(EMULATOR): asn1rtt_%.erl
- $(V_ERLC) +debug_info $<
+ $(V_ERLC) +debug_info $(DETERMINISM_FLAG) $<
$(EVAL_CT_MODULES:%=%.erl): prepare_templates.$(EMULATOR) \
$(EBIN)/asn1ct_rtt.$(EMULATOR) \
diff --git a/lib/asn1/src/asn1ct_gen.erl b/lib/asn1/src/asn1ct_gen.erl
index 9950438d4f..88dc88487d 100644
--- a/lib/asn1/src/asn1ct_gen.erl
+++ b/lib/asn1/src/asn1ct_gen.erl
@@ -1331,9 +1331,9 @@ gen_head(#gen{options=Options}=Gen, Mod, Hrl) ->
Options1 =
case Deterministic of
true ->
- % compile:keep_compile_option will filter some of these
- % out of generated .beam files, but this will keep
- % them out of the generated .erl files
+ %% compile:keep_compile_option will filter some of these
+ %% out of generated .beam files, but this will keep
+ %% them out of the generated .erl files
lists:filter(
fun({cwd, _}) -> false;
({outdir, _}) -> false;
diff --git a/lib/asn1/test/Makefile b/lib/asn1/test/Makefile
index 58f7b294f3..de2a38e752 100644
--- a/lib/asn1/test/Makefile
+++ b/lib/asn1/test/Makefile
@@ -138,6 +138,7 @@ RELSYSDIR = $(RELEASE_PATH)/asn1_test
# FLAGS
# ----------------------------------------------------
ERL_COMPILE_FLAGS += +warnings_as_errors +nowarn_export_all
+ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS))
EBIN = .
# ----------------------------------------------------