Bit-reproduciblity issue for gfortran .mod files
Alastair McKinstry
mckinstry@debian.org
Fri Feb 2 13:22:00 GMT 2018
Hi,
gfortran .mod files compressed files, contains a header, which looks like:
(viewed with e.g. zmore /usr/include/cgns.mod ):
GFORTRAN module version '14' created from /build/libcgns-XmhIxt/libcgns-3.3.0/src/cgns_f.F90
(() () () () () () () () () () () () () () () () () () () () () () () ()
() () ())
The full path of the compiled fortran file is included, which can break b=
it-reproducible builds.
(see https://reproducible-builds.org/)
A trivial patch is included, to strip the path.
Best regards
Alastair McKinstry
Index: gcc-7-7.2.0/src/gcc/fortran/module.c
===================================================================
--- gcc-7-7.2.0.orig/src/gcc/fortran/module.c
+++ gcc-7-7.2.0/src/gcc/fortran/module.c
@@ -79,6 +79,10 @@ along with GCC; see the file COPYING3.
#include "scanner.h"
#include <zlib.h>
+/* for GNU / POSIX basename */
+#define _GNU_SOURCE
+#include <string.h>
+
#define MODULE_EXTENSION ".mod"
#define SUBMODULE_EXTENSION ".smod"
@@ -6063,8 +6067,9 @@ dump_module (const char *name, int dump_
gfc_fatal_error ("Can't open module file %qs for writing at %C: %s",
filename_tmp, xstrerror (errno));
+ /* Use basename to make builds bit-reproducible */
gzprintf (module_fp, "GFORTRAN module version '%s' created from %s\n",
- MOD_VERSION, gfc_source_file);
+ MOD_VERSION, basename(gfc_source_file));
/* Write the module itself. */
iomode = IO_OUTPUT;
--
Alastair McKinstry, <alastair@sceal.ie>, <mckinstry@debian.org>, https://diaspora.sceal.ie/u/amckinstry
Misentropy: doubting that the Universe is becoming more disordered.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20180202/0ebb7931/attachment.sig>
More information about the Fortran
mailing list