Giving __DATE__ and __TIME__ fixed values

Hi,

we’re trying to make our build more deterministic. Several third-party libraries we depend on use DATE and TIME, which makes that part of the build nondeterministic. So we’d like to force both of them to a fixed value via some flag.

-D__DATE__= -D__TIME__= kind of works, but it triggers Wbuiltin-macro-redefined warnings (and it also causes a crash when using them with pchs). Is using -D flags the right approach for this? It seems a bit hacky. Would there be interest in adding a (say) -ffixed-date-time=1997-07-16T19:20+01:00 flag that sets the initial value of DATE and TIME so that we don’t have to redefine them?

Nico

It’s still hacky, but I bet -U__DATE__ -D__DATE__=x still works.

It's still hacky, but I bet -U__DATE__ -D__DATE__=x still works.

That's a good idea, but it seems to trigger "warning: undefining builtin
macro [-Wbuiltin-macro-redefined]" instead.

I uploaded a patch for this: https://reviews.llvm.org/D23934