build: support SOURCE_DATE_EPOCH for reproducible build
PATCH 1/1 build: support SOURCE_DATE_EPOCH for reproducible build
Including build timestamps in artifacts makes it harder to reproducibly build them.
Allow to overwrite build timestamp MAKE_STAMP by setting the SOURCE_DATE_EPOCH environment variable.
More details on SOURCE_DATE_EPOCH and reproducible builds:
https://reproducible-builds.org/docs/source-date-epoch/
--- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configure.ac +1 -1
@@ -165,7 +165,7 @@ AC_CONFIG_COMMANDS([nftversion.h], [ ]) # Current date should be fetched exactly once per build, # so have 'make' call date and pass the value to every 'gcc' call -AC_SUBST([MAKE_STAMP], ["\$(shell date +%s)"]) +AC_SUBST([MAKE_STAMP], ["\$(shell printenv SOURCE_DATE_EPOCH || date +%s)"]) AC_ARG_ENABLE([distcheck], AS_HELP_STRING([--enable-distcheck], [Build for distcheck]),
Signature · 1 line
2.52.0
Quoted 22 lines · Philipp Bartsch
Including build timestamps in artifacts makes it harder to reproducibly build them.
Allow to overwrite build timestamp
MAKE_STAMPby setting theSOURCE_DATE_EPOCHenvironment variable.More details on
SOURCE_DATE_EPOCHand reproducible builds:
https://reproducible-builds.org/docs/source-date-epoch/Fixes 64c07e38f049 ("table: Embed creating nft version into userdata")Reported-by Arnout Engelen <[email protected]>Signed-off-by Philipp Bartsch <[email protected]>--- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)configure.ac +0
-0
configure.ac AC_CONFIG_COMMANDS([nftversion.h], [ · line 171
Quoted 8 lines
configure.ac +1
-1@@ -165,7 +165,7 @@ AC_CONFIG_COMMANDS([nftversion.h], [ ]) # Current date should be fetched exactly once per build, # so have 'make' call date and pass the value to every 'gcc' call -AC_SUBST([MAKE_STAMP], ["\$(shell date +%s)"]) +AC_SUBST([MAKE_STAMP], ["\$(shell printenv SOURCE_DATE_EPOCH || date +%s)"]) AC_ARG_ENABLE([distcheck], AS_HELP_STRING([--enable-distcheck], [Build for distcheck]),
Apart from the reproducibility problem, the original code doesn't actual do what the comment says. date is called every time a file is compiled. Here are the first and last half-dozen time-stamps snipped from a recent build:
-DMAKE_STAMP=1769185524 -DMAKE_STAMP=1769185524 -DMAKE_STAMP=1769185524 -DMAKE_STAMP=1769185524 -DMAKE_STAMP=1769185525 -DMAKE_STAMP=1769185525 ... -DMAKE_STAMP=1769185536 -DMAKE_STAMP=1769185536 -DMAKE_STAMP=1769185539 -DMAKE_STAMP=1769185539 -DMAKE_STAMP=1769185540 -DMAKE_STAMP=1769185540
Generating one time-stamp in the Makefile is a pain in backside. I have come up with a way to do it, but it's fiddly. Florian, Phil, would it suffice to generate the time-stamp in configure?
J.
Pablo Neira Ayuso
maintainerCc'ing Phil.
Quoted 51 lines · Jeremy Sowden
Quoted 22 lines · Philipp Bartsch
Including build timestamps in artifacts makes it harder to reproducibly build them.
Allow to overwrite build timestamp
MAKE_STAMPby setting theSOURCE_DATE_EPOCHenvironment variable.More details on
SOURCE_DATE_EPOCHand reproducible builds:
https://reproducible-builds.org/docs/source-date-epoch/Fixes 64c07e38f049 ("table: Embed creating nft version into userdata")Reported-by Arnout Engelen <[email protected]>Signed-off-by Philipp Bartsch <[email protected]>--- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)configure.ac +0
-0configure.ac AC_CONFIG_COMMANDS([nftversion.h], [ · line 171
Quoted 8 lines
configure.ac +1
-1@@ -165,7 +165,7 @@ AC_CONFIG_COMMANDS([nftversion.h], [ ]) # Current date should be fetched exactly once per build, # so have 'make' call date and pass the value to every 'gcc' call -AC_SUBST([MAKE_STAMP], ["\$(shell date +%s)"]) +AC_SUBST([MAKE_STAMP], ["\$(shell printenv SOURCE_DATE_EPOCH || date +%s)"]) AC_ARG_ENABLE([distcheck], AS_HELP_STRING([--enable-distcheck], [Build for distcheck]),Apart from the reproducibility problem, the original code doesn't actual do what the comment says.
dateis called every time a file is compiled. Here are the first and last half-dozen time-stamps snipped from a recent build:-DMAKE_STAMP=1769185524 -DMAKE_STAMP=1769185524 -DMAKE_STAMP=1769185524 -DMAKE_STAMP=1769185524 -DMAKE_STAMP=1769185525 -DMAKE_STAMP=1769185525 ... -DMAKE_STAMP=1769185536 -DMAKE_STAMP=1769185536 -DMAKE_STAMP=1769185539 -DMAKE_STAMP=1769185539 -DMAKE_STAMP=1769185540 -DMAKE_STAMP=1769185540
Quoted 3 lines
Generating one time-stamp in the
Makefileis a pain in backside. I have come up with a way to do it, but it's fiddly. Florian, Phil, would it suffice to generate the time-stamp in configure?
Due to this issue, I can also see bogus:
# Warning: table ip x was created by a newer version of nftables? Content may be incomplete!
with partial recompilations while developing on nftables, it is a bit annoying because I have to: make clean and compile again. This occasionally triggers spurious tests failures here for that reason.
Quoted 1 line · Pablo Neira Ayuso
Cc'ing Phil.
Thanks!
Quoted 8 lines · Jeremy Sowden
Quoted 7 lines · Philipp Bartsch
Quoted 6 lines
Including build timestamps in artifacts makes it harder to reproducibly build them.
Allow to overwrite build timestamp
MAKE_STAMPby setting theSOURCE_DATE_EPOCHenvironment variable.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
More details on
SOURCE_DATE_EPOCHand reproducible builds:
https://reproducible-builds.org/docs/source-date-epoch/Fixes 64c07e38f049 ("table: Embed creating nft version into userdata")Reported-by Arnout Engelen <[email protected]>Signed-off-by Philipp Bartsch <[email protected]>
Quoted 23 lines
Quoted 23 lines
Quoted 9 lines
--- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)configure.ac +0
-0configure.ac AC_CONFIG_COMMANDS([nftversion.h], [ · line 171
Quoted 8 lines
configure.ac +1
-1@@ -165,7 +165,7 @@ AC_CONFIG_COMMANDS([nftversion.h], [ ]) # Current date should be fetched exactly once per build, # so have 'make' call date and pass the value to every 'gcc' call -AC_SUBST([MAKE_STAMP], ["\$(shell date +%s)"]) +AC_SUBST([MAKE_STAMP], ["\$(shell printenv SOURCE_DATE_EPOCH || date +%s)"]) AC_ARG_ENABLE([distcheck], AS_HELP_STRING([--enable-distcheck], [Build for distcheck]),Apart from the reproducibility problem, the original code doesn't actual do what the comment says.
dateis called every time a file is compiled. Here are the first and last half-dozen time-stamps snipped from a recent build:
Quoted 13 lines
Quoted 5 lines
-DMAKE_STAMP=1769185524 -DMAKE_STAMP=1769185524 -DMAKE_STAMP=1769185524 -DMAKE_STAMP=1769185524 -DMAKE_STAMP=1769185525Quoted 8 lines
-DMAKE_STAMP=1769185525 ... -DMAKE_STAMP=1769185536 -DMAKE_STAMP=1769185536 -DMAKE_STAMP=1769185539 -DMAKE_STAMP=1769185539 -DMAKE_STAMP=1769185540 -DMAKE_STAMP=1769185540
Ugh, that's indeed a bug.
Quoted 3 lines
Quoted 3 lines
Generating one time-stamp in the
Makefileis a pain in backside. I have come up with a way to do it, but it's fiddly. Florian, Phil, would it suffice to generate the time-stamp in configure?
I deliberately chose a build timestamp, not a configure one. In most cases it won't matter, but since one could defeat the stamp by recompiling after making changes without calling configure.
Quoted 7 lines
Due to this issue, I can also see bogus:
# Warning: table ip x was created by a newer version of nftables? Content may be incomplete!
with partial recompilations while developing on nftables, it is a bit annoying because I have to: make clean and compile again. This occasionally triggers spurious tests failures here for that reason.
Requesting simple expansion by assigning to MAKE_STAMP using ':=' operator fixes the value throughout one build, but partial recompiling still leads to objects compiled with different MAKE_STAMP values.
Looks like nftbuildstamp should reside in an object file which is forced to recompile each time. MAKE_STAMP being consumed by a single object also mitigates the recursive expansion. WDYT? Am I missing a detail?
Thanks, Phil
Florian Westphal
maintainerQuoted 7 lines · Phil Sutter
Quoted 3 lines
Quoted 3 lines
Generating one time-stamp in the
Makefileis a pain in backside. I have come up with a way to do it, but it's fiddly. Florian, Phil, would it suffice to generate the time-stamp in configure?I deliberately chose a build timestamp, not a configure one. In most cases it won't matter, but since one could defeat the stamp by recompiling after making changes without calling configure.
I don't think thats a concern. This is geared towards official releases only (and catching possible issues on update path on real deployments, not deveopment workstation).
So I vote for configure-time.
Quoted 5 lines · Florian Westphal
Quoted 4 lines · Phil Sutter
Quoted 3 lines
Quoted 3 lines
Generating one time-stamp in the
Makefileis a pain in backside. I have come up with a way to do it, but it's fiddly. Florian, Phil, would it suffice to generate the time-stamp in configure?
Quoted 7 lines
Quoted 3 lines
I deliberately chose a build timestamp, not a configure one. In most cases it won't matter, but since one could defeat the stamp by recompiling after making changes without calling configure.
I don't think thats a concern. This is geared towards official releases only (and catching possible issues on update path on real deployments, not deveopment workstation).
This is my thinking.
Quoted 1 line
So I vote for configure-time.
J.