Index: lib/Lex/PPMacroExpansion.cpp =================================================================== --- lib/Lex/PPMacroExpansion.cpp +++ lib/Lex/PPMacroExpansion.cpp @@ -1013,7 +1013,12 @@ /// the identifier tokens inserted. static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc, Preprocessor &PP) { - time_t TT = time(nullptr); + time_t TT; + const char *envValue = getenv("SOURCE_DATE_EPOCH"); + if (envValue != nullptr) + TT = strtol(envValue, nullptr, 10); + else + TT = time(nullptr); struct tm *TM = localtime(&TT); static const char * const Months[] = {