This is an archive of the discontinued LLVM Phabricator instance.

Add a new preprocessor option `-fbuild-session-timestamp-date-time-macros`
Needs ReviewPublic

Authored by appcs on Mar 4 2022, 8:09 PM.

Details

Summary

Add a new preprocessor option -fbuild-session-timestamp-date-time-macros to
set the predefined macros: DATE and TIME using option
-fbuild-session-timestamp or -fbuild-session-file=<file>

Motivation:
0. Using the SOURCE_DATE_EPOCH environmental variable to specify reproducible

embedded timestamps. See: 

a. https://reproducible-builds.org/specs/source-date-epoch/
b. https://gcc.gnu.org/onlinedocs/cpp/Environment-Variables.html
  1. Add a -ffixed-date-time= flag that sets the initial value of DATE, TIME, TIMESTAMP

    https://reviews.llvm.org/D23934

Diff Detail

Event Timeline

appcs created this revision.Mar 4 2022, 8:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 4 2022, 8:09 PM
Herald added a subscriber: dang. · View Herald Transcript
appcs requested review of this revision.Mar 4 2022, 8:09 PM

Why isn't D23934 sufficient? What do these flags with very long names do that ffixed-date-time doesn't?

bruno added a comment.Mar 7 2022, 12:39 PM

Why isn't D23934 sufficient? What do these flags with very long names do that ffixed-date-time doesn't?

+1

Also, how does this work with the testcase added in D23934? Also, along the lines of similar questions in D23934, how does this affect -Wdate-time and -Wpch-date-time?

appcs added a comment.Mar 7 2022, 4:26 PM

Why isn't D23934 sufficient? What do these flags with very long names do that ffixed-date-time doesn't?

Given that -fbuild-session-timestamp and -fbuild-session-file=<file> already exist, and that I had implemented the above since asking if https://reviews.llvm.org/D23934 would get committed, I submitted this.
The thought behind the choice of option name was that all the related options would appear together under --help

I will port https://reviews.llvm.org/D23934 to top of trunk, thank you.

appcs added a comment.Mar 7 2022, 5:37 PM

...
Also, along the lines of similar questions in D23934, how does this affect -Wdate-time and -Wpch-date-time?

In the rebase of D23934:

a. Disallow the simultaneous use of -Wdate-time/-Wpch-date-time and -ffixed-date-time=<timestamp>?
b. Disallow -ffixed-date-time=<timestamp>:

0. if PCH's are used
1. in PCH compilation

Also, (just as -Wdate-time warns on TIMESTAMP use), do we (in a separate patch), extend the scope of -Wpch-date-time to cover the use of TIMESTAMP is in a PCH?

Thank you.

appcs added a comment.Mar 25 2022, 4:33 PM

I will port https://reviews.llvm.org/D23934 to top of trunk, thank you.

Rebased. Please see: D122517