New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Propagate shell environment variable SOURCE_DATE_EPOCH #4239
Conversation
for reproducible builds. https://reproducible-builds.org/specs/source-date-epoch/ says > Build processes MUST NOT unset this variable for child processes if it is already present. Without this patch, openSUSE's games/globulation2 builds varied from a .cpp file with __TIME__ that should be normalized by g++ as we set SOURCE_DATE_EPOCH. Signed-off-by: Bernhard M. Wiedemann <bwiedemann@suse.de>
|
scons uses this for its own build (see |
|
This would violate one of SCons's primary promises that the external environment doesn't impact the build. The way you've currently written it would ignore any instructions in the build system itself to set IMHO this should be fixed in games/globulation2's codebase (as @mwichmann pointed out we have such a fix, and in fact you provided that change to SCons' own build system). Thoughts? |
|
I think, the best would be to add it to exceptions. |
That's a concern for your build environment. We have to consider the effects of breaking SCons policy on propagating any shell environment variables without the build system explicitly requesting it. |
| @@ -1034,6 +1034,8 @@ def __init__( | |||
| # should override any values set by the tools. | |||
| for key, val in save.items(): | |||
| self._dict[key] = val | |||
| if 'SOURCE_DATE_EPOCH' in os.environ: | |||
| self._dict['ENV']['SOURCE_DATE_EPOCH'] = os.environ['SOURCE_DATE_EPOCH'] | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure that this is going to do what you expect. This will set a value in the construction environment, yes, but it still won't be passed on to gcc or whoever needs to be listening during builds. For that, it needs to be added to the Execution Environment (usually env['ENV']).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what worked in my tests (after 8 failed tries). I think, since this is Environment.py the self._dict['ENV'] here is env['ENV']
|
This should be a SCons built in command line option (at the very least) to turn on taking in the value from the environment. |
I tend to disagree there. |
|
Here's all you need to make this work without changing SCons at all. Create a directory: The save the following as Then as long as you have SOURCE_DATE_EPOCH defined in your shell, any build you build with SCons will propagate this. |
Could we also add that into a system python path under |
|
There is a predefined "system location", but it's not in the Python path: See https://scons.org/doc/production/HTML/scons-man.html#opt-site-dir |
|
@bmwiedemann - is this workable for your builds? |
|
So putting an extra file into |
|
The command line argument could work if you set
What's the best way to indicate to people who would use scons to build packages for distribution that such a file is available and how to use? Note:Besides you I don't think any other SCons user has ever enquired about SOURCE_DATE_EPOCH thus far.. |
|
@bmwiedemann @lamby @mwichmann |
|
Does anyone use the debian directory from our git repo? |
Debian doesn't.
Ideally by pinging the key distributions or by filing a wishlist bug against them (they only need to adjust build scripts to install it once, after all). Hopefully they would read the changelogs extremely carefully, but likely not. :) |
…ell environment to support reproducible builds. This is replacement logic for PR SCons#4239
|
Closing in favor of #4261 |
Contributor Checklist:
CHANGES.txt(and read theREADME.rst)This is a PoC patch to
Preserve
SOURCE_DATE_EPOCHfor reproducible builds.https://reproducible-builds.org/specs/source-date-epoch/ says
Without this patch, openSUSE's
games/globulation2builds varied from a .cpp file with__TIME__that should be normalized byg++as we setSOURCE_DATE_EPOCH.Signed-off-by: Bernhard M. Wiedemann
I am not familiar with the scons codebase, thus would appreciate help to get this improved.