[Preprocessor] Add a -ffixed-date-time= flag that sets the initial value of DATE, TIME, TIMESTAMP
Rebase D23934.
Paths
| Differential D122517
Rebase D23934: Add a -ffixed-date-time= flag that sets the initial value of __DATE__, __TIME__, __TIMESTAMP__ Needs ReviewPublic Authored by appcs on Mar 25 2022, 4:29 PM.
Details
Diff Detail Event TimelineComment Actions (From D121040) Please let me know about the following and I will incorporate your feedback and submit subsequent patches for addressing these questions: a. Disallow the simultaneous use of -Wdate-time/-Wpch-date-time and -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. Comment Actions Bazel uses -Wno-builtin-macro-redefined -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted".
Comment Actions
If you are saying that defining DATE, TIMESTAMP, TIME to an arbitrary time value, then that is the definition of the problem that we are trying to solve; else, please clarify. Thanks.
Via -ffixed-date-time the value would have to be formatted e.g. 1969-12-31T23:59:59 (RFC3339 without fractional seconds and timezone); else, please clarify. Thanks. aaron.ballman added inline comments.
Comment Actions
Comment Actions
Please ignore. Thanks. Comment Actions
Please ignore. Thanks. Comment Actions
(After a fair amount of reading, and contemplation), I think I understand. Basically, Clang takes the (rightfully correct) stand that the very presence of the DATE, TIME and TIMESTAMP macros in the source makes the resulting binary irreproducible. Period. Comment Actions
Yeah, my question is whether we need the ability to set time to an arbitrary point and adjust the output of the three macros. Is it needed by a user? Comment Actions Created D135045 [Frontend] Recognize environment variable SOURCE_DATE_EPOCH. I think that's more likely what users want to use.
Revision Contents
Diff 419021 clang/include/clang/Driver/Options.td
clang/include/clang/Lex/PreprocessorOptions.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/test/Preprocessor/fixed-date-time.cpp
|
This function doesn't exist on Windows.