[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#823937: marked as done (gcc -E has __DATE__/__TIME__ as Jan 1 1970 00:00:00)



Your message dated Mon, 15 May 2017 18:48:44 +0000
with message-id <E1dAL2y-0008Qy-MR@fasolo.debian.org>
and subject line Bug#823937: fixed in gcc-5 5.4.1-9
has caused the Debian Bug report #823937,
regarding gcc -E has __DATE__/__TIME__ as Jan 1 1970 00:00:00
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
823937: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=823937
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: gcc-5
Version: 5.3.1-17
Severity: normal
Tags: upstream patch
Control: clone -1 -2
Control: reassign -2 gcc-6 6.1.1-1

Hi,
With the SOURCE_DATE_EPOCH patch from upstream, the __DATE__ and
__TIME__ macros always give Jan 1 1970 00:00:00 when running the
preprocessor on its own with gcc -E[1]. I believe this is because
c_lex_with_flags is not called when just preprocessing (no C code needs
to be lexed), so pfile->source_date_epoch stays initialised to 0, and
subsequent __DATE__/__TIME__ expansions believe that the timestamp has
been set to epoch 0. I have attached an alternative implementation of
gcc-SOURCE_DATE_EPOCH.diff which fixes this, by initialising
pfile->source_date_epoch inside libcpp when pfile is initially created.

[1] https://paste.debian.net/683081/

-- System Information:
Debian Release: stretch/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.5.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages gcc-5 depends on:
ii  binutils      2.26-8
ii  cpp-5         5.3.1-17
ii  gcc-5-base    5.3.1-17
ii  libc6         2.22-7
ii  libcc1-0      6.1.1-1
ii  libgcc-5-dev  5.3.1-17
ii  libgcc1       1:6.1.1-1
ii  libgmp10      2:6.1.0+dfsg-2
ii  libisl15      0.16.1-1
ii  libmpc3       1.0.3-1
ii  libmpfr4      3.1.4-1
ii  libstdc++6    6.1.1-1
ii  zlib1g        1:1.2.8.dfsg-2+b1

Versions of packages gcc-5 recommends:
ii  libc6-dev  2.22-7

Versions of packages gcc-5 suggests:
pn  gcc-5-doc         <none>
pn  gcc-5-locales     <none>
pn  gcc-5-multilib    <none>
pn  libasan2-dbg      <none>
pn  libatomic1-dbg    <none>
pn  libcilkrts5-dbg   <none>
pn  libgcc1-dbg       <none>
pn  libgomp1-dbg      <none>
pn  libitm1-dbg       <none>
pn  liblsan0-dbg      <none>
pn  libmpx0-dbg       <none>
pn  libquadmath0-dbg  <none>
pn  libtsan0-dbg      <none>
pn  libubsan0-dbg     <none>

-- no debconf information
--- a/src/libcpp/init.c
+++ b/src/libcpp/init.c
@@ -36,6 +36,7 @@
 
 static void init_library (void);
 static void mark_named_operators (cpp_reader *, int);
+static void cpp_init_source_date_epoch (cpp_reader *);
 static void read_original_filename (cpp_reader *);
 static void read_original_directory (cpp_reader *);
 static void post_options (cpp_reader *);
@@ -264,6 +265,9 @@
 
   _cpp_init_hashtable (pfile, table);
 
+  /* Initialize the source_date_epoch value.  */
+  cpp_init_source_date_epoch (pfile);
+
   return pfile;
 }
 
@@ -530,6 +534,46 @@
     _cpp_define_builtin (pfile, "__OBJC__ 1");
 }
 
