[PATCH] D20791: Support SOURCE_DATE_EPOCH environment variable
Ed Maste via cfe-commits
cfe-commits at lists.llvm.org
Mon May 30 10:32:11 PDT 2016
emaste updated this revision to Diff 58977.
emaste added a comment.
Use gmtime to report in UTC when `SOURCE_DATE_EPOCH` is set. This follows GCC and makes sense given the purpose of `SOURCE_DATE_EPOCH`.
For reference here is discussion on the GCC list when this was introduced there: https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02210.html
http://reviews.llvm.org/D20791
Files:
lib/Lex/PPMacroExpansion.cpp
Index: lib/Lex/PPMacroExpansion.cpp
===================================================================
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -1013,8 +1013,16 @@
/// the identifier tokens inserted.
static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc,
Preprocessor &PP) {
- time_t TT = time(nullptr);
- struct tm *TM = localtime(&TT);
+ time_t TT;
+ struct tm *TM;
+ const char *envValue = getenv("SOURCE_DATE_EPOCH");
+ if (envValue != nullptr) {
+ TT = strtol(envValue, nullptr, 10);
+ TM = gmtime(&TT);
+ } else {
+ TT = time(nullptr);
+ TM = localtime(&TT);
+ }
static const char * const Months[] = {
"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20791.58977.patch
Type: text/x-patch
Size: 795 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160530/90682193/attachment-0001.bin>
More information about the cfe-commits
mailing list