diff options
author | Eduard Sanou <dhole@openmailbox.org> | 2016-06-01 16:42:41 +0000 |
---|---|---|
committer | Matthias Klose <doko@gcc.gnu.org> | 2016-06-01 16:42:41 +0000 |
commit | 15c98b2e0d51511893baaf477beb496ed425bae8 (patch) | |
tree | 6111e9d43417c0a01997f03f171b4d3df5f399a5 /gcc/gcc.c | |
parent | de482e91f177ea4f4b5dfbaeb1f6e77fb98aae29 (diff) | |
download | gcc-15c98b2e0d51511893baaf477beb496ed425bae8.zip gcc-15c98b2e0d51511893baaf477beb496ed425bae8.tar.gz gcc-15c98b2e0d51511893baaf477beb496ed425bae8.tar.bz2 |
c-common.c (get_source_date_epoch): Rename to cb_get_source_date_epoch.
gcc/c-family/ChangeLog:
2016-05-13 Eduard Sanou <dhole@openmailbox.org>
* c-common.c (get_source_date_epoch): Rename to
cb_get_source_date_epoch.
* c-common.c (cb_get_source_date_epoch): Use a single generic erorr
message when the parsing fails. Use error_at instead of fatal_error.
* c-common.h (get_source_date_epoch): Rename to
cb_get_source_date_epoch.
* c-common.h (cb_get_source_date_epoch): Prototype.
* c-common.h (MAX_SOURCE_DATE_EPOCH): Define.
* c-common.h (c_omp_region_type): Remove trailing comma.
* c-lex.c (init_c_lex): Set cb->get_source_date_epoch callback.
* c-lex.c (c_lex_with_flags): Remove initialization of
pfile->source_date_epoch.
gcc/ChangeLog:
2016-05-13 Eduard Sanou <dhole@openmailbox.org>
* doc/cppenv.texi: Note that the `%s` in `date` is a non-standard
extension.
* gcc.c (driver_handle_option): Call set_source_date_epoch_envvar.
* gcc.c (set_source_date_epoch_envvar): New function, sets
the SOURCE_DATE_EPOCH environment variable to the current time.
gcc/testsuite/ChangeLog:
2016-05-13 Eduard Sanou <dhole@openmailbox.org>
* gcc.dg/cpp/source_date_epoch-1.c: New file, test the proper
behaviour of the macros __DATE__ and __TIME__ when SOURCE_DATE_EPOCH
env var is set.
* gcc.dg/cpp/source_date_epoch-2.c: New file, test the error output
when parsing the SOURCE_DATE_EPOCH env var, and make sure it is only
shown once.
* lib/gcc-dg.exp (dg-set-compiler-env-var): New function, set env vars
during compilation.
* lib/gcc-dg.exp (restore-compiler-env-var): New function, restore env
vars set by dg-set-compiler-env-var.
libcpp/ChangeLog:
2016-05-13 Eduard Sanou <dhole@openmailbox.org>
* include/cpplib.h (cpp_callbacks): Add get_source_date_epoch
callback.
* include/cpplib.h (cpp_init_source_date_epoch): Remove prototype.
* init.c (cpp_init_source_date_epoch): Remove function.
* init.c (cpp_create_reader): Initialize pfile->source_date_epoch.
* internal.h (cpp_reader): Extend comment about source_date_epoch.
* macro.c (_cpp_builtin_macro_text): Use get_source_date_epoch
callback only once, read pfile->source_date_epoch on future passes.
Check that get_source_date_epoch callback is not NULL.
From-SVN: r237001
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r-- | gcc/gcc.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -3547,6 +3547,29 @@ save_switch (const char *opt, size_t n_args, const char *const *args, n_switches++; } +/* Set the SOURCE_DATE_EPOCH environment variable to the current time if it is + not set already. */ + +static void +set_source_date_epoch_envvar () +{ + /* Array size is 21 = ceil(log_10(2^64)) + 1 to hold string representations + of 64 bit integers. */ + char source_date_epoch[21]; + time_t tt; + + errno = 0; + tt = time (NULL); + if (tt < (time_t) 0 || errno != 0) + tt = (time_t) 0; + + snprintf (source_date_epoch, 21, "%llu", (unsigned long long) tt); + /* Using setenv instead of xputenv because we want the variable to remain + after finalizing so that it's still set in the second run when using + -fcompare-debug. */ + setenv ("SOURCE_DATE_EPOCH", source_date_epoch, 0); +} + /* Handle an option DECODED that is unknown to the option-processing machinery. */ @@ -3846,6 +3869,7 @@ driver_handle_option (struct gcc_options *opts, else compare_debug_opt = arg; save_switch (compare_debug_replacement_opt, 0, NULL, validated, true); + set_source_date_epoch_envvar (); return true; case OPT_fdiagnostics_color_: |