+/* Read SOURCE_DATE_EPOCH from environment to have a deterministic
+   timestamp to replace embedded current dates to get reproducible
+   results.  Returns -1 if SOURCE_DATE_EPOCH is not defined.  */
+static time_t
+get_source_date_epoch (cpp_reader *pfile)
+{
+  char *source_date_epoch;
+  long long epoch;
+  char *endptr;
+
+  source_date_epoch = getenv ("SOURCE_DATE_EPOCH");
+  if (!source_date_epoch)
+    return (time_t) -1;
+
+  errno = 0;
+  epoch = strtoll (source_date_epoch, &endptr, 10);
+  if ((errno == ERANGE && (epoch == LLONG_MAX || epoch == LLONG_MIN))
+      || (errno != 0 && epoch == 0))
+    cpp_error (pfile, CPP_DL_FATAL, "environment variable $SOURCE_DATE_EPOCH: "
+		 "strtoll: %s\n", xstrerror(errno));
+  if (endptr == source_date_epoch)
+    cpp_error (pfile, CPP_DL_FATAL, "environment variable $SOURCE_DATE_EPOCH: "
+		 "no digits were found: %s\n", endptr);
+  if (*endptr != '\0')
+    cpp_error (pfile, CPP_DL_FATAL, "environment variable $SOURCE_DATE_EPOCH: "
+		 "trailing garbage: %s\n", endptr);
+  if (epoch < 0)
+    cpp_error (pfile, CPP_DL_FATAL, "environment variable $SOURCE_DATE_EPOCH: "
+		 "value must be nonnegative: %lld \n", epoch);
+
+  return (time_t) epoch;
+}
+
+/* Initialize the source_date_epoch value.  */
+static void
+cpp_init_source_date_epoch (cpp_reader *pfile)
+{
+  pfile->source_date_epoch = get_source_date_epoch (pfile);
+}
+
 /* Sanity-checks are dependent on command-line options, so it is
    called as a subroutine of cpp_read_main_file ().  */
 #if ENABLE_CHECKING
--- a/src/libcpp/internal.h
+++ b/src/libcpp/internal.h
@@ -502,6 +502,10 @@
   const unsigned char *date;
   const unsigned char *time;
 
+  /* Externally set timestamp to replace current date and time useful for
+     reproducibility.  */
+  time_t source_date_epoch;
+
   /* EOF token, and a token forcing paste avoidance.  */
   cpp_token avoid_paste;
   cpp_token eof;
--- a/src/libcpp/macro.c
+++ b/src/libcpp/macro.c
@@ -350,13 +350,20 @@
 	  time_t tt;
 	  struct tm *tb = NULL;
 
