From 044f7bbe11db26fc98580d1f6a84af35b04740b4 Mon Sep 17 00:00:00 2001 From: Cat Stevens Date: Wed, 20 Feb 2019 14:29:32 -0500 Subject: [PATCH] vm/master.hpp: optional reproducible VM compilation The old behaviour of building with `__DATE__` and `__TIME__` is still the default, but now it's possible to use `-DREPRODUCIBLE=1` and the `REPRODUCIBLE=1` parameter to `make` and `nmake`. Specifically, this replaces the value of `FACTOR_COMPILE_TIME` with the string constant `"[reproducible]"`. This is purely a cosmetic change. --- GNUmakefile | 2 ++ Nmakefile | 4 ++++ vm/master.hpp | 9 +++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 53a1f0b8b5..595a6c90ef 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,6 +1,7 @@ ifdef CONFIG VERSION = 0.99 GIT_LABEL = $(shell echo `git describe --all`-`git rev-parse HEAD`) + REPRODUCIBLE ?= 0 BUNDLE = Factor.app @@ -10,6 +11,7 @@ ifdef CONFIG -pedantic \ -DFACTOR_VERSION="$(VERSION)" \ -DFACTOR_GIT_LABEL="$(GIT_LABEL)" \ + -DFACTOR_REPRODUCIBLE="$(REPRODUCIBLE)" \ $(SITE_CFLAGS) CXXFLAGS += -std=c++11 diff --git a/Nmakefile b/Nmakefile index 0b0ce66777..441c7875e1 100644 --- a/Nmakefile +++ b/Nmakefile @@ -65,6 +65,10 @@ LINK_FLAGS = $(LINK_FLAGS) /DEBUG CL_FLAGS = $(CL_FLAGS) /Zi /DFACTOR_DEBUG !ENDIF +!IF DEFINED(REPRODUCIBLE) +CL_FLAGS = $(CL_FLAGS) /DFACTOR_REPRODUCIBLE=1 +!ENDIF + ML_FLAGS = /nologo /safeseh EXE_OBJS = vm\main-windows.obj vm\factor.res diff --git a/vm/master.hpp b/vm/master.hpp index 4c87f74b97..7fd7b18a46 100644 --- a/vm/master.hpp +++ b/vm/master.hpp @@ -52,8 +52,13 @@ #define FACTOR_COMPILER_VERSION "unknown" #endif -// Record compilation time -#define FACTOR_COMPILE_TIME __DATE__ " " __TIME__ +#if (FACTOR_REPRODUCIBLE == 1) + #pragma message "REPRODUCIBLE" + #define FACTOR_COMPILE_TIME "[reproducible]" +#else + // Record compilation time + #define FACTOR_COMPILE_TIME __DATE__ " " __TIME__ +#endif // Detect target CPU type #if defined(__arm__) -- 2.34.1