File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -36,10 +36,21 @@ JL_DLLEXPORT int jl_gettimeofday(struct jl_timeval *jtv)
36
36
jtv -> sec = tb .time ;
37
37
jtv -> usec = tb .millitm * 1000 ;
38
38
#else
39
- struct timeval tv ;
40
- int code = gettimeofday (& tv , NULL );
41
- jtv -> sec = tv .tv_sec ;
42
- jtv -> usec = tv .tv_usec ;
39
+ int code = 0 ; // success
40
+ // Allow reproducible build by using the environment variable SOURCE_DATE_EPOCH
41
+ // https://reproducible-builds.org/docs/source-date-epoch/
42
+ time_t now ;
43
+ char * source_date_epoch ;
44
+ if ((source_date_epoch = getenv ("SOURCE_DATE_EPOCH" )) == NULL ||
45
+ (now = (time_t )strtoll (source_date_epoch , NULL , 10 )) <= 0 ) {
46
+ struct timeval tv ;
47
+ code = gettimeofday (& tv , NULL );
48
+ jtv -> sec = tv .tv_sec ;
49
+ jtv -> usec = tv .tv_usec ;
50
+ } else {
51
+ jtv -> sec = now ;
52
+ jtv -> usec = 0 ;
53
+ }
43
54
#endif
44
55
return code ;
45
56
}
You can’t perform that action at this time.
0 commit comments