-	  /* (time_t) -1 is a legitimate value for "number of seconds
-	     since the Epoch", so we have to do a little dance to
-	     distinguish that from a genuine error.  */
-	  errno = 0;
-	  tt = time(NULL);
-	  if (tt != (time_t)-1 || errno == 0)
-	    tb = localtime (&tt);
+	  /* Set a reproducible timestamp for __DATE__ and __TIME__ macro
+	     usage if SOURCE_DATE_EPOCH is defined.  */
+	  if (pfile->source_date_epoch != (time_t) -1)
+	     tb = gmtime (&pfile->source_date_epoch);
+	  else
+	    {
+	      /* (time_t) -1 is a legitimate value for "number of seconds
+		 since the Epoch", so we have to do a little dance to
+		 distinguish that from a genuine error.  */
+	      errno = 0;
+	      tt = time (NULL);
+	      if (tt != (time_t)-1 || errno == 0)
+		tb = localtime (&tt);
+	    }
 
 	  if (tb)
 	    {

Attachment: signature.asc
Description: PGP signature


--- End Message ---
--- Begin Message ---
Source: gcc-5
Source-Version: 5.4.1-9

We believe that the bug you reported is fixed in the latest version of
gcc-5, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 823937@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Matthias Klose <doko@debian.org> (supplier of updated gcc-5 package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Mon, 15 May 2017 11:23:28 -0700
Source: gcc-5
Binary: gcc-5-base libgcc-5-dev libgcc4 libgcc4-dbg lib64gcc-5-dev lib32gcc-5-dev libn32gcc-5-dev libx32gcc-5-dev gcc-5 gcc-5-multilib gcc-5-test-results gcc-5-plugin-dev gcc-5-hppa64-linux-gnu cpp-5 gcc-5-locales g++-5 g++-5-multilib libasan2 libasan2-dbg lib32asan2 lib32asan2-dbg lib64asan2 lib64asan2-dbg libx32asan2 libx32asan2-dbg libmpx0 libmpx0-dbg lib32mpx0 lib32mpx0-dbg lib64mpx0 lib64mpx0-dbg libgccjit-5-doc libgccjit-5-dev gobjc++-5 gobjc++-5-multilib gobjc-5 gobjc-5-multilib libobjc-5-dev lib64objc-5-dev lib32objc-5-dev libn32objc-5-dev libx32objc-5-dev gfortran-5 gfortran-5-multilib libgfortran-5-dev lib64gfortran-5-dev lib32gfortran-5-dev libn32gfortran-5-dev libx32gfortran-5-dev gccgo-5 gccgo-5-multilib libgo7 libgo7-dbg lib64go7 lib64go7-dbg lib32go7 lib32go7-dbg libn32go7 libn32go7-dbg libx32go7 libx32go7-dbg gcj-5 gcj-5-jdk gcj-5-jre-headless gcj-5-jre libgcj16 gcj-5-jre-lib libgcj16-awt libgcj16-dev libgcj16-dbg gcj-5-source libgcj-doc libstdc++-5-dev
 libstdc++-5-pic libstdc++6-5-dbg lib32stdc++-5-dev lib32stdc++6-5-dbg lib64stdc++-5-dev lib64stdc++6-5-dbg libn32stdc++-5-dev libn32stdc++6-5-dbg libx32stdc++-5-dev libx32stdc++6-5-dbg libstdc++-5-doc gnat-5 gnat-5-sjlj libgnat-5 libgnat-5-dbg libgnatvsn5-dev libgnatvsn5 libgnatvsn5-dbg libgnatprj5-dev libgnatprj5 libgnatprj5-dbg gdc-5 gdc-5-multilib libphobos-5-dev lib64phobos-5-dev lib32phobos-5-dev libx32phobos-5-dev
 gcc-5-source
Architecture: source
Version: 5.4.1-9
Distribution: unstable
Urgency: medium
Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org>
Changed-By: Matthias Klose <doko@debian.org>
Description:
 cpp-5      - GNU C preprocessor
 g++-5      - GNU C++ compiler
 g++-5-multilib - GNU C++ compiler (multilib support)
 gcc-5      - GNU C compiler
 gcc-5-base - GCC, the GNU Compiler Collection (base package)
 gcc-5-hppa64-linux-gnu - GNU C compiler (cross compiler for hppa64)
 gcc-5-locales - GCC, the GNU compiler collection (native language support files)
 gcc-5-multilib - GNU C compiler (multilib support)
 gcc-5-plugin-dev - Files for GNU GCC plugin development.
 gcc-5-source - Source of the GNU Compiler Collection
 gcc-5-test-results - Test results for the GCC test suite
 gccgo-5    - GNU Go compiler
 gccgo-5-multilib - GNU Go compiler (multilib support)
 gcj-5      - GCJ byte code and native compiler for Java(TM)
 gcj-5-jdk  - GCJ and Classpath development tools for Java(TM)
 gcj-5-jre  - Java runtime environment using GIJ/Classpath
 gcj-5-jre-headless - Java runtime environment using GIJ/Classpath (headless version)
 gcj-5-jre-lib - Java runtime library for use with gcj (jar files)
 gcj-5-source - GCJ java sources for use in IDEs like eclipse and netbeans
 gdc-5      - GNU D compiler (version 2)
 gdc-5-multilib - GNU D compiler (version 2, multilib support)
 gfortran-5 - GNU Fortran compiler
 gfortran-5-multilib - GNU Fortran compiler (multilib support)
 gnat-5     - GNU Ada compiler
 gnat-5-sjlj - GNU Ada compiler (setjump/longjump runtime library)
 gobjc++-5  - GNU Objective-C++ compiler
 gobjc++-5-multilib - GNU Objective-C++ compiler (multilib support)
 gobjc-5    - GNU Objective-C compiler
 gobjc-5-multilib - GNU Objective-C compiler (multilib support)
 lib32asan2 - AddressSanitizer -- a fast memory error detector (32bit)
 lib32asan2-dbg - AddressSanitizer -- a fast memory error detector (32 bit debug sy
 lib32gcc-5-dev - GCC support library (32 bit development files)
 lib32gfortran-5-dev - Runtime library for GNU Fortran applications (32bit development f
 lib32go7   - Runtime library for GNU Go applications (32bit)
 lib32go7-dbg - Runtime library for GNU Go applications (32 bit debug symbols)
 lib32mpx0  - Intel memory protection extensions (32bit)
 lib32mpx0-dbg - Intel memory protection extensions (32 bit debug symbols)
 lib32objc-5-dev - Runtime library for GNU Objective-C applications (32bit developme
 lib32phobos-5-dev - Phobos D standard library (64bit development files)
 lib32stdc++-5-dev - GNU Standard C++ Library v3 (development files)
 lib32stdc++6-5-dbg - GNU Standard C++ Library v3 (debugging files)
 lib64asan2 - AddressSanitizer -- a fast memory error detector (64bit)
 lib64asan2-dbg - AddressSanitizer -- a fast memory error detector (64bit debug sym
 lib64gcc-5-dev - GCC support library (64bit development files)
 lib64gfortran-5-dev - Runtime library for GNU Fortran applications (64bit development f
 lib64go7   - Runtime library for GNU Go applications (64bit)
 lib64go7-dbg - Runtime library for GNU Go applications (64bit debug symbols)
 lib64mpx0  - Intel memory protection extensions (64bit)
 lib64mpx0-dbg - Intel memory protection extensions (64bit debug symbols)
 lib64objc-5-dev - Runtime library for GNU Objective-C applications (64bit developme
 lib64phobos-5-dev - Phobos D standard library (64bit development files)
 lib64stdc++-5-dev - GNU Standard C++ Library v3 (development files)
 lib64stdc++6-5-dbg - GNU Standard C++ Library v3 (debugging files)
 libasan2   - AddressSanitizer -- a fast memory error detector
 libasan2-dbg - AddressSanitizer -- a fast memory error detector (debug symbols)
 libgcc-5-dev - GCC support library (development files)
 libgcc4    - GCC support library
 libgcc4-dbg - GCC support library (debug symbols)
 libgccjit-5-dev - GCC just-in-time compilation (development files)
 libgccjit-5-doc - GCC just-in-time compilation (documentation)
 libgcj-doc - libgcj API documentation and example programs
 libgcj16   - Java runtime library for use with gcj
 libgcj16-awt - AWT peer runtime libraries for use with gcj
 libgcj16-dbg - Debugging symbols for libraries provided in libgcj16-dev
 libgcj16-dev - Java development headers for use with gcj
 libgfortran-5-dev - Runtime library for GNU Fortran applications (development files)
 libgnat-5  - runtime for applications compiled with GNAT (shared library)
 libgnat-5-dbg - runtime for applications compiled with GNAT (debugging symbols)
 libgnatprj5 - GNU Ada compiler Project Manager (shared library)
 libgnatprj5-dbg - GNU Ada compiler Project Manager (debugging symbols)
 libgnatprj5-dev - GNU Ada compiler Project Manager (development files)
 libgnatvsn5 - GNU Ada compiler selected components (shared library)
 libgnatvsn5-dbg - GNU Ada compiler selected components (debugging symbols)
 libgnatvsn5-dev - GNU Ada compiler selected components (development files)
 libgo7     - Runtime library for GNU Go applications
 libgo7-dbg - Runtime library for GNU Go applications (debug symbols)
 libmpx0    - Intel memory protection extensions (runtime)
 libmpx0-dbg - Intel memory protection extensions (debug symbols)
 libn32gcc-5-dev - GCC support library (n32 development files)
 libn32gfortran-5-dev - Runtime library for GNU Fortran applications (n32 development fil
 libn32go7  - Runtime library for GNU Go applications (n32)
 libn32go7-dbg - Runtime library for GNU Go applications (n32 debug symbols)
 libn32objc-5-dev - Runtime library for GNU Objective-C applications (n32 development
 libn32stdc++-5-dev - GNU Standard C++ Library v3 (development files)
 libn32stdc++6-5-dbg - GNU Standard C++ Library v3 (debugging files)
 libobjc-5-dev - Runtime library for GNU Objective-C applications (development fil
 libphobos-5-dev - Phobos D standard library
 libstdc++-5-dev - GNU Standard C++ Library v3 (development files)
 libstdc++-5-doc - GNU Standard C++ Library v3 (documentation files)
 libstdc++-5-pic - GNU Standard C++ Library v3 (shared library subset kit)
 libstdc++6-5-dbg - GNU Standard C++ Library v3 (debugging files)
 libx32asan2 - AddressSanitizer -- a fast memory error detector (x32)
 libx32asan2-dbg - AddressSanitizer -- a fast memory error detector (x32 debug symbo
 libx32gcc-5-dev - GCC support library (x32 development files)
 libx32gfortran-5-dev - Runtime library for GNU Fortran applications (x32 development fil
 libx32go7  - Runtime library for GNU Go applications (x32)
 libx32go7-dbg - Runtime library for GNU Go applications (x32 debug symbols)
 libx32objc-5-dev - Runtime library for GNU Objective-C applications (x32 development
 libx32phobos-5-dev - Phobos D standard library (x32 development files)
 libx32stdc++-5-dev - GNU Standard C++ Library v3 (development files)
 libx32stdc++6-5-dbg - GNU Standard C++ Library v3 (debugging files)
Closes: 823937
Changes:
 gcc-5 (5.4.1-9) unstable; urgency=medium
 .
   * Update to SVN 20170515 (r248069, 5.4.1) from the gcc-5-branch.
     - Fix PR libstdc++/79980, PR libstdc++/80041, PR libstdc++/79980,
       PR libstdc++/79511, PR libstdc++/80034, PR target/45053 (PPC),
       PR c++/79548, PR target/69868 (PPC), PR target/68491 (x86),
       PR target/68390 (ARM), PR target/80376 (PPC), PR target/80315 (PPC),
       PR target/80082 (ARM), PR ipa/77333, PR tree-optimization/68021,
       PR target/79733 (x86), PR target/80246 (PPC), PR target/80180 (x86),
       PR lto/79587, PR target/79906 (PPC), PR gcov-profile/80081,
       PR middle-end/79753, PR target/79769, PR target/79770,
       PR middle-end/79831, PR middle-end/78339, PR target/65705,
       PR target/69804, PR sanitizer/71458, PR tree-optimization/79631,
       PR ipa/79761, PR tree-optimization/79803, PR rtl-optimization/79574,
       PR rtl-optimization/79574, PR rtl-optimization/79577,
       PR target/79951 (PPC), PR target/71017 (x86), PR target/80019 (x86),
       PR target/79439 (PPC), PR target/77850 (PA), PR fortran/80392,
       PR fortran/80361, PR fortran/59910, PR fortran/80388, PR c/79756,
       PR tree-optimization/79732, PR tree-optimization/79666,
       PR tree-optimization/80122, PR tree-optimization/80334,
       PR middle-end/80539, PR fortran/79894.
   * Fix symlinks to man pages in the hppa64 package. Addresses: #857583.
   * Fix ecj1 symlink for gcj cross compiler packages. Addresses: #855640.
   * Don't ship the gnatgcc manpage symlink when building GFDL packages.
     Addresses: #857384.
   * Install the gcov-dump utility.
   * Remove libquadmath/gdtoa license from debian/copyright (files removed).
   * PR preprocessor/71183, taken from the trunk. Closes: #823937.
   * Update the Linaro support to the 5-2017.05 snapshot.
   * Disable running the testsuite on KFreeBSD, hanging the buildds.
Checksums-Sha1:
 a85525b6e91f89922fe073d7ea628c8ec4150d8b 17569 gcc-5_5.4.1-9.dsc
 f4487eb114f991743ac5269eec025bd068ac4e08 3608044 gcc-5_5.4.1-9.diff.gz
 7c413f9976fd6aa8aa291de4ab425e0d6bf4f440 14597 gcc-5_5.4.1-9_source.buildinfo
Checksums-Sha256:
 de99f85e86678b1d019e76ef88f01d542d5a340a42c21abd3d8c1d791dd71c6b 17569 gcc-5_5.4.1-9.dsc
 0bf8f190bb20ba1f29dcae62d4193642ab3afbedd06d2d9a549068046de35fb6 3608044 gcc-5_5.4.1-9.diff.gz
 f302c060f9a122ca02e8902d928fa2a9b1132a2fc600d9ff2bae00f02229a448 14597 gcc-5_5.4.1-9_source.buildinfo
Files:
 ebe2d6b95b8885bd576c3d73546c1dc0 17569 devel optional gcc-5_5.4.1-9.dsc
 0279245ea051d3379d88dffa9975ab86 3608044 devel optional gcc-5_5.4.1-9.diff.gz
 7df0634de9a7b47eac14a176002c16df 14597 devel optional gcc-5_5.4.1-9_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iQJEBAEBCAAuFiEE1WVxuIqLuvFAv2PWvX6qYHePpvUFAlkZ9aIQHGRva29AZGVi
aWFuLm9yZwAKCRC9fqpgd4+m9arqD/9vMaSHjD0In3lTptSJYThYYFCOHc69Ujco
tFbY2lfJ/13kMiRvkbzYV3fXG14ubUVXTm48sRBqDawWKSzfVEQhvKz0MijoYz14
TdCcLkhg89HKXku5sIW28NRu9+yDGWX9HLQk/sncQkCEVuWY+U6yDANYuQtjGYmm
5PVvekc8I9lWNdb2Ig50ErJuJycJJ7jo5wh48En9vcwcrbFbQLcRXOCmhnUzutBf
D0ofRZUna8IEg5Kiw/BKHBwnhYDe1KRzwlJMvnaNZZ52G1FQQ/LQZ0jVoHsKkr1A
srpycq8H6TXokOO29IcI9z5nwwt2+3XyY9mHt4Kupaz/7s9GeOkJWoWH8e2kyahU
jYR1aVLNFIaWXKFCIwAvG42lqHoG4cBNSGwIqRV8WajsfCg7K5z9V5YiPXl1e1BJ
V4qt8bGFj1Oby2Gr1ShuQyq6q+WjfERBQt5Q0yMuOpghwomauweopwNHIqMBCHgz
xfiMWEhO5r1vvaG0yHH25LjXMSLIWiSvcoAO4QbbU4w/ov6WlbxpK3w9BG3d0YNh
QGMEKbuVMwDw4V527wrbeh/FaxKWQ9RXUOHxr4uox/NtWxCbHI1WhTElVtt9cRhQ
7wiKwVup4WxFqgCEPqJ363OIXT7fiOlyqq/KacavtjXC+twmrbGrlT4nKq0qnvZf
xS73iFwu6Q==
=oHJk
-----END PGP SIGNATURE-----

--- End Message ---

Reply to: