0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.0910: Vim is not reproducibly buildable

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.
This commit is contained in:
Bram Moolenaar
2020-06-05 23:16:29 +02:00
parent 002bc79991
commit 8f1dde5021
6 changed files with 44 additions and 0 deletions

View File

@@ -2130,6 +2130,7 @@ CCC = $(CCC_NF) $(ALL_CFLAGS)
# A shell script is used to try linking without unnecessary libraries. # A shell script is used to try linking without unnecessary libraries.
$(VIMTARGET): auto/config.mk objects $(OBJ) version.c version.h $(VIMTARGET): auto/config.mk objects $(OBJ) version.c version.h
$(CCC) version.c -o objects/version.o $(CCC) version.c -o objects/version.o
@$(BUILD_DATE_MSG)
@LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \ @LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
-o $(VIMTARGET) $(OBJ) $(ALL_LIBS)" \ -o $(VIMTARGET) $(OBJ) $(ALL_LIBS)" \
MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \ MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \

12
src/auto/configure vendored
View File

@@ -721,6 +721,7 @@ OS_EXTRA_SRC
XCODE_SELECT XCODE_SELECT
CPP_MM CPP_MM
CROSS_COMPILING CROSS_COMPILING
BUILD_DATE_MSG
STRIP STRIP
AWK AWK
FGREP FGREP
@@ -4455,6 +4456,17 @@ See \`config.log' for more details" "$LINENO" 5; }
fi fi
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 "$as_me:${as_lineno-$LINENO}: checking --enable-fail-if-missing argument" >&5
$as_echo_n "checking --enable-fail-if-missing argument... " >&6; } $as_echo_n "checking --enable-fail-if-missing argument... " >&6; }

View File

@@ -30,6 +30,9 @@
/* Define when __DATE__ " " __TIME__ can be used */ /* Define when __DATE__ " " __TIME__ can be used */
#undef HAVE_DATE_TIME #undef HAVE_DATE_TIME
/* Defined from $SOURCE_DATE_EPOCH, used as the build date */
#undef BUILD_DATE
/* Define when __attribute__((unused)) can be used */ /* Define when __attribute__((unused)) can be used */
#undef HAVE_ATTRIBUTE_UNUSED #undef HAVE_ATTRIBUTE_UNUSED

View File

@@ -169,6 +169,10 @@ MAKEMO = @MAKEMO@
MSGFMT = @MSGFMT@ MSGFMT = @MSGFMT@
MSGFMT_DESKTOP = @MSGFMT_DESKTOP@ 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 # 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. # work. This is needed when using the Makefile in the top directory.
first: all first: all

View File

@@ -62,6 +62,18 @@ if test x"$ac_cv_prog_cc_c99" != xno; then
fi fi
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. dnl Check for the flag that fails if stuff are missing.
AC_MSG_CHECKING(--enable-fail-if-missing argument) AC_MSG_CHECKING(--enable-fail-if-missing argument)

View File

@@ -44,9 +44,13 @@ init_longVersion(void)
* VAX C can't concatenate strings in the preprocessor. * VAX C can't concatenate strings in the preprocessor.
*/ */
strcpy(longVersion, VIM_VERSION_LONG_DATE); strcpy(longVersion, VIM_VERSION_LONG_DATE);
#ifdef BUILD_DATE
strcat(longVersion, BUILD_DATE);
#else
strcat(longVersion, __DATE__); strcat(longVersion, __DATE__);
strcat(longVersion, " "); strcat(longVersion, " ");
strcat(longVersion, __TIME__); strcat(longVersion, __TIME__);
#endif
strcat(longVersion, ")"); strcat(longVersion, ")");
} }
@@ -56,7 +60,15 @@ init_longVersion(void)
{ {
if (longVersion == NULL) 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__; char *date_time = __DATE__ " " __TIME__;
#endif
#endif
char *msg = _("%s (%s, compiled %s)"); char *msg = _("%s (%s, compiled %s)");
size_t len = strlen(msg) size_t len = strlen(msg)
+ strlen(VIM_VERSION_LONG_ONLY) + strlen(VIM_VERSION_LONG_ONLY)