Issue 20444 - Make __DATE__ in dlang reproducible using SOURCE_DATE_EPOCH
Summary: Make __DATE__ in dlang reproducible using SOURCE_DATE_EPOCH
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 enhancement
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks: 20445
  Show dependency treegraph
 
Reported: 2019-12-12 09:34 UTC by jelle
Modified: 2020-04-17 00:02 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description jelle 2019-12-12 09:34:57 UTC
The reproducible builds project is working on achieving bit for bit identical builds on for example two different systems. To prove that the same source can be used on two different machines to create an identical build. Timestamps lead to unreproducibility by use of __DATE__ or __TIME__, other compilers such as GCC support SOURCE_DATE_EPOCH which makes the build reproducible by using that epoch timestamp value as value for the __DATE__.

It would be nice to see the D compiler also support SOURCE_DATE_EPOCH so that __DATE__ and __TIME__ does not need to be removed from source code to make builds reproducible. 

More about reproducible builds can be found here: https://reproducible-builds.org/ and about SOURCE_DATE_EPOCH https://reproducible-builds.org/docs/source-date-epoch/

GCC references:
https://gcc.gnu.org/onlinedocs/cpp/Environment-Variables.html
https://wiki.debian.org/ReproducibleBuilds/TimestampsFromCPPMacros
Comment 1 Dlang Bot 2020-04-14 10:40:38 UTC
@Geod24 created dlang/dmd pull request #11035 "Fix issue 20444 - Support `SOURCE_DATE_EPOCH` for reproducible builds" fixing this issue:

- Refactor: Move time/date/timestamp handling to target
  
  As mentioned in issue 20444, some compilers (e.g. GCC) support SOURCE_DATE_EPOCH.
  Moving the handling to target will allow them to hook their driver logic directly,
  instead of having to edit lexer.

- Fix issue 20444 - Support `SOURCE_DATE_EPOCH` for reproducible builds
  
  Adds support for the de-facto standard `SOURCE_DATE_EPOCH` variable,
  for lexer tokens `__DATE__`, `__TIME__`, `__TIMESTAMP__`.

https://github.com/dlang/dmd/pull/11035
Comment 2 Dlang Bot 2020-04-17 00:02:56 UTC
dlang/dmd pull request #11035 "Fix issue 20444 - Support `SOURCE_DATE_EPOCH` for reproducible builds" was merged into master:

- bfb538a1cb5c5991955696db6584fb90bfe783ef by Geod24:
  Fix issue 20444 - Support `SOURCE_DATE_EPOCH` for reproducible builds
  
  Adds support for the de-facto standard `SOURCE_DATE_EPOCH` variable,
  for lexer tokens `__DATE__`, `__TIME__`, `__TIMESTAMP__`.

https://github.com/dlang/dmd/pull/11035