fix partial updates to libgray.a when using Nix

When building the static library the Nixpkgs stdenv `ar` defaults to not
writing timestamps for the members file. This imply make will always try
to add all members to the archive, which defeats the purpose of the
file-level granularity.
This commit is contained in:
Michele Guerini Rocco 2023-10-13 13:58:47 +02:00
parent 95d398d503
commit c889c754f7
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450
3 changed files with 16 additions and 1 deletions

View File

@ -69,6 +69,13 @@ LD = gfortran
FFLAGS += -J$(OBJDIR) -I$(INCDIR) -ffree-line-length-none -fPIC FFLAGS += -J$(OBJDIR) -I$(INCDIR) -ffree-line-length-none -fPIC
CPPFLAGS += -DREVISION=\"$(GIT_REV)$(GIT_DIRTY)\" -DPREFIX=\"$(PREFIX)\" CPPFLAGS += -DREVISION=\"$(GIT_REV)$(GIT_DIRTY)\" -DPREFIX=\"$(PREFIX)\"
ifndef DETERMINISTIC
ifdef AR_DEFAULT_DETERMINISTIC
# Write timestamps to allow partial updates
ARFLAGS = crU
endif
endif
# Static build options # Static build options
ifdef STATIC ifdef STATIC
LIBRARIES := $(LIBRARIES:so=a) LIBRARIES := $(LIBRARIES:so=a)
@ -109,7 +116,7 @@ install: $(BINARIES) $(LIBRARIES) $(SHAREDIR)/doc $(SHAREDIR)/gray.1
$(OBJDIR)/%.o: $(OBJDIR)/%.d $(OBJDIR)/%.o: $(OBJDIR)/%.d
# GRAY binary # GRAY binary
$(GRAY): $(shell ./depend $(OBJDIR)/main.o) | $(BINDIR) $(GRAY): $(OBJDIR)/main.o $(LIBGRAY).a | $(BINDIR)
$(LD) $(LDFLAGS) -o '$@' $^ $(LD) $(LDFLAGS) -o '$@' $^
# GRAY shared library # GRAY shared library

7
configure vendored
View File

@ -15,6 +15,7 @@ Options:
--prefix=PREFIX install files in PREFIX [/usr/local] --prefix=PREFIX install files in PREFIX [/usr/local]
--enable-static statically link programs and libraries [no] --enable-static statically link programs and libraries [no]
--disable-static dynamically link programs and libraries [yes] --disable-static dynamically link programs and libraries [yes]
--enable-deterministic try to make a bit-for-bit deterministic build [no]
--with-katex=PATH specify path to the KaTeX library [automatically downloaded] --with-katex=PATH specify path to the KaTeX library [automatically downloaded]
EOF EOF
} }
@ -40,6 +41,7 @@ for arg in "$@"; do
;; ;;
--enable-static) printf 'STATIC=1\n' >> configure.mk ;; --enable-static) printf 'STATIC=1\n' >> configure.mk ;;
--disable-static) ;; --disable-static) ;;
--enable-deterministic) printf 'DETERMINISTIC=1\n' >> configure.mk ;;
--with-katex=*) printf 'KATEX_URL==file://%s/\n' "${arg#*=}" >> configure.mk ;; --with-katex=*) printf 'KATEX_URL==file://%s/\n' "${arg#*=}" >> configure.mk ;;
*=*) *=*)
printf '%s\n' "${arg?}" >> configure.mk printf '%s\n' "${arg?}" >> configure.mk
@ -79,3 +81,8 @@ if [ $? -ne 0 ]; then
fi fi
printf 'using %s as Fortran compiler\n' "$FC" printf 'using %s as Fortran compiler\n' "$FC"
printf '%s=%s\n' FC "$FC" >> configure.mk printf '%s=%s\n' FC "$FC" >> configure.mk
# Check whether ar is deterministic by default
if ar h | grep -q '\[D\].*(default)' 2>/dev/null; then
printf 'AR_DEFAULT_DETERMINISTIC=1\n' >> configure.mk
fi

View File

@ -59,6 +59,7 @@ in
configureFlags = [ configureFlags = [
(lib.enableFeature static "static") (lib.enableFeature static "static")
"--with-katex=${katex}" "--with-katex=${katex}"
"--enable-deterministic"
"GIT_REV=${version}" "GIT_REV=${version}"
"GIT_DIRTY=" "GIT_DIRTY="
]; ];