Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
5417-make-Allow-OTP-to-be-built-deterministical...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 5417-make-Allow-OTP-to-be-built-deterministically.patch of Package erlang
From da001d9d75f2cac4ebc577d362a21ebff58080c6 Mon Sep 17 00:00:00 2001 From: Tom Davies <todavies5@gmail.com> Date: Thu, 28 Apr 2022 06:31:02 -0700 Subject: [PATCH 7/7] 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. --- Makefile.in | 9 ++++- configure | 4 ++ configure.src | 4 ++ erts/configure | 19 ++++++++++ erts/configure.ac | 13 +++++++ erts/emulator/test/Makefile | 2 +- erts/preloaded/src/Makefile | 4 ++ erts/preloaded/src/add_abstract_code | 9 ++++- lib/asn1/src/Makefile | 12 ++++-- lib/asn1/src/asn1ct_gen.erl | 6 +-- lib/asn1/test/Makefile | 1 + lib/common_test/test/Makefile | 1 + lib/compiler/src/Makefile | 6 +++ lib/compiler/test/Makefile | 1 + lib/compiler/test/test_lib.erl | 57 +++++++++++++--------------- lib/debugger/test/Makefile | 1 + lib/diameter/src/Makefile | 12 ++++-- lib/diameter/test/Makefile | 1 + lib/edoc/test/Makefile | 1 + lib/eldap/test/Makefile | 1 + lib/erl_docgen/test/Makefile | 1 + lib/eunit/test/Makefile | 1 + lib/ftp/test/Makefile | 1 + lib/inets/test/Makefile | 1 + lib/kernel/test/Makefile | 1 + lib/megaco/Makefile | 10 ++++- lib/megaco/src/app/megaco.mk | 6 +++ lib/megaco/src/binary/depend.mk | 4 ++ lib/megaco/test/Makefile | 2 + lib/mnesia/test/Makefile | 1 + lib/observer/test/Makefile | 1 + lib/odbc/test/Makefile | 2 + lib/os_mon/test/Makefile | 1 + lib/parsetools/test/Makefile | 1 + lib/parsetools/test/leex_SUITE.erl | 10 +++-- lib/parsetools/test/yecc_SUITE.erl | 10 +++-- lib/public_key/asn1/Makefile | 4 ++ lib/public_key/test/Makefile | 1 + lib/reltool/test/Makefile | 1 + lib/runtime_tools/test/Makefile | 1 + lib/sasl/test/Makefile | 1 + lib/snmp/src/compile/Makefile | 4 ++ lib/snmp/test/Makefile | 1 + lib/ssh/test/Makefile | 1 + lib/ssl/test/Makefile | 1 + lib/stdlib/src/Makefile | 13 +++++-- lib/stdlib/test/Makefile | 1 + lib/syntax_tools/test/Makefile | 1 + lib/tftp/test/Makefile | 1 + lib/tools/test/Makefile | 1 + lib/xmerl/src/Makefile | 9 ++++- lib/xmerl/test/Makefile | 1 + make/otp.mk.in | 7 ++++ 53 files changed, 208 insertions(+), 58 deletions(-) diff --git a/Makefile.in b/Makefile.in index 28567ddaa5..cc92df3a21 100644 --- a/Makefile.in +++ b/Makefile.in @@ -294,6 +294,13 @@ RELEASE_ROOT = $(TESTROOT) endif endif +# ---------------------------------------------------------------------- + +ifeq ($(ERL_DETERMINISTIC),yes) + DETERMINISM_FLAG = +deterministic +else + DETERMINISM_FLAG = +endif # ---------------------------------------------------------------------- @@ -1036,7 +1043,7 @@ primary_bootstrap: primary_bootstrap_build: primary_bootstrap_mkdirs primary_bootstrap_compiler \ primary_bootstrap_stdlib - $(make_verbose)cd lib && $(MAKE) ERLC_FLAGS='-pa $(BOOTSTRAP_COMPILER)/ebin' \ + $(make_verbose)cd lib && $(MAKE) ERLC_FLAGS='-pa $(BOOTSTRAP_COMPILER)/ebin $(DETERMINISM_FLAG)' \ BOOTSTRAP_TOP=$(BOOTSTRAP_TOP) \ BOOTSTRAP=1 opt diff --git a/configure b/configure index 19b4b01ec8..6b95e18181 100755 --- a/configure +++ b/configure @@ -139,6 +139,10 @@ while test $# != 0; do pie_cflags="-fno-PIE" pie_ldflags="-no-pie" ;; + --enable-deterministic-build) + config_arguments="$config_arguments --enable-deterministic-build";; + --disable-deterministic-build) + config_arguments="$config_arguments --disable-deterministic-build";; CFLAGS=* | LDFLAGS=*) flgs_var=`echo "$1" | sed 's/=.*$//'` flgs_val=`echo "$1" | sed 's/^[^=]*=//'` diff --git a/configure.src b/configure.src index f0afd5c6ee..1a24bfc693 100644 --- a/configure.src +++ b/configure.src @@ -139,6 +139,10 @@ while test $# != 0; do pie_cflags="-fno-PIE" pie_ldflags="-no-pie" ;; + --enable-deterministic-build) + config_arguments="$config_arguments --enable-deterministic-build";; + --disable-deterministic-build) + config_arguments="$config_arguments --disable-deterministic-build";; CFLAGS=* | LDFLAGS=*) flgs_var=`echo "$1" | sed 's/=.*$//'` flgs_val=`echo "$1" | sed 's/^[^=]*=//'` diff --git a/erts/configure b/erts/configure index 3a563fd0e4..a85a6d0f00 100755 --- a/erts/configure +++ b/erts/configure @@ -650,6 +650,7 @@ ac_func_c_list= ac_subst_vars='LTLIBOBJS LIBOBJS +ERL_DETERMINISTIC CFLAGS32 CC32 JAVAC @@ -868,6 +869,7 @@ enable_prefer_elapsed_monotonic_time_during_suspend enable_gettimeofday_as_os_system_time with_javac enable_sanitizers +enable_deterministic_build ' ac_precious_vars='build_alias host_alias @@ -1610,6 +1612,9 @@ Optional Features: Force usage of gettimeofday() for OS system time --enable-sanitizers[=comma-separated list of sanitizers] Default=address,undefined + --enable-deterministic-build + enable build determinism, stripping absolute paths + from build output Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -25435,6 +25440,20 @@ LDFLAGS="$LDFLAGS $sanitizers" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +# Check whether --enable-deterministic-build was given. +if test ${enable_deterministic_build+y} +then : + enableval=$enable_deterministic_build; case "$enableval" in + no) ERL_DETERMINISTIC=no ;; + *) ERL_DETERMINISTIC=yes ;; + esac +else $as_nop + ERL_DETERMINISTIC=no +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for -O switch" >&5 $as_echo_n "checking CFLAGS for -O switch... " >&6; } case "$CFLAGS" in diff --git a/erts/configure.in b/erts/configure.in index 29eec06f65..9ee5a37a40 100644 --- a/erts/configure.in +++ b/erts/configure.in @@ -3570,6 +3570,19 @@ CFLAGS="$CFLAGS $sanitizers" CFLAGS="-std=gnu99 $CFLAGS" DEBUG_CFLAGS="-std=gnu99 $DEBUG_CFLAGS"]) +dnl ---------------------------------------------------------------------- +dnl Enable build determinism flag +dnl ---------------------------------------------------------------------- + +AC_ARG_ENABLE(deterministic-build, +AS_HELP_STRING([--enable-deterministic-build], [enable build determinism, stripping absolute paths from build output]), +[ case "$enableval" in + no) ERL_DETERMINISTIC=no ;; + *) ERL_DETERMINISTIC=yes ;; + esac ], +ERL_DETERMINISTIC=no) +AC_SUBST(ERL_DETERMINISTIC) + AC_MSG_CHECKING([CFLAGS for -O switch]) case "$CFLAGS" in *-O*) AC_MSG_RESULT([yes]) ;; diff --git a/erts/emulator/test/Makefile b/erts/emulator/test/Makefile index 89ba1239d2..33a80f2e53 100644 --- a/erts/emulator/test/Makefile +++ b/erts/emulator/test/Makefile @@ -182,7 +182,7 @@ RELSYSDIR = $(RELEASE_PATH)/emulator_test # FLAGS # ---------------------------------------------------- ERL_MAKE_FLAGS += -ERL_COMPILE_FLAGS += +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$($(ERL_COMPILE_FLAGS))) # ---------------------------------------------------- # Targets diff --git a/erts/preloaded/src/Makefile b/erts/preloaded/src/Makefile index 191341a9f5..1994aa1302 100644 --- a/erts/preloaded/src/Makefile +++ b/erts/preloaded/src/Makefile @@ -86,6 +86,10 @@ STDLIB_INCLUDE=$(ERL_TOP)/lib/stdlib/include ERL_COMPILE_FLAGS += +debug_info -I$(KERNEL_SRC) -I$(KERNEL_INCLUDE) +ifeq ($(ERL_DETERMINISTIC),yes) + ERL_COMPILE_FLAGS += deterministic +endif + DIA_PLT = erts-preloaded.plt DIA_ANALYSIS = $(basename $(DIA_PLT)).dialyzer_analysis ifeq ($(DIAW_EH),true) diff --git a/erts/preloaded/src/add_abstract_code b/erts/preloaded/src/add_abstract_code index 9040199417..11add7773d 100644 --- a/erts/preloaded/src/add_abstract_code +++ b/erts/preloaded/src/add_abstract_code @@ -39,7 +39,12 @@ main([BeamFile,AbstrFile]) -> fix_options(CInf0) -> CInf1 = binary_to_term(CInf0), - {options,Opts0} = lists:keyfind(options, 1, CInf1), - Opts = Opts0 -- [from_asm], + Opts = + case lists:keyfind(options, 1, CInf1) of + {options,Opts0} -> + Opts0 -- [from_asm]; + false -> + [] + end, CInf = lists:keyreplace(options, 1, CInf1, {options,Opts}), {term_to_binary(CInf), Opts}. 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 = . # ---------------------------------------------------- diff --git a/lib/common_test/test/Makefile b/lib/common_test/test/Makefile index 4cc10cbdcc..1af9990bb7 100644 --- a/lib/common_test/test/Makefile +++ b/lib/common_test/test/Makefile @@ -99,6 +99,7 @@ RELSYSDIR = $(RELEASE_PATH)/common_test_test ERL_MAKE_FLAGS += ERL_COMPILE_FLAGS += +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . 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 # ---------------------------------------------------- diff --git a/lib/compiler/test/Makefile b/lib/compiler/test/Makefile index 37fb570154..8e145ae136 100644 --- a/lib/compiler/test/Makefile +++ b/lib/compiler/test/Makefile @@ -168,6 +168,7 @@ RELSYSDIR = $(RELEASE_PATH)/compiler_test ERL_MAKE_FLAGS += ERL_COMPILE_FLAGS += +clint +clint0 +ssalint +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/compiler/test/test_lib.erl b/lib/compiler/test/test_lib.erl index 39a887834c..7182dd6555 100644 --- a/lib/compiler/test/test_lib.erl +++ b/lib/compiler/test/test_lib.erl @@ -82,36 +82,33 @@ uniq() -> opt_opts(Mod) -> Comp = Mod:module_info(compile), - case lists:keyfind(options, 1, Comp) of - {options,Opts} -> - lists:filter(fun - (debug_info) -> true; - (dialyzer) -> true; - (deterministic) -> true; - ({enable_feature,_}) -> true; - (inline) -> true; - (no_bsm3) -> true; - (no_bsm_opt) -> true; - (no_copt) -> true; - (no_fun_opt) -> true; - (no_init_yregs) -> true; - (no_make_fun3) -> true; - (no_module_opt) -> true; - (no_postopt) -> true; - (no_put_tuple2) -> true; - (no_recv_opt) -> true; - (no_share_opt) -> true; - (no_shared_fun_wrappers) -> true; - (no_ssa_float) -> true; - (no_ssa_opt) -> true; - (no_stack_trimming) -> true; - (no_swap) -> true; - (no_type_opt) -> true; - (_) -> false - end, Opts); - %% `options` may not be set at all if +deterministic is enabled - false -> [] - end. + %% `options` may not be set at all if +deterministic is enabled. + Opts = proplists:get_value(options, Comp, []), + lists:filter(fun + (debug_info) -> true; + (dialyzer) -> true; + ({feature,_,enable}) -> true; + ({feature,_,disable}) -> true; + (inline) -> true; + (no_bsm3) -> true; + (no_bsm_opt) -> true; + (no_copt) -> true; + (no_fun_opt) -> true; + (no_init_yregs) -> true; + (no_make_fun3) -> true; + (no_module_opt) -> true; + (no_postopt) -> true; + (no_put_tuple2) -> true; + (no_recv_opt) -> true; + (no_share_opt) -> true; + (no_shared_fun_wrappers) -> true; + (no_ssa_float) -> true; + (no_ssa_opt) -> true; + (no_stack_trimming) -> true; + (no_swap) -> true; + (no_type_opt) -> true; + (_) -> false + end, Opts). %% Some test suites gets cloned (e.g. to "record_SUITE" to %% "record_no_opt_SUITE"), but the data directory is not cloned. diff --git a/lib/debugger/test/Makefile b/lib/debugger/test/Makefile index 14186798f0..015b5f9c29 100644 --- a/lib/debugger/test/Makefile +++ b/lib/debugger/test/Makefile @@ -71,6 +71,7 @@ RELSYSDIR = $(RELEASE_PATH)/debugger_test ERL_MAKE_FLAGS += ERL_COMPILE_FLAGS += +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/diameter/src/Makefile b/lib/diameter/src/Makefile index 6dd3667a46..75e23d4191 100644 --- a/lib/diameter/src/Makefile +++ b/lib/diameter/src/Makefile @@ -122,6 +122,12 @@ ERL_COMPILE_FLAGS += \ # -pa is to be able to include_lib from the include directory: the # path must contain the application name. +ifeq ($(ERL_DETERMINISTIC),yes) + DETERMINISM_FLAG = +deterministic +else + DETERMINISM_FLAG = +endif + # ---------------------------------------------------- # Targets # ---------------------------------------------------- @@ -152,7 +158,7 @@ $(filter-out opt, $(TYPES)): # The dictionary parser. gen/$(DICT_YRL).erl: compiler/$(DICT_YRL).yrl $(yecc_verbose) \ - $(ERLC) -Werror -o $(@D) $< + $(ERLC) -Werror $(DETERMINISM_FLAG) -o $(@D) $< # Generate the app file. $(APP_TARGET): $(APP_SRC) ../vsn.mk modules.mk @@ -256,8 +262,8 @@ release_spec: opt $(INSTALL_DATA) $(EXTERNAL_HRLS:%=../include/%) $(DICT_HRLS) \ "$(RELSYSDIR)/include" $(INSTALL_DATA) $(DICTS:%=dict/%.dia) "$(RELSYSDIR)/src/dict" - $(MAKE) $(TARGET_DIRS:%/=release_src_%) - $(MAKE) $(EXAMPLE_DIRS:%/=release_examples_%) + $(MAKE) ERL_DETERMINISTIC=$(ERL_DETERMINISTIC) $(TARGET_DIRS:%/=release_src_%) + $(MAKE) ERL_DETERMINISTIC=$(ERL_DETERMINISTIC) $(EXAMPLE_DIRS:%/=release_examples_%) $(TARGET_DIRS:%/=release_src_%): release_src_%: $(INSTALL_DIR) "$(RELSYSDIR)/src/$*" diff --git a/lib/diameter/test/Makefile b/lib/diameter/test/Makefile index 53b5fd4618..98fb9ff652 100644 --- a/lib/diameter/test/Makefile +++ b/lib/diameter/test/Makefile @@ -59,6 +59,7 @@ ERL_COMPILE_FLAGS += +warn_export_vars \ -I ../include \ -I ../src/gen \ $(STRICT_FLAGS) +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) # ---------------------------------------------------- # Targets diff --git a/lib/edoc/test/Makefile b/lib/edoc/test/Makefile index 80906a9456..139ba8b8bd 100644 --- a/lib/edoc/test/Makefile +++ b/lib/edoc/test/Makefile @@ -27,6 +27,7 @@ RELSYSDIR = $(RELEASE_PATH)/edoc_test ERL_MAKE_FLAGS += ERL_COMPILE_FLAGS += +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/eldap/test/Makefile b/lib/eldap/test/Makefile index ba8fe0dfa9..61cad55c64 100644 --- a/lib/eldap/test/Makefile +++ b/lib/eldap/test/Makefile @@ -54,6 +54,7 @@ RELSYSDIR = $(RELEASE_PATH)/eldap_test # FLAGS # ---------------------------------------------------- ERL_COMPILE_FLAGS += $(INCLUDES) -pa $(ERL_TOP)/lib/eldap/ebin +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/erl_docgen/test/Makefile b/lib/erl_docgen/test/Makefile index fe45b2a684..9af7824553 100644 --- a/lib/erl_docgen/test/Makefile +++ b/lib/erl_docgen/test/Makefile @@ -26,6 +26,7 @@ RELSYSDIR = $(RELEASE_PATH)/erl_docgen_test ERL_MAKE_FLAGS += ERL_COMPILE_FLAGS += +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/eunit/test/Makefile b/lib/eunit/test/Makefile index e2fbdf7241..1bd9c0a07c 100644 --- a/lib/eunit/test/Makefile +++ b/lib/eunit/test/Makefile @@ -45,6 +45,7 @@ RELSYSDIR = $(RELEASE_PATH)/eunit_test # ---------------------------------------------------- ERL_MAKE_FLAGS += ERL_COMPILE_FLAGS += +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/ftp/test/Makefile b/lib/ftp/test/Makefile index 71ddb3bc7c..4686d8f1bd 100644 --- a/lib/ftp/test/Makefile +++ b/lib/ftp/test/Makefile @@ -152,6 +152,7 @@ RELTESTSYSBINDIR = $(RELTESTSYSALLDATADIR)/bin ERL_COMPILE_FLAGS += \ $(INCLUDES) \ $(FTP_FLAGS) +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) # ---------------------------------------------------- # Targets diff --git a/lib/inets/test/Makefile b/lib/inets/test/Makefile index 16a1abaee7..414884a535 100644 --- a/lib/inets/test/Makefile +++ b/lib/inets/test/Makefile @@ -200,6 +200,7 @@ RELTESTSYSBINDIR = $(RELTESTSYSALLDATADIR)/bin ERL_COMPILE_FLAGS += \ $(INCLUDES) \ $(INETS_FLAGS) +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) # ---------------------------------------------------- # Targets diff --git a/lib/kernel/test/Makefile b/lib/kernel/test/Makefile index 12e6c42f7c..130e626b56 100644 --- a/lib/kernel/test/Makefile +++ b/lib/kernel/test/Makefile @@ -159,6 +159,7 @@ RELSYSDIR = $(RELEASE_PATH)/kernel_test ERL_MAKE_FLAGS += ERL_COMPILE_FLAGS += +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/megaco/Makefile b/lib/megaco/Makefile index 5dc2955dd8..a1b7adc924 100644 --- a/lib/megaco/Makefile +++ b/lib/megaco/Makefile @@ -98,7 +98,13 @@ else FLEX_SCANNER_REENTRANT_ENABLER = --enable-megaco-reentrant-flex-scanner endif -CONFIGURE_OPTS = $(FLEX_SCANNER_LINENO_ENABLER) $(FLEX_SCANNER_REENTRANT_ENABLER) +ifeq ($(ERL_DETERMINISTIC),yes) + ERL_DETERMINISTIC_ENABLER = --enable-deterministic-build +else + ERL_DETERMINISTIC_ENABLER = --disable-deterministic-build +endif + +CONFIGURE_OPTS = $(FLEX_SCANNER_LINENO_ENABLER) $(FLEX_SCANNER_REENTRANT_ENABLER) $(ERL_DETERMINISTIC_ENABLER) DIA_PLT = ./priv/plt/$(APPLICATION).plt @@ -115,7 +121,7 @@ include $(ERL_TOP)/make/otp_subdir.mk reconf: (cd $(ERL_TOP) && \ - ./otp_build configure && \ + ./otp_build configure $(ERL_DETERMINISTIC_ENABLER) && \ cd $(ERL_TOP)/../libraries/megaco) conf: do_configure diff --git a/lib/megaco/src/app/megaco.mk b/lib/megaco/src/app/megaco.mk index a887dd42bc..d42fd0d7ed 100644 --- a/lib/megaco/src/app/megaco.mk +++ b/lib/megaco/src/app/megaco.mk @@ -42,6 +42,12 @@ ifeq ($(WARN_UNUSED_WARS), true) ERL_COMPILE_FLAGS += +warn_unused_vars endif +ifeq ($(ERL_DETERMINISTIC),yes) +ERL_COMPILE_FLAGS += +deterministic +YRL_FLAGS += +deterministic +XRL_FLAGS += +deterministic +endif + MEGACO_APP_VSN_COMPILE_FLAGS = \ +'{parse_transform,sys_pre_attributes}' \ +'{attribute,insert,app_vsn,$(APP_VSN)}' diff --git a/lib/megaco/src/binary/depend.mk b/lib/megaco/src/binary/depend.mk index ca2872975c..d430d157c0 100644 --- a/lib/megaco/src/binary/depend.mk +++ b/lib/megaco/src/binary/depend.mk @@ -35,6 +35,10 @@ ifeq ($(MEGACO_INLINE_ASN1_RT),true) ASN1_CT_OPTS += +inline endif +ifeq ($(ERL_DETERMINISTIC),yes) +ASN1_CT_OPTS += +deterministic +endif + BER_V1_FLAGS = $(ASN1_CT_OPTS) +asn1config BER_V2_FLAGS = $(ASN1_CT_OPTS) +asn1config BER_V3_FLAGS = $(ASN1_CT_OPTS) +asn1config diff --git a/lib/megaco/test/Makefile b/lib/megaco/test/Makefile index 57437e50a6..eced232a47 100644 --- a/lib/megaco/test/Makefile +++ b/lib/megaco/test/Makefile @@ -90,6 +90,8 @@ ERL_COMPILE_FLAGS += $(MEGACO_ERL_COMPILE_FLAGS) # We have a behaviour in the test catalog (megaco_test_generator) ERL_COMPILE_FLAGS += -pa ../../megaco/test +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) + ERL_PATH = -pa ../../megaco/examples/simple \ -pa ../../megaco/ebin \ -pa ../../et/ebin diff --git a/lib/mnesia/test/Makefile b/lib/mnesia/test/Makefile index 378bcc44d0..c3fbad88ca 100644 --- a/lib/mnesia/test/Makefile +++ b/lib/mnesia/test/Makefile @@ -91,6 +91,7 @@ RELSYSDIR = $(RELEASE_PATH)/mnesia_test # FLAGS # ---------------------------------------------------- #ERL_COMPILE_FLAGS += +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/observer/test/Makefile b/lib/observer/test/Makefile index 8c7ca2fcfc..114f77400f 100644 --- a/lib/observer/test/Makefile +++ b/lib/observer/test/Makefile @@ -52,6 +52,7 @@ RELSYSDIR = $(RELEASE_PATH)/observer_test # ---------------------------------------------------- ERL_MAKE_FLAGS += ERL_COMPILE_FLAGS += +warnings_as_errors +nowarn_export_all +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/odbc/test/Makefile b/lib/odbc/test/Makefile index 87caa54c61..ab184ac06b 100644 --- a/lib/odbc/test/Makefile +++ b/lib/odbc/test/Makefile @@ -72,6 +72,8 @@ RELSYSDIR = $(RELEASE_PATH)/odbc_test ERL_COMPILE_FLAGS += $(INCLUDES) \ +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) + # ---------------------------------------------------- # Targets # ---------------------------------------------------- diff --git a/lib/os_mon/test/Makefile b/lib/os_mon/test/Makefile index d8dc4e57c7..df7b606c06 100644 --- a/lib/os_mon/test/Makefile +++ b/lib/os_mon/test/Makefile @@ -55,6 +55,7 @@ RELSYSDIR = $(RELEASE_PATH)/os_mon_test # ---------------------------------------------------- ERL_MAKE_FLAGS += ERL_COMPILE_FLAGS += -I$(ERL_TOP)/lib/snmp/include +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) # ---------------------------------------------------- # Targets diff --git a/lib/parsetools/test/Makefile b/lib/parsetools/test/Makefile index d494953f1e..23cb9709e1 100644 --- a/lib/parsetools/test/Makefile +++ b/lib/parsetools/test/Makefile @@ -42,6 +42,7 @@ RELSYSDIR = $(RELEASE_PATH)/parsetools_test # ---------------------------------------------------- ERL_MAKE_FLAGS += ERL_COMPILE_FLAGS += +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/parsetools/test/leex_SUITE.erl b/lib/parsetools/test/leex_SUITE.erl index 2d73b58e3c..bef048dc82 100644 --- a/lib/parsetools/test/leex_SUITE.erl +++ b/lib/parsetools/test/leex_SUITE.erl @@ -388,12 +388,14 @@ deterministic(Config) when is_list(Config) -> %% deterministic mode, that include should only use the basename, %% "leexinc.hrl", but otherwise, it should contain the full path. - AbsolutePathSuffix = "/lib/parsetools/include/leexinc.hrl", + %% Matches when OTP is not installed (e.g. /lib/parsetools/include/leexinc.hrl) + %% and when it is (e.g. /lib/parsetools-2.3.2/include/leexinc.hrl) + AbsolutePathSuffix = ".*/lib/parsetools.*/include/leexinc\.hrl", ok = leex:compile(Filename, Scannerfile, #options{specific=[deterministic]}), {ok, FormsDet} = epp:parse_file(Scannerfile,[]), ?assertMatch(false, search_for_file_attr(AbsolutePathSuffix, FormsDet)), - ?assertMatch({value, _}, search_for_file_attr("leexinc.hrl", FormsDet)), + ?assertMatch({value, _}, search_for_file_attr("leexinc\.hrl", FormsDet)), file:delete(Scannerfile), ok = leex:compile(Filename, Scannerfile, #options{}), @@ -1308,10 +1310,10 @@ extract(File, {error, Es, Ws}) -> extract(File, Ts) -> lists:append([T || {F, T} <- Ts, F =:= File]). -search_for_file_attr(PartialFilePath, Forms) -> +search_for_file_attr(PartialFilePathRegex, Forms) -> lists:search(fun ({attribute, _, file, {FileAttr, _}}) -> - case string:find(FileAttr, PartialFilePath) of + case re:run(FileAttr, PartialFilePathRegex) of nomatch -> false; _ -> true end; diff --git a/lib/parsetools/test/yecc_SUITE.erl b/lib/parsetools/test/yecc_SUITE.erl index 16a6b47ade..e76b98f0f5 100644 --- a/lib/parsetools/test/yecc_SUITE.erl +++ b/lib/parsetools/test/yecc_SUITE.erl @@ -946,12 +946,14 @@ deterministic(Config) when is_list(Config) -> %% only use the basename, "yeccpre.hrl", but otherwise, it should %% contain the full path. - AbsolutePathSuffix = "/lib/parsetools/include/yeccpre.hrl", + %% Matches when OTP is not installed (e.g. /lib/parsetools/include/yeccpre.hrl) + %% and when it is (e.g. /lib/parsetools-2.3.2/include/yeccpre.hrl) + AbsolutePathSuffix = "/lib/parsetools.*/include/yeccpre\.hrl", ok = yecc:compile(Filename, Parserfile, #options{specific=[deterministic]}), {ok, FormsDet} = epp:parse_file(Parserfile,[]), ?assertMatch(false, search_for_file_attr(AbsolutePathSuffix, FormsDet)), - ?assertMatch({value, _}, search_for_file_attr("yeccpre.hrl", FormsDet)), + ?assertMatch({value, _}, search_for_file_attr("yeccpre\.hrl", FormsDet)), file:delete(Parserfile), ok = yecc:compile(Filename, Parserfile, #options{}), @@ -2321,10 +2323,10 @@ process_list() -> safe_second_element({_,Info}) -> Info; safe_second_element(Other) -> Other. -search_for_file_attr(PartialFilePath, Forms) -> +search_for_file_attr(PartialFilePathRegex, Forms) -> lists:search(fun ({attribute, _, file, {FileAttr, _}}) -> - case string:find(FileAttr, PartialFilePath) of + case re:run(FileAttr, PartialFilePathRegex) of nomatch -> false; _ -> true end; diff --git a/lib/public_key/asn1/Makefile b/lib/public_key/asn1/Makefile index d33e13fb14..c1adf58ed4 100644 --- a/lib/public_key/asn1/Makefile +++ b/lib/public_key/asn1/Makefile @@ -70,6 +70,10 @@ ERL_COMPILE_FLAGS += $(EXTRA_ERLC_FLAGS) ASN_FLAGS = -bber +der +noobj +asn1config +ifeq ($(ERL_DETERMINISTIC),yes) + ASN_FLAGS += +deterministic +endif + # ---------------------------------------------------- # Targets # ---------------------------------------------------- diff --git a/lib/public_key/test/Makefile b/lib/public_key/test/Makefile index 6c39c534d2..aa42cf281f 100644 --- a/lib/public_key/test/Makefile +++ b/lib/public_key/test/Makefile @@ -55,6 +55,7 @@ RELSYSDIR = $(RELEASE_PATH)/public_key_test # FLAGS # ---------------------------------------------------- ERL_COMPILE_FLAGS += $(INCLUDES) +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/reltool/test/Makefile b/lib/reltool/test/Makefile index 789019cf7d..245c9c9f00 100644 --- a/lib/reltool/test/Makefile +++ b/lib/reltool/test/Makefile @@ -51,6 +51,7 @@ RELSYSDIR = $(RELEASE_PATH)/reltool_test # FLAGS # ---------------------------------------------------- ERL_COMPILE_FLAGS += -pa $(ERL_TOP)/lib/reltool/ebin/ +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/runtime_tools/test/Makefile b/lib/runtime_tools/test/Makefile index f899d53f7f..c9578d376e 100644 --- a/lib/runtime_tools/test/Makefile +++ b/lib/runtime_tools/test/Makefile @@ -31,6 +31,7 @@ RELSYSDIR = $(RELEASE_PATH)/runtime_tools_test ERL_MAKE_FLAGS += ERL_COMPILE_FLAGS += -Werror +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/sasl/test/Makefile b/lib/sasl/test/Makefile index 11c2a9e69f..adc5a927ac 100644 --- a/lib/sasl/test/Makefile +++ b/lib/sasl/test/Makefile @@ -58,6 +58,7 @@ RELSYSDIR = $(RELEASE_PATH)/sasl_test # ---------------------------------------------------- ERL_MAKE_FLAGS += ERL_COMPILE_FLAGS += -I$(ERL_TOP)/lib/sasl/src +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/snmp/src/compile/Makefile b/lib/snmp/src/compile/Makefile index d37eaf9636..f255237a04 100644 --- a/lib/snmp/src/compile/Makefile +++ b/lib/snmp/src/compile/Makefile @@ -85,6 +85,10 @@ ERL_COMPILE_FLAGS += -I../../include \ YRL_FLAGS = -o . +ifeq ($(ERL_DETERMINISTIC),yes) + YRL_FLAGS += +deterministic +endif + # ---------------------------------------------------- # Targets diff --git a/lib/snmp/test/Makefile b/lib/snmp/test/Makefile index ac25a0d0b3..8de1b1e80d 100644 --- a/lib/snmp/test/Makefile +++ b/lib/snmp/test/Makefile @@ -161,6 +161,7 @@ ERL_COMPILE_FLAGS += -I../../snmp/src/app \ +'{parse_transform,sys_pre_attributes}' \ +'{attribute,insert,app_vsn,$(APP_VSN)}' \ $(SNMP_FLAGS) +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) ERL_SNMP_FLAGS = $(SNMP_MIB_FLAGS) \ -I../priv/mibs diff --git a/lib/ssh/test/Makefile b/lib/ssh/test/Makefile index e07806f488..908312f8de 100644 --- a/lib/ssh/test/Makefile +++ b/lib/ssh/test/Makefile @@ -98,6 +98,7 @@ RELSYSDIR = $(RELEASE_PATH)/ssh_test INCLUDES = -I$(ERL_TOP)/lib/ssh/src ERL_COMPILE_FLAGS += $(INCLUDES) -pa ../ebin +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/ssl/test/Makefile b/lib/ssl/test/Makefile index 9272ab0988..47ba9adfbd 100644 --- a/lib/ssl/test/Makefile +++ b/lib/ssl/test/Makefile @@ -143,6 +143,7 @@ RELSYSDIR = $(RELEASE_PATH)/ssl_test # running the target "targets". # ---------------------------------------------------- ERL_COMPILE_FLAGS += $(INCLUDES) +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) # ---------------------------------------------------- # Targets diff --git a/lib/stdlib/src/Makefile b/lib/stdlib/src/Makefile index b7b5ead962..47625c0011 100644 --- a/lib/stdlib/src/Makefile +++ b/lib/stdlib/src/Makefile @@ -166,6 +166,12 @@ endif ERL_COMPILE_FLAGS += -Werror ERL_COMPILE_FLAGS += -I../include -I../../kernel/include +ifeq ($(ERL_DETERMINISTIC),yes) + DETERMINISM_FLAG = +deterministic +else + DETERMINISM_FLAG = +endif + # ---------------------------------------------------- # Targets # ---------------------------------------------------- @@ -191,16 +197,17 @@ primary_bootstrap_compiler: \ $(BOOTSTRAP_COMPILER)/ebin/io.beam \ $(BOOTSTRAP_COMPILER)/ebin/otp_internal.beam + $(BOOTSTRAP_COMPILER)/ebin/erl_parse.beam: erl_parse.yrl $(gen_verbose) - $(V_at)$(ERLC) -o $(BOOTSTRAP_COMPILER)/egen erl_parse.yrl - $(V_at)$(ERLC) -o $(BOOTSTRAP_COMPILER)/ebin $(BOOTSTRAP_COMPILER)/egen/erl_parse.erl + $(V_at)$(ERLC) -o $(BOOTSTRAP_COMPILER)/egen $(DETERMINISM_FLAG) erl_parse.yrl + $(V_at)$(ERLC) -o $(BOOTSTRAP_COMPILER)/ebin $(DETERMINISM_FLAG) $(BOOTSTRAP_COMPILER)/egen/erl_parse.erl $(BOOTSTRAP_TOP)/lib/stdlib/egen/erl_parse.erl: erl_parse.yrl $(yecc_verbose)$(ERLC) $(YRL_FLAGS) -o$(BOOTSTRAP_TOP)/lib/stdlib/egen erl_parse.yrl $(BOOTSTRAP_COMPILER)/ebin/%.beam: %.erl - $(V_ERLC) -o $(BOOTSTRAP_COMPILER)/ebin $< + $(V_ERLC) -o $(BOOTSTRAP_COMPILER)/ebin $(DETERMINISM_FLAG) $< # ---------------------------------------------------- # Special Build Targets diff --git a/lib/stdlib/test/Makefile b/lib/stdlib/test/Makefile index 18d3a083a3..3ebaefac4e 100644 --- a/lib/stdlib/test/Makefile +++ b/lib/stdlib/test/Makefile @@ -120,6 +120,7 @@ RELSYSDIR = $(RELEASE_PATH)/stdlib_test ERL_COMPILE_FLAGS += -I$(ERL_TOP)/lib/kernel/include \ -I$(ERL_TOP)/lib/stdlib/include +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/syntax_tools/test/Makefile b/lib/syntax_tools/test/Makefile index 51fe2417b1..deee5ab814 100644 --- a/lib/syntax_tools/test/Makefile +++ b/lib/syntax_tools/test/Makefile @@ -27,6 +27,7 @@ RELSYSDIR = $(RELEASE_PATH)/syntax_tools_test ERL_MAKE_FLAGS += ERL_COMPILE_FLAGS += +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/tftp/test/Makefile b/lib/tftp/test/Makefile index 3eb0886f66..a3caf45321 100644 --- a/lib/tftp/test/Makefile +++ b/lib/tftp/test/Makefile @@ -152,6 +152,7 @@ RELTESTSYSBINDIR = $(RELTESTSYSALLDATADIR)/bin ERL_COMPILE_FLAGS += \ $(INCLUDES) \ $(TFTP_FLAGS) +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) # ---------------------------------------------------- # Targets diff --git a/lib/tools/test/Makefile b/lib/tools/test/Makefile index 571fdd07e9..984568e4c5 100644 --- a/lib/tools/test/Makefile +++ b/lib/tools/test/Makefile @@ -54,6 +54,7 @@ RELSYSDIR = $(RELEASE_PATH)/tools_test # ---------------------------------------------------- ERL_MAKE_FLAGS += ERL_COMPILE_FLAGS += +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) EBIN = . diff --git a/lib/xmerl/src/Makefile b/lib/xmerl/src/Makefile index 0a9f8391c7..e7e7c8e978 100644 --- a/lib/xmerl/src/Makefile +++ b/lib/xmerl/src/Makefile @@ -127,6 +127,11 @@ ERL_COMPILE_FLAGS += \ # +bin_opt_info +ifeq ($(ERL_DETERMINISTIC),yes) + DETERMINISM_FLAG = +deterministic +else + DETERMINISM_FLAG = +endif # ---------------------------------------------------- # Targets @@ -173,10 +178,10 @@ $(APPUP_TARGET): $(APPUP_SRC) ../vsn.mk $(vsn_verbose)sed -e 's;%VSN%;$(VSN);' $< > $@ xmerl_xpath_parse.erl: xmerl_xpath_parse.yrl - $(yecc_verbose)$(ERLC) -o $(ESRC) $< + $(yecc_verbose)$(ERLC) -o $(ESRC) $(DETERMINISM_FLAG) $< xmerl_b64Bin.erl: xmerl_b64Bin.yrl - $(yecc_verbose)$(ERLC) -o $(ESRC) $< + $(yecc_verbose)$(ERLC) -o $(ESRC) $(DETERMINISM_FLAG) $< xmerl_sax_parser_list.erl: xmerl_sax_parser_list.erlsrc xmerl_sax_parser_base.erlsrc $(gen_verbose)cat xmerl_sax_parser_list.erlsrc xmerl_sax_parser_base.erlsrc >$@ diff --git a/lib/xmerl/test/Makefile b/lib/xmerl/test/Makefile index 49091a9a54..97180d8051 100644 --- a/lib/xmerl/test/Makefile +++ b/lib/xmerl/test/Makefile @@ -86,6 +86,7 @@ RELSYSDIR = $(RELEASE_PATH)/xmerl_test # ---------------------------------------------------- ERL_COMPILE_FLAGS += +ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS)) # ---------------------------------------------------- diff --git a/make/otp.mk.in b/make/otp.mk.in index 7ec4aea91a..61654ad5cb 100644 --- a/make/otp.mk.in +++ b/make/otp.mk.in @@ -92,6 +92,8 @@ BITS64 = @BITS64@ OTP_RELEASE = @OTP_RELEASE@ +ERL_DETERMINISTIC = @ERL_DETERMINISTIC@ + # ---------------------------------------------------- # Erlang language section # ---------------------------------------------------- @@ -104,6 +106,11 @@ ifdef BOOTSTRAP else ERL_COMPILE_FLAGS += +debug_info endif +ifeq ($(ERL_DETERMINISTIC),yes) + ERL_COMPILE_FLAGS += +deterministic + YRL_FLAGS += +deterministic + XRL_FLAGS += +deterministic +endif ifeq ($(USE_ESOCK),yes) ERL_COMPILE_FLAGS += -DUSE_ESOCK=true endif -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor