From fa3211a7a671b1d411c39c02b805b38f06a9e593 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 26 Oct 2020 10:53:22 -0700 Subject: [PATCH 1/4] opal_functions.m4: remove redundant code This code was invoked twice. Leave it solely in OPAL_CONFIGURE_SETUP, which is invoked before OPAL_BASIC_SETUP. Signed-off-by: Jeff Squyres (cherry picked from commit 7c36b458473f7eca7e3da88ac1d6f0937396fb1e) --- config/opal_functions.m4 | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/config/opal_functions.m4 b/config/opal_functions.m4 index 7a85dbf8766..b398edfa20c 100644 --- a/config/opal_functions.m4 +++ b/config/opal_functions.m4 @@ -12,7 +12,7 @@ dnl Copyright (c) 2004-2005 The Regents of the University of California. dnl All rights reserved. dnl Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. dnl Copyright (c) 2009 Oak Ridge National Labs. All rights reserved. -dnl Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved. +dnl Copyright (c) 2009-2020 Cisco Systems, Inc. All rights reserved. dnl Copyright (c) 2014 Intel, Inc. All rights reserved. dnl Copyright (c) 2015-2017 Research Organization for Information Science dnl and Technology (RIST). All rights reserved. @@ -112,14 +112,6 @@ dnl ####################################################################### dnl ####################################################################### AC_DEFUN([OPAL_BASIC_SETUP],[ -# -# Save some stats about this build -# - -OPAL_CONFIGURE_USER="`whoami`" -OPAL_CONFIGURE_HOST="`(hostname || uname -n) 2> /dev/null | sed 1q`" -OPAL_CONFIGURE_DATE="`date`" - # # Make automake clean emacs ~ files for "make clean" # From 35e7d86eb10198ba56acf9aa237df556c0db5f15 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Wed, 28 Jun 2017 13:36:27 +0900 Subject: [PATCH 2/4] configury: make build Reproducible If defined, use SOURCE_DATE_EPOCH environment variable; make the build Reproducible by forcing timestamps. See https://reproducible-builds.org/docs/source-date-epoch/ for more information. Thanks Bernhard M. Wiedemann for bringing this to our attention. Fixes open-mpi/ompi#3759 **NOTE:** This was cherry-picked from master, and slightly modified / amended for the v4.1.x branch. Signed-off-by: Gilles Gouaillardet Signed-off-by: Bernhard M. Wiedemann Signed-off-by: Jeff Squyres (cherry picked from commit 7b4e8ba4aa41831fa3c5221ed4c7d71e979d2df2) --- README | 13 +++++++++++++ autogen.pl | 2 +- config/getdate.sh | 10 ++++++++++ config/opal_functions.m4 | 6 +++--- config/opal_get_version.m4 | 4 ++-- ompi/tools/mpisync/Makefile.am | 4 ++-- ompi/tools/ompi_info/Makefile.am | 4 ++-- orte/tools/orte-info/Makefile.am | 4 ++-- oshmem/tools/oshmem_info/Makefile.am | 4 ++-- 9 files changed, 37 insertions(+), 14 deletions(-) create mode 100755 config/getdate.sh diff --git a/README b/README index 7943be07080..e438ae6b06b 100644 --- a/README +++ b/README @@ -168,6 +168,19 @@ General notes using the clang-4.0 system compiler. A workaround is to build Open MPI using the GNU compiler. +- Open MPI has taken some steps towards Reproducible Builds + (https://reproducible-builds.org/). Specifically, Open MPI's + "configure" and "make" process, by default, records the build date + and some system-specific information such as the hostname where Open + MPI was built and the username who built it. If you desire a + Reproducible Build, set the $SOURCE_DATE_EPOCH, $USER and $HOSTNAME + environment variables before invoking "configure" and "make", and + Open MPI will use those values instead of invoking "whoami" and/or + "hostname", respectively. See + https://reproducible-builds.org/docs/source-date-epoch/ for + information on the expected format and content of the + $SOURCE_DATE_EPOCH variable. + Platform Notes -------------- diff --git a/autogen.pl b/autogen.pl index 924c4c6d68f..de4b3c17f97 100755 --- a/autogen.pl +++ b/autogen.pl @@ -1200,7 +1200,7 @@ sub in_tarball { dnl This file is automatically created by autogen.pl; it should not dnl be edited by hand!! dnl -dnl Generated by $username at " . localtime(time) . " +dnl Generated by $username at " . localtime($ENV{SOURCE_DATE_EPOCH} || time) . " dnl on $full_hostname. $dnl_line\n\n"; diff --git a/config/getdate.sh b/config/getdate.sh new file mode 100755 index 00000000000..94824d97e43 --- /dev/null +++ b/config/getdate.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# +# Copyright (c) 2017 Research Organization for Information Science +# and Technology (RIST). All rights reserved. +# Copyright (c) 2020 Cisco Systems, Inc. All rights reserved. + +# Provide a way to override build date for reproducible build results +# See https://reproducible-builds.org/ for why this is good. + +date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" "$@" diff --git a/config/opal_functions.m4 b/config/opal_functions.m4 index b398edfa20c..e531b9a8657 100644 --- a/config/opal_functions.m4 +++ b/config/opal_functions.m4 @@ -94,9 +94,9 @@ EOF # Save some stats about this build # -OPAL_CONFIGURE_USER="`whoami`" -OPAL_CONFIGURE_HOST="`(hostname || uname -n) 2> /dev/null | sed 1q`" -OPAL_CONFIGURE_DATE="`date`" +OPAL_CONFIGURE_USER="${USER:-`whoami`}" +OPAL_CONFIGURE_HOST="${HOSTNAME:-`(hostname || uname -n) 2> /dev/null | sed 1q`}" +OPAL_CONFIGURE_DATE="`$srcdir/config/getdate.sh`" OPAL_LIBNL_SANITY_INIT diff --git a/config/opal_get_version.m4 b/config/opal_get_version.m4 index 7df2b5563b5..69537994b7c 100644 --- a/config/opal_get_version.m4 +++ b/config/opal_get_version.m4 @@ -10,7 +10,7 @@ dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, dnl University of Stuttgart. All rights reserved. dnl Copyright (c) 2004-2005 The Regents of the University of California. dnl All rights reserved. -dnl Copyright (c) 2008-2014 Cisco Systems, Inc. All rights reserved. +dnl Copyright (c) 2008-2020 Cisco Systems, Inc. All rights reserved. dnl Copyright (c) 2014 Intel, Inc. All rights reserved. dnl Copyright (c) 2014 Research Organization for Information Science dnl and Technology (RIST). All rights reserved. @@ -91,7 +91,7 @@ m4_define([OPAL_GET_VERSION],[ $2_REPO_REV=`git describe --tags --always` fi else - $2_REPO_REV="date`date '+%Y-%m-%d'`" + $2_REPO_REV=date`$srcdir/getdate.sh '+%Y-%m-%d'` fi fi diff --git a/ompi/tools/mpisync/Makefile.am b/ompi/tools/mpisync/Makefile.am index 3514afcc59f..e4e85b6f930 100644 --- a/ompi/tools/mpisync/Makefile.am +++ b/ompi/tools/mpisync/Makefile.am @@ -32,8 +32,8 @@ AM_CFLAGS = \ -DOPAL_CONFIGURE_HOST="\"@OPAL_CONFIGURE_HOST@\"" \ -DOPAL_CONFIGURE_DATE="\"@OPAL_CONFIGURE_DATE@\"" \ -DOMPI_BUILD_USER="\"$$USER\"" \ - -DOMPI_BUILD_HOST="\"`(hostname || uname -n) | sed 1q`\"" \ - -DOMPI_BUILD_DATE="\"`date`\"" \ + -DOMPI_BUILD_HOST="\"`$${HOSTNAME:-(hostname || uname -n) | sed 1q`\"" \ + -DOMPI_BUILD_DATE="\"`$(top_srcdir)/config/getdate.sh`\"" \ -DOMPI_BUILD_CFLAGS="\"@CFLAGS@\"" \ -DOMPI_BUILD_CPPFLAGS="\"@CPPFLAGS@\"" \ -DOMPI_BUILD_CXXFLAGS="\"@CXXFLAGS@\"" \ diff --git a/ompi/tools/ompi_info/Makefile.am b/ompi/tools/ompi_info/Makefile.am index 296d8ba283a..9875701a6ea 100644 --- a/ompi/tools/ompi_info/Makefile.am +++ b/ompi/tools/ompi_info/Makefile.am @@ -28,8 +28,8 @@ AM_CFLAGS = \ -DOPAL_CONFIGURE_HOST="\"@OPAL_CONFIGURE_HOST@\"" \ -DOPAL_CONFIGURE_DATE="\"@OPAL_CONFIGURE_DATE@\"" \ -DOMPI_BUILD_USER="\"$$USER\"" \ - -DOMPI_BUILD_HOST="\"`(hostname || uname -n) 2> /dev/null | sed 1q`\"" \ - -DOMPI_BUILD_DATE="\"`date`\"" \ + -DOMPI_BUILD_HOST="\"$${HOSTNAME:-`(hostname || uname -n) 2> /dev/null | sed 1q`}\"" \ + -DOMPI_BUILD_DATE="\"`$(top_srcdir)/config/getdate.sh`\"" \ -DOMPI_BUILD_CFLAGS="\"@CFLAGS@\"" \ -DOMPI_BUILD_CPPFLAGS="\"@CPPFLAGS@\"" \ -DOMPI_BUILD_CXXFLAGS="\"@CXXFLAGS@\"" \ diff --git a/orte/tools/orte-info/Makefile.am b/orte/tools/orte-info/Makefile.am index d1e68728401..ac852a27c01 100644 --- a/orte/tools/orte-info/Makefile.am +++ b/orte/tools/orte-info/Makefile.am @@ -25,8 +25,8 @@ AM_CFLAGS = \ -DOPAL_CONFIGURE_HOST="\"@OPAL_CONFIGURE_HOST@\"" \ -DOPAL_CONFIGURE_DATE="\"@OPAL_CONFIGURE_DATE@\"" \ -DOMPI_BUILD_USER="\"$$USER\"" \ - -DOMPI_BUILD_HOST="\"`(hostname || uname -n) | sed 1q`\"" \ - -DOMPI_BUILD_DATE="\"`date`\"" \ + -DOMPI_BUILD_HOST="\"`$${HOSTNAME:-(hostname || uname -n) | sed 1q`\"" \ + -DOMPI_BUILD_DATE="\"`$(top_srcdir)/config/getdate.sh`\"" \ -DOMPI_BUILD_CFLAGS="\"@CFLAGS@\"" \ -DOMPI_BUILD_CPPFLAGS="\"@CPPFLAGS@\"" \ -DOMPI_BUILD_CXXFLAGS="\"@CXXFLAGS@\"" \ diff --git a/oshmem/tools/oshmem_info/Makefile.am b/oshmem/tools/oshmem_info/Makefile.am index a474eaf51d0..4f30236dd2b 100644 --- a/oshmem/tools/oshmem_info/Makefile.am +++ b/oshmem/tools/oshmem_info/Makefile.am @@ -17,8 +17,8 @@ AM_CPPFLAGS = \ -DOPAL_CONFIGURE_HOST="\"@OPAL_CONFIGURE_HOST@\"" \ -DOPAL_CONFIGURE_DATE="\"@OPAL_CONFIGURE_DATE@\"" \ -DOMPI_BUILD_USER="\"$$USER\"" \ - -DOMPI_BUILD_HOST="\"`(hostname || uname -n) 2> /dev/null | sed 1q`\"" \ - -DOMPI_BUILD_DATE="\"`date`\"" \ + -DOMPI_BUILD_HOST="\"$${HOSTNAME:-`(hostname || uname -n) 2> /dev/null | sed 1q`}\"" \ + -DOMPI_BUILD_DATE="\"`$(top_srcdir)/config/getdate.sh`\"" \ -DOMPI_BUILD_CFLAGS="\"@CFLAGS@\"" \ -DOMPI_BUILD_CPPFLAGS="\"@CPPFLAGS@\"" \ -DOMPI_BUILD_CXXFLAGS="\"@CXXFLAGS@\"" \ From 234356a12849be94f97cf2214ef3c980b1ad8db9 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Wed, 28 Oct 2020 22:47:28 -0400 Subject: [PATCH 3/4] configure.ac: Add workaround on MacOS for "readlink -f" MacOS does not have "readlink -f" or "realpath", so use the MacOS-provided Python, which we know has os.path.realpath(). Signed-off-by: Jeff Squyres (cherry picked from commit ddf216b0a31ce34f1195ec0605917602db227958) --- configure.ac | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 40bf904ae0d..cf3e424ffe2 100644 --- a/configure.ac +++ b/configure.ac @@ -125,11 +125,29 @@ AC_DEFUN([OMPI_CHECK_DIR_FOR_SPACES],[ AC_MSG_ERROR([Cannot continue.])]) ]) +AC_DEFUN([OMPI_CANONICALIZE_PATH],[ + case $host_os in + darwin*) + # MacOS does not have "readlink -f" or realpath (at least as + # of MacOS Cataline / 10.15). Instead, use Python, because we + # know MacOS comes with a /usr/bin/python that has + # os.path.realpath. + $2=`/usr/bin/python -c 'import os; print os.path.realpath("'$1'")'` + ;; + *) + $2=`readlink -f $1` + ;; + esac +]) + OMPI_CHECK_DIR_FOR_SPACES([$srcdir], [a], [source tree]) -OMPI_CHECK_DIR_FOR_SPACES([`readlink -f $srcdir`], [an], [absolute source tree]) -OMPI_CHECK_DIR_FOR_SPACES([`readlink -f .`], [a], [build tree]) +OMPI_CANONICALIZE_PATH([$srcdir], [ompi_dir]) +OMPI_CHECK_DIR_FOR_SPACES([$ompi_dir], [an], [absolute source tree]) +OMPI_CANONICALIZE_PATH([.], [ompi_dir]) +OMPI_CHECK_DIR_FOR_SPACES([$ompi_dir], [a], [build tree]) OMPI_CHECK_DIR_FOR_SPACES([$prefix], [a], [prefix]) -OMPI_CHECK_DIR_FOR_SPACES([`readlink -f $prefix`], [an], [absolute prefix]) +OMPI_CANONICALIZE_PATH([$prefix], [ompi_dir]) +OMPI_CHECK_DIR_FOR_SPACES([$ompi_dir], [an], [absolute prefix]) opal_show_subtitle "Checking versions" From e7f829bbb0d5b372cfdfa79ff7ccdb398ce25c84 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Wed, 28 Oct 2020 22:56:13 -0400 Subject: [PATCH 4/4] getdate.sh: make the date(1) usage more portable There are several different flavors of date(1) out there. Try a few different CLI options for date(1) to see which one works. Signed-off-by: Jeff Squyres (cherry picked from commit 89920bac4c6f48efaf1e04245e3f4c5974c6fc99) --- config/getdate.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/getdate.sh b/config/getdate.sh index 94824d97e43..257e953b669 100755 --- a/config/getdate.sh +++ b/config/getdate.sh @@ -7,4 +7,8 @@ # Provide a way to override build date for reproducible build results # See https://reproducible-builds.org/ for why this is good. -date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" "$@" +# There are several different flavors of date(1) out there. +# Try a few different CLI options for date(1) to see which one works. + +SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date +%s)}" +date -u -d "@$SOURCE_DATE_EPOCH" "$@" 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" "$@" 2>/dev/null || date -u "$@"