In the debian reproducible builds project we have considered several
options to address this issue. We considered redefining the __DATE__ and
__TIME__ defines by command line flags passed to gcc, but as you say,
that triggers warnings, which could become errors when building with
-Werror and thus may require manual intervention on many packages.

Would replacing the localtime function with one of your own
in a DSO and preloading the DSO when invoking GCC be a viable
solution? E.g., like so:

$ cat time.c && gcc -Wall -fpic -o libtime.so -shared time.c && echo "__DATE__ __TIME__" | LD_PRELOAD=./libtime.so gcc -E -xc -
#include <time.h>
static struct tm t;
struct tm *localtime (const time_t *timer) { return &t; }
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "<stdin>"
"Jan  0 1900" "00:00:00"

Martin

Reply via email to