Make __DATE__/__TIME__ deterministic when NIX_ENFORCE_PURITY=1#51510
Make __DATE__/__TIME__ deterministic when NIX_ENFORCE_PURITY=1#51510rht wants to merge 1 commit intoNixOS:masterfrom rht:deterministic-build
Conversation
There was a problem hiding this comment.
Did you mean?
| extraAfter=(-D__DATE__=\"???-??-????\" | |
| extraAfter=(-D__DATE__=\"??-??-????\" |
There was a problem hiding this comment.
Do you know what debian is doing here?
There was a problem hiding this comment.
It appears that there has been a patch to gcc (since 2016) to allow using SOURCE_DATE_EPOCH https://wiki.debian.org/ReproducibleBuilds/TimestampsFromCPPMacros.
There was a problem hiding this comment.
Some packages (e.g. pycrypto) do already have SOURCE_DATE_EPOCH defined, though it would be preferable to do this globally.
There was a problem hiding this comment.
There is
nixpkgs/pkgs/stdenv/generic/setup.sh
Lines 244 to 249 in 33b9aa4
There was a problem hiding this comment.
But why we need these macros then, when the environment variable is already exported?
There was a problem hiding this comment.
If a packages ignores environment variables, we are likely detecting this because cc wrapper will also not find libraries and headers.
There was a problem hiding this comment.
I suppose since the SOURCE_DATE_EPOCH is only supported for gcc >=7.x, but not so for earlier versions, and so I have to modify it to be enabled only for early gcc's.
There was a problem hiding this comment.
mhm. Can this hit us somewhere else?
|
I don't think setting an invalid date is the right thing to do. We should use |
|
|
|
Wait, the early versions have already been patched as well, so this fix is obsolete: |
|
@rht I have updated my comment to reflect your investigation in this PR, thank you :) |
Extracted from 3dba999.
See #2281. This is the gcc stuff in the list made by @Ekleog in #2281 (comment), excluding the PGO commit.
Motivation for this change
Things done
sandboxinnix.confon non-NixOS)nix-shell -p nox --run "nox-review wip"./result/bin/)nix path-info -Sbefore and after)