Skip to content
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

Fix reproducibility issues #187

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ m4_define([TOOL_DISABLE_NO],
TOOL_PARAMETERS($1,$2,$3)
])

echo "# Build with FreeFEM with ./configure " `date` >$ff_where_lib_conf
DATE_FMT="+%Y-%m-%d"
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date +%s)}"
BUILD_DATE=$(date -u -d "@$SOURCE_DATE_EPOCH" "$DATE_FMT" 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" "$DATE_FMT" 2>/dev/null || date -u "$DATE_FMT")```
prj- marked this conversation as resolved.
Show resolved Hide resolved

echo "# Build with FreeFEM with ./configure $BUILD_DATE" >$ff_where_lib_conf
# To allow anonymous CVS version to contain a "./configure" and
# Makefiles

Expand Down Expand Up @@ -679,7 +683,7 @@ ff_prefix_dir="${prefix}/lib/ff++/$VERSION"
AC_MSG_CHECKING(prefix dir freefem++ )
AC_MSG_RESULT($ff_prefix_dir)

FF_DATE=`date`
FF_DATE="$BUILD_DATE"
AC_DEFINE_UNQUOTED(VersionFreeFemDate,"$FF_DATE",FreeFEM build date)
AC_DEFINE_UNQUOTED(FF_PREFIX_DIR,"${ff_prefix_dir}",FreeFem prefix dir)
AC_SUBST(ff_prefix_dir,$ff_prefix_dir)
Expand Down
2 changes: 1 addition & 1 deletion examples/3d/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ EXTRA_DIST = *.edp \

all.edp: Makefile
(echo "NoGraphicWindow=true;NoUseOfWait=true;int verbosityy=verbosity;int MEM1234=storageused();"; \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$'` ; do \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$' | LC_ALL=C sort` ; do \
echo ' cout << "--------- file : '$$i' --------------------------------------------------------" << endl;' ;\
echo "verbosity=verbosityy;searchMethod=0;" ; \
echo \{ include \"$$i\"\;\}\; ;\
Expand Down
2 changes: 1 addition & 1 deletion examples/3dCurve/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ EXTRA_DIST = *.edp all.edp

all.edp: Makefile
(echo "NoGraphicWindow=true;NoUseOfWait=true;int verbosityy=verbosity;int MEM1234=storageused();"; \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$'` ; do \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$' | LC_ALL=C sort` ; do \
echo ' cout << "--------- file : '$$i' --------------------------------------------------------" << endl;' ;\
echo "verbosity=verbosityy;searchMethod=0;" ; \
echo \{ include \"$$i\"\;\}\; ;\
Expand Down
2 changes: 1 addition & 1 deletion examples/3dSurf/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ EXTRA_DIST = *.edp all.edp

all.edp: Makefile
(echo "NoGraphicWindow=true;NoUseOfWait=true;int verbosityy=verbosity;int MEM1234=storageused();"; \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$'` ; do \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$' | LC_ALL=C sort` ; do \
echo ' cout << "--------- file : '$$i' --------------------------------------------------------" << endl;' ;\
echo "verbosity=verbosityy;searchMethod=0;" ; \
echo \{ include \"$$i\"\;\}\; ;\
Expand Down
2 changes: 1 addition & 1 deletion examples/eigen/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ EXTRA_DIST = *.edp all.edp

all.edp:
(echo "NoUseOfWait=true;int verbosityy=verbosity;"; \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$'` ; do \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$' | LC_ALL=C sort` ; do \
echo ' cout << "--------- file : '$$i' --------------------------------------------------------" << endl;' ;\
echo "verbosity=verbosityy;" ; \
echo \{ include \"$$i\"\;\}\; ;\
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ EXTRA_DIST = *.edp all.edp regtests.edp regtests.m4 ref.edp

all.edp:
(echo "NoUseOfWait=true;int verbosityy=verbosity;"; \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$'` ; do \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$' | LC_ALL=C sort` ; do \
echo ' cout << "--------- file : '$$i' --------------------------------------------------------" << endl;' ;\
echo "verbosity=verbosityy;" ; \
echo \{ include \"$$i\"\;\}\; ;\
Expand Down
2 changes: 1 addition & 1 deletion examples/misc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ EXTRA_DIST=*.edp all.edp regtests.edp regtests.m4 ref.edp torture.msh speedtest.

all.edp:
(echo "NoUseOfWait=true;int verbosityy=verbosity;"; \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$'` ; do \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$' | LC_ALL=C sort` ; do \
echo ' cout << "--------- file : '$$i' --------------------------------------------------------" << endl;' ;\
echo "verbosity=verbosityy;" ; \
echo \{ include \"$$i\"\;\}\; ;\
Expand Down
2 changes: 1 addition & 1 deletion examples/plugin/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ all.edp:
mkdir o
@test -f ../../src/bin-win32/FreeFem++.exe && ffpp=../../src/bin-win32/FreeFem++.exe || ffpp=../../src/nw/FreeFem++; \
(echo "NoGraphicWindow=true;NoUseOfWait=true;int verbosityy=verbosity;"; \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$'` ; do \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$' | LC_ALL=C sort` ; do \
if $$ffpp -ns -jc -v 0 $$i 1>/dev/null 2>/dev/null ; then \
echo ' cout << "--------- file : '$$i' --------------------------------------------------------" << endl;' ;\
echo "verbosity=verbosityy;" ; \
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ EXTRA_DIST=*.edp aile.msh xyf all.edp regtests.edp regtests.m4 ref.edp

all.edp:
(echo "NoUseOfWait=true;int verbosityy=verbosity;"; \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$'` ; do \
for i in *`ls *.edp|grep -v -E '^(all|regtests|makeref|ref)\.edp$$' | LC_ALL=C sort` ; do \
echo ' cout << "--------- file : '$$i' --------------------------------------------------------" << endl;' ;\
echo "verbosity=verbosityy;" ; \
echo \{ include \"$$i\"\;\}\; ;\
Expand Down
3 changes: 2 additions & 1 deletion src/fflib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ endif
# Build date changes at every change
EXTRA_DIST=strversionnumber.m4
BUILT_SOURCES=strversionnumber.cpp
BUILD_DATE="$(date --utc --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y-%m-%d)"
strversionnumber.cpp: $(libff_a_SOURCES2) ../../Makefile
m4 -DVersionFreeFemDate="`date`" -DGitVersion="`git describe --tags 2>/dev/null|| echo 'no git'`" strversionnumber.m4 > $@
m4 -DVersionFreeFemDate="$(BUILD_DATE)" -DGitVersion="`git describe --tags 2>/dev/null|| echo 'no git'`" strversionnumber.m4 > $@
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not work on even on Debian.

$ make strversionnumber.cpp
m4 -DVersionFreeFemDate="""" -DGitVersion="`git describe --tags 2>/dev/null|| echo 'no git'`" strversionnumber.m4 > strversionnumber.cpp

Any suggestion @mzf-guest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed! This code does not work when SOURCE_DATE_EPOCH is not defined by the build chain. Good catch! and sorry the miss.

The Makefile example from this page seems to work better, at least in a minimal test. But I can't make it work from the Makefile.am file. When running autoreconf -i, the ifeq is recognized as a AM command instead of copying it verbatim in the Makefile.

DATE_FMT = +%Y-%m-%d
ifdef SOURCE_DATE_EPOCH
    BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u "$(DATE_FMT)")
else
    BUILD_DATE ?= $(shell date "$(DATE_FMT)")
endif

Unfortunately, I'm not very skilled with autotools. Do you have any hints?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahah, no, I faced the exact same issue. Maybe this should be put a static makefile, like Makefile.date. And then we'd replace date by make -f Makefile.date date with

$ cat Makefile.date
DATE_FMT = +%Y-%m-%d
ifdef SOURCE_DATE_EPOCH
    BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u "$(DATE_FMT)")
else
    BUILD_DATE ?= $(shell date "$(DATE_FMT)")
endif

date:
    echo $(BUILD_DATE)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any update about this @mzf-guest?

FORCE:
3 changes: 2 additions & 1 deletion src/medit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ ffmedit_SOURCES=animat.c cube.c image.c listnum.c mouse.c persp.c stream.c zaldy
LDADD=picking.$(OBJEXT) ../libMesh/libMesh.a $(LIBSGLUT) -lm
AM_CPPFLAGS=-I$(srcdir)/../libMesh
BUILT_SOURCES=compil.date
BUILD_DATE="$(date --utc --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y-%m-%d)"
compil.date: $(ffmedit_SOURCES)
echo "#define COMPIL " '"' `date` '(with ff++ $(VERSION))''"' > compil.date
echo "#define COMPIL " '"' $(BUILD_DATE) '(with ff++ $(VERSION))''"' > compil.date
#.PHONY: compil.date

# ALH - during a parallel make, we should make sure that picking.o is not used before being made by a different
Expand Down