This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix SOURCE_DATE_EPOCH handling with -E (PR preprocessor/71183)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>, Jason Merrill <jason at redhat dot com>, Marek Polacek <polacek at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 13 Jun 2016 20:28:41 +0200
- Subject: [PATCH] Fix SOURCE_DATE_EPOCH handling with -E (PR preprocessor/71183)
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The SOURCE_DATE_EPOCH env var is ignored during -E, which is undesirable
and inconsistent. The problem is that the appropriate callback for
libcpp is only installed when compiling and not when preprocessing only.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?
2016-06-13 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/71183
* c-ppoutput.c (init_pp_output): Set cb->get_source_date_epoch
to cb_get_source_date_epoch.
* gcc.dg/cpp/source_date_epoch-3.c: New test.
--- gcc/c-family/c-ppoutput.c.jj 2016-01-04 14:55:58.000000000 +0100
+++ gcc/c-family/c-ppoutput.c 2016-06-12 19:49:50.932112947 +0200
@@ -150,6 +150,7 @@ init_pp_output (FILE *out_stream)
}
cb->has_attribute = c_common_has_attribute;
+ cb->get_source_date_epoch = cb_get_source_date_epoch;
/* Initialize the print structure. */
print.src_line = 1;
--- gcc/testsuite/gcc.dg/cpp/source_date_epoch-3.c.jj 2016-06-12 19:56:49.988696438 +0200
+++ gcc/testsuite/gcc.dg/cpp/source_date_epoch-3.c 2016-06-12 19:57:36.648093343 +0200
@@ -0,0 +1,9 @@
+/* PR preprocessor/71183 */
+/* { dg-do preprocess } */
+/* { dg-set-compiler-env-var SOURCE_DATE_EPOCH "630333296" } */
+
+const char *date = __DATE__;
+const char *time = __TIME__;
+
+/* { dg-final { scan-file source_date_epoch-3.i "Dec 22 1989" } } */
+/* { dg-final { scan-file source_date_epoch-3.i "12:34:56" } } */
Jakub