Do not gather CPU, user and host info about the build host
authorBernhard M. Wiedemann <bwiedemann@suse.de>
Tue, 7 Aug 2018 19:12:40 +0000 (21:12 +0200)
committerErik Lindahl <erik.lindahl@gmail.com>
Sun, 30 Sep 2018 07:13:39 +0000 (09:13 +0200)
as it is rather irrelevant, but makes the build results vary
across hosts (sometimes even with different microcode versions).
See https://reproducible-builds.org/ for why this matters.

Bumped checkpoint version number, as the header information
is now semantically different. All code versions can still
read checkpoints as well as they used to be able to.

Change-Id: Ifec9d03001ba1826f900d092c359bca1d218f7f7

cmake/gmxSetBuildInformation.cmake
src/buildinfo.h.cmakein
src/gromacs/fileio/checkpoint.cpp
src/gromacs/utility/binaryinformation.cpp

index 6d34b444c8d910989adfde5184e3de442ba362bb..4368f02b22428e525a29c17c7e1a5a02375b968b 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+# Copyright (c) 2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -39,9 +39,6 @@
 # configuration, or anonymous/unknown if it cannot be detected
 # (Windows).
 #
-# BUILD_TIME
-# BUILD_USER
-# BUILD_HOST
 # BUILD_CPU_VENDOR
 # BUILD_CPU_BRAND
 # BUILD_CPU_FAMILY
 include(gmxDetectCpu)
 
 function(gmx_set_build_information)
-    if(NOT BUILD_USER)
-        if(CMAKE_HOST_UNIX)
-            execute_process( COMMAND whoami OUTPUT_VARIABLE TMP_USER OUTPUT_STRIP_TRAILING_WHITESPACE)
-            execute_process( COMMAND hostname OUTPUT_VARIABLE TMP_HOSTNAME OUTPUT_STRIP_TRAILING_WHITESPACE)
-        else()
-            set(TMP_USER "Anonymous")
-            set(TMP_HOSTNAME "unknown")
-        endif()
-        set(BUILD_USER "${TMP_USER}\@${TMP_HOSTNAME} [CMAKE]" CACHE INTERNAL "Build user")
-        message(STATUS "Setting build user - ${BUILD_USER}")
-    endif()
-
-    if(NOT BUILD_TIME)
-        STRING(TIMESTAMP TMP_TIME "%Y-%m-%d %H:%M:%S" UTC)
-        set(BUILD_TIME "${TMP_TIME}" CACHE INTERNAL "Build date & time")
-        message(STATUS "Setting build time - ${BUILD_TIME}")
-    endif()
-
-    if(NOT BUILD_HOST)
-        if(CMAKE_HOST_UNIX)
-            execute_process( COMMAND uname -srm OUTPUT_VARIABLE TMP_HOST OUTPUT_STRIP_TRAILING_WHITESPACE)
-        else()
-            set(TMP_HOST "${CMAKE_HOST_SYSTEM} ${CMAKE_HOST_SYSTEM_PROCESSOR}")
-        endif()
-        set(BUILD_HOST "${TMP_HOST}" CACHE INTERNAL "Build host & architecture")
-        message(STATUS "Setting build host - ${BUILD_HOST}")
-    endif()
-
     # Set up some defaults that will usually be overwritten
     if(CMAKE_CROSSCOMPILING)
         set(_reason ", cross-compiled")
index 2d2cc7cb9a7233c53dd01bd472e94e3ed2a3f188..c58bb6ded9797fd7d3283140a464e653867b1cc6 100644 (file)
  * Used for log and version output.
  */
 
-/** Hardware and OS version for build host */
-#define BUILD_HOST              "@BUILD_HOST@"
-
-/** Date and time for build */
-#define BUILD_TIME              "@BUILD_TIME@"
-
-/** User doing build */
-#define BUILD_USER              "@BUILD_USER@"
-
-/** CPU vendor for build host */
-#define BUILD_CPU_VENDOR        "@BUILD_CPU_VENDOR@"
-
-/** CPU brand for build host */
-#define BUILD_CPU_BRAND         "@BUILD_CPU_BRAND@"
-
-/** CPU family for build host */
-#define BUILD_CPU_FAMILY        @BUILD_CPU_FAMILY@
-
-/** CPU model for build host */
-#define BUILD_CPU_MODEL         @BUILD_CPU_MODEL@
-
-/** CPU stepping for build host */
-#define BUILD_CPU_STEPPING      @BUILD_CPU_STEPPING@
-
-/** CPU feature list for build host */
-#define BUILD_CPU_FEATURES      "@BUILD_CPU_FEATURES@"
-
 /** C compiler used to build */
 #define BUILD_C_COMPILER        "@BUILD_C_COMPILER@"
 
index c4461a69aef9d5b36bb53480a24b365cbcae4d4d..b401426d240b02e164c86f502e307ecccf11d9ff 100644 (file)
 #define CPT_MAGIC2 171819
 #define CPTSTRLEN 1024
 
-/* cpt_version should normally only be changed
- * when the header or footer format changes.
+/*! \brief Enum of values that describe the contents of a cpt file
+ * whose format matches a version number
+ *
+ * The enum helps the code be more self-documenting and ensure merges
+ * do not silently resolve when two patches make the same bump. When
+ * adding new functionality, add a new element just above cptv_Count
+ * in this enumeration, and write code below that does the right thing
+ * according to the value of file_version.
+ */
+enum cptv {
+    cptv_Unknown = 17,                                       /**< Version before numbering scheme */
+    cptv_RemoveBuildMachineInformation,                      /**< remove functionality that makes mdrun builds non-reproducible */
+    cptv_Count                                               /**< the total number of cptv versions */
+};
+
+/*! \brief Version number of the file format written to checkpoint
+ * files by this version of the code.
+ *
+ * cpt_version should normally only be changed, via adding a new field
+ * to cptv enumeration, when the header or footer format changes.
+ *
  * The state data format itself is backward and forward compatible.
  * But old code can not read a new entry that is present in the file
  * (but can read a new format when new entries are not present).
- */
-static const int cpt_version = 17;
+ *
+ * The cpt_version increases whenever the file format in the main
+ * development branch changes, due to an extension of the cptv enum above.
+ * Backward compatibility for reading old run input files is maintained
+ * by checking this version number against that of the file and then using
+ * the correct code path. */
+static const int cpt_version = cptv_Count - 1;
 
 
 const char *est_names[estNR] =
@@ -887,13 +911,18 @@ static int do_cpte_matrices(XDR *xd, StatePart part, int ecpt, int sflags,
 // serialization, help separate comparison from reading, and have
 // better defined transformation functions to/from trajectory frame
 // data structures.
+//
+// Several fields were once written to checkpoint file headers, but
+// have been removed. So that old files can continue to be read,
+// the names of such fields contain the string "_UNUSED" so that it
+// is clear they should not be used.
 struct CheckpointHeaderContents
 {
     int         file_version;
     char        version[CPTSTRLEN];
-    char        btime[CPTSTRLEN];
-    char        buser[CPTSTRLEN];
-    char        bhost[CPTSTRLEN];
+    char        btime_UNUSED[CPTSTRLEN];
+    char        buser_UNUSED[CPTSTRLEN];
+    char        bhost_UNUSED[CPTSTRLEN];
     int         double_prec;
     char        fprog[CPTSTRLEN];
     char        ftime[CPTSTRLEN];
@@ -949,9 +978,15 @@ static void do_cpt_header(XDR *xd, gmx_bool bRead, FILE *list,
         gmx_gethostname(fhost, 255);
     }
     do_cpt_string_err(xd, "GROMACS version", contents->version, list);
-    do_cpt_string_err(xd, "GROMACS build time", contents->btime, list);
-    do_cpt_string_err(xd, "GROMACS build user", contents->buser, list);
-    do_cpt_string_err(xd, "GROMACS build host", contents->bhost, list);
+    // The following fields are no longer ever written with meaningful
+    // content, but because they precede the file version, there is no
+    // good way for new code to read the old and new formats, nor a
+    // good way for old code to avoid giving an error while reading a
+    // new format. So we read and write a field that no longer has a
+    // purpose.
+    do_cpt_string_err(xd, "GROMACS build time UNUSED", contents->btime_UNUSED, list);
+    do_cpt_string_err(xd, "GROMACS build user UNUSED", contents->buser_UNUSED, list);
+    do_cpt_string_err(xd, "GROMACS build host UNUSED", contents->bhost_UNUSED, list);
     do_cpt_string_err(xd, "generating program", contents->fprog, list);
     do_cpt_string_err(xd, "generation time", contents->ftime, list);
     contents->file_version = cpt_version;
@@ -1928,9 +1963,6 @@ void write_checkpoint(const char *fn, gmx_bool bNumberAndKeep,
         nED, eSwapCoords
     };
     std::strcpy(headerContents.version, gmx_version());
-    std::strcpy(headerContents.btime, BUILD_TIME);
-    std::strcpy(headerContents.buser, BUILD_USER);
-    std::strcpy(headerContents.bhost, BUILD_HOST);
     std::strcpy(headerContents.fprog, gmx::getProgramContext().fullBinaryPath());
     std::strcpy(headerContents.ftime, timebuf);
     if (DOMAINDECOMP(cr))
@@ -2095,9 +2127,6 @@ static void check_match(FILE *fplog, const t_commrec *cr, const ivec dd_nc,
 
     if (reproducibilityRequested)
     {
-        check_string(fplog, "Build time", BUILD_TIME, headerContents.btime, &mm);
-        check_string(fplog, "Build user", BUILD_USER, headerContents.buser, &mm);
-        check_string(fplog, "Build host", BUILD_HOST, headerContents.bhost, &mm);
         check_string(fplog, "Program name", gmx::getProgramContext().fullBinaryPath(), headerContents.fprog, &mm);
 
         check_int   (fplog, "#ranks", cr->nnodes, headerContents.nnodes, &mm);
@@ -2215,9 +2244,6 @@ static void read_checkpoint(const char *fn, FILE **pfplog,
         fprintf(fplog, "Reading checkpoint file %s\n", fn);
         fprintf(fplog, "  file generated by:     %s\n", headerContents->fprog);
         fprintf(fplog, "  file generated at:     %s\n", headerContents->ftime);
-        fprintf(fplog, "  GROMACS build time:    %s\n", headerContents->btime);
-        fprintf(fplog, "  GROMACS build user:    %s\n", headerContents->buser);
-        fprintf(fplog, "  GROMACS build host:    %s\n", headerContents->bhost);
         fprintf(fplog, "  GROMACS double prec.:  %d\n", headerContents->double_prec);
         fprintf(fplog, "  simulation part #:     %d\n", headerContents->simulation_part);
         fprintf(fplog, "  step:                  %s\n", gmx_step_str(headerContents->step, buf));
index 979e9752f28d474f61aac1dc8a1a37245a08f0c8..4387acc25d1444f805e9617ec83effeb862626cc 100644 (file)
@@ -270,17 +270,9 @@ void gmx_print_version_info(gmx::TextWriter *writer)
 #endif
 
 
-    writer->writeLine(formatString("Built on:           %s", BUILD_TIME));
-    writer->writeLine(formatString("Built by:           %s", BUILD_USER));
-    writer->writeLine(formatString("Build OS/arch:      %s", BUILD_HOST));
-    writer->writeLine(formatString("Build CPU vendor:   %s", BUILD_CPU_VENDOR));
-    writer->writeLine(formatString("Build CPU brand:    %s", BUILD_CPU_BRAND));
-    writer->writeLine(formatString("Build CPU family:   %d   Model: %d   Stepping: %d",
-                                   BUILD_CPU_FAMILY, BUILD_CPU_MODEL, BUILD_CPU_STEPPING));
     /* TODO: The below strings can be quite long, so it would be nice to wrap
      * them. Can wait for later, as the master branch has ready code to do all
      * that. */
-    writer->writeLine(formatString("Build CPU features: %s", BUILD_CPU_FEATURES));
     writer->writeLine(formatString("C compiler:         %s", BUILD_C_COMPILER));
     writer->writeLine(formatString("C compiler flags:   %s", BUILD_CFLAGS));
     writer->writeLine(formatString("C++ compiler:       %s", BUILD_CXX_COMPILER));