[PATCH] D135045: [Frontend] Recognize environment variable SOURCE_DATE_EPOCH

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 2 16:22:25 PDT 2022


MaskRay created this revision.
MaskRay added reviewers: clang-language-wg, aaron.ballman, appcs, efriedma, emaste.
Herald added a subscriber: StephenFan.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

See https://reproducible-builds.org/docs/source-date-epoch/ . The environment
variable has ``SOURCE_DATE_EPOCH`` been recognized by many compilers.

In GCC, if `SOURCE_DATE_EPOCH` is set, it specifies a UNIX timestamp to be used
in replacement of the current date and time in the `__DATE__` and `__TIME__`
macros. Note: `__TIMESTAMP__` uses the modification time of the current source
file, which is unaffected by `SOURCE_DATE_EPOCH`.

The patch implements the GCC behavior.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135045

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/Preprocessor/SOURCE_DATE_EPOCH.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135045.464577.patch
Type: text/x-patch
Size: 4999 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221002/d565c379/attachment.bin>


More information about the cfe-commits mailing list