diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-06-05 23:16:29 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-06-05 23:16:29 +0200 |
commit | 8f1dde5021d9623a951d1ccbc78cf1b1a55ccd7a (patch) | |
tree | 1a2a9aee6f224db95e60a7ba401b2087cdbdb661 | |
parent | 002bc79991286934a9593b80635c27d4238cdfc4 (diff) |
patch 8.2.0910: Vim is not reproducibly buildablev8.2.0910
Problem: Vim is not reproducibly buildable.
Solution: Use the $SOURCE_DATE_EPOCH environment variable in configure.
(James McCoy, closes #513) Give a warning about using it.
-rw-r--r-- | src/Makefile | 1 | ||||
-rwxr-xr-x | src/auto/configure | 12 | ||||
-rw-r--r-- | src/config.h.in | 3 | ||||
-rw-r--r-- | src/config.mk.in | 4 | ||||
-rw-r--r-- | src/configure.ac | 12 | ||||
-rw-r--r-- | src/version.c | 12 |
6 files changed, 44 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile index c12481cc7a..354c13faf7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2130,6 +2130,7 @@ CCC = $(CCC_NF) $(ALL_CFLAGS) # A shell script is used to try linking without unnecessary libraries. $(VIMTARGET): auto/config.mk objects $(OBJ) version.c version.h $(CCC) version.c -o objects/version.o + @$(BUILD_DATE_MSG) @LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \ -o $(VIMTARGET) $(OBJ) $(ALL_LIBS)" \ MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \ diff --git a/src/auto/configure b/src/auto/configure index 516e45ceea..4c3ff325d0 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -721,6 +721,7 @@ OS_EXTRA_SRC XCODE_SELECT CPP_MM CROSS_COMPILING +BUILD_DATE_MSG STRIP AWK FGREP @@ -4455,6 +4456,17 @@ See \`config.log' for more details" "$LINENO" 5; } fi fi +if test -n "$SOURCE_DATE_EPOCH"; then + DATE_FMT="%b %d %Y %H:%M:%S" + BUILD_DATE=$(LC_ALL=C date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u -r "$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u "+$DATE_FMT") + cat >>confdefs.h <<_ACEOF +#define BUILD_DATE "$BUILD_DATE" +_ACEOF + + BUILD_DATE_MSG=-"echo -e '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nNOTE: build date/time is fixed: $BUILD_DATE\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='" + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-fail-if-missing argument" >&5 $as_echo_n "checking --enable-fail-if-missing argument... " >&6; } diff --git a/src/config.h.in b/src/config.h.in index 5c8c7e5561..7055b6f005 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -30,6 +30,9 @@ /* Define when __DATE__ " " __TIME__ can be used */ #undef HAVE_DATE_TIME +/* Defined from $SOURCE_DATE_EPOCH, used as the build date */ +#undef BUILD_DATE + /* Define when __attribute__((unused)) can be used */ #undef HAVE_ATTRIBUTE_UNUSED diff --git a/src/config.mk.in b/src/config.mk.in index 1b5175b9e7..f55bea6f73 100644 --- a/src/config.mk.in +++ b/src/config.mk.in @@ -169,6 +169,10 @@ MAKEMO = @MAKEMO@ MSGFMT = @MSGFMT@ MSGFMT_DESKTOP = @MSGFMT_DESKTOP@ +### set if $SOURCE_DATE_EPOCH was set when running configure +BUILD_DATE_MSG = @BUILD_DATE_MSG@ + + # Make sure that "make first" will run "make all" once configure has done its # work. This is needed when using the Makefile in the top directory. first: all diff --git a/src/configure.ac b/src/configure.ac index 67851802bf..dccf3dce85 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -62,6 +62,18 @@ if test x"$ac_cv_prog_cc_c99" != xno; then fi fi +dnl If $SOURCE_DATE_EPOCH is present in the environment, use that as the +dnl "compiled" timestamp in :version's output. Attempt to get the formatted +dnl date using GNU date syntax, BSD date syntax, and finally falling back to +dnl just using the current time. +if test -n "$SOURCE_DATE_EPOCH"; then + DATE_FMT="%b %d %Y %H:%M:%S" + BUILD_DATE=$(LC_ALL=C date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u -r "$SOURCE_DATE_EPOCH" "+$DATE_FMT" 2>/dev/null || LC_ALL=C date -u "+$DATE_FMT") + AC_DEFINE_UNQUOTED(BUILD_DATE, ["$BUILD_DATE"]) + BUILD_DATE_MSG=-"echo -e '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nNOTE: build date/time is fixed: $BUILD_DATE\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='" + AC_SUBST(BUILD_DATE_MSG) +fi + dnl Check for the flag that fails if stuff are missing. AC_MSG_CHECKING(--enable-fail-if-missing argument) diff --git a/src/version.c b/src/version.c index 5fca34bf29..e761c5dc4a 100644 --- a/src/version.c +++ b/src/version.c @@ -44,9 +44,13 @@ init_longVersion(void) * VAX C can't concatenate strings in the preprocessor. */ strcpy(longVersion, VIM_VERSION_LONG_DATE); +#ifdef BUILD_DATE + strcat(longVersion, BUILD_DATE); +#else strcat(longVersion, __DATE__); strcat(longVersion, " "); strcat(longVersion, __TIME__); +#endif strcat(longVersion, ")"); } @@ -56,7 +60,15 @@ init_longVersion(void) { if (longVersion == NULL) { +#ifdef BUILD_DATE + char *date_time = BUILD_DATE; +#else +#ifdef BUILD_DATE + char *date_time = BUILD_DATE; +#else char *date_time = __DATE__ " " __TIME__; +#endif +#endif char *msg = _("%s (%s, compiled %s)"); size_t len = strlen(msg) + strlen(VIM_VERSION_LONG_ONLY) |