all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Sarah Morgensen via Guix-patches via <guix-patches@gnu.org>
To: 49107@debbugs.gnu.org
Subject: [bug#49107] [PATCH core-updates] gnu: fontconfig: Use (locally) deterministic caching
Date: Fri, 18 Jun 2021 17:52:05 -0700	[thread overview]
Message-ID: <d2647ed721b9f12b1267427409455e385ffaa12d.1624063731.git.iskarian@mgsn.dev> (raw)

Make fontconfig use directory contents rather than modification time to
determine cache validity (by pretending that mtime is broken).

* gnu/packages/patches/fontconfig-cache-ignore-mtime.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/fontutils.scm (fontconfig)[source]: Use it.
[arguments]: Unset SOURCE_DATE_EPOCH for tests.
---
 gnu/local.mk                                      |  1 +
 gnu/packages/fontutils.scm                        |  7 ++++++-
 .../patches/fontconfig-cache-ignore-mtime.patch   | 15 +++++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/fontconfig-cache-ignore-mtime.patch

Hello Guix,

This patch attempts to make fontconfig's caching work seamlessly on Guix,
instead of requiring users to manually run `fc-cache -f` after installing or
removing fonts. This addresses <https://issues.guix.gnu.org/18640>.

Fontconfig usually uses a directory's mtime as its checksum. However, when
fontconfig detects a "broken mtime" filesystem, it will generate a directory
checksum from the directory listing contents. This is slightly slower, as it has
to stat all the files in all font directories. Unconditionally enabling this
mode should get us more regular behavior.

I am not confident this method is fully deterministic; particular filesystem
capabilities may still be an implicit imput in the checksums. This should only
matter when distributing pre-generated caches.

Fontconfig does honor SOURCE_DATE_EPOCH, but without a reliable mtime,
fontconfig has no way of knowing when to update such a cache. SOURCE_DATE_EPOCH
is now disabled for the tests because they assume working cache invalidation.

I have tested this patch on x86-64.

diff --git a/gnu/local.mk b/gnu/local.mk
index c57e587e84..1d26c9e7c7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1012,6 +1012,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/fifo-map-remove-catch.hpp.patch		\
   %D%/packages/patches/findutils-localstatedir.patch		\
   %D%/packages/patches/flann-cmake-3.11.patch			\
+  %D%/packages/patches/fontconfig-cache-ignore-mtime.patch	\
   %D%/packages/patches/foobillard++-pkg-config.patch		\
   %D%/packages/patches/foomatic-filters-CVE-2015-8327.patch	\
   %D%/packages/patches/foomatic-filters-CVE-2015-8560.patch	\
diff --git a/gnu/packages/fontutils.scm b/gnu/packages/fontutils.scm
index dbce5beba8..0ee51a792e 100644
--- a/gnu/packages/fontutils.scm
+++ b/gnu/packages/fontutils.scm
@@ -14,6 +14,7 @@
 ;;; Copyright © 2020 Nicolas Goaziou <mail@nicolasgoaziou.fr>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2020, 2021 Nicolas Goaziou <mail@nicolasgoaziou.fr>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -331,7 +332,8 @@ Font Format (WOFF).")
                   "https://www.freedesktop.org/software/"
                   "fontconfig/release/fontconfig-" version ".tar.xz"))
             (sha256 (base32
-                     "1850q4k80yxma5g3yxkvyv8i5a3xqzswwml8gjy3jmywx8qqd5pa"))))
+                     "1850q4k80yxma5g3yxkvyv8i5a3xqzswwml8gjy3jmywx8qqd5pa"))
+             (patches (search-patches "fontconfig-cache-ignore-mtime.patch"))))
      (build-system gnu-build-system)
      ;; In Requires or Requires.private of fontconfig.pc.
      (propagated-inputs `(("expat" ,expat)
@@ -362,6 +364,9 @@ Font Format (WOFF).")
         (modify-phases %standard-phases
           (add-before 'check 'skip-problematic-tests
             (lambda _
+              ;; SOURCE_DATE_EPOCH doesn't make sense when ignoring mtime
+              (unsetenv "SOURCE_DATE_EPOCH")
+
               (substitute* "test/run-test.sh"
                 ;; The crbug1004254 test attempts to fetch fonts from the
                 ;; network.
diff --git a/gnu/packages/patches/fontconfig-cache-ignore-mtime.patch b/gnu/packages/patches/fontconfig-cache-ignore-mtime.patch
new file mode 100644
index 0000000000..b6e942ee10
--- /dev/null
+++ b/gnu/packages/patches/fontconfig-cache-ignore-mtime.patch
@@ -0,0 +1,15 @@
+Pretend that stat's mtime is broken, so that the fontconfig cache does not
+depend upon modification time to determine if a cache is stale.
+
+diff --git a/src/fcstat.c b/src/fcstat.c
+index 5a2bd7c..d603a96 100644
+--- a/src/fcstat.c
++++ b/src/fcstat.c
+@@ -431,6 +431,7 @@ FcIsFsMmapSafe (int fd)
+ FcBool
+ FcIsFsMtimeBroken (const FcChar8 *dir)
+ {
++    return FcTrue;
+     int fd = FcOpen ((const char *) dir, O_RDONLY);
+ 
+     if (fd != -1)

base-commit: bcdc13454c4afab37b650d4bbfa95e539060619f
-- 
2.31.1





             reply	other threads:[~2021-06-19  0:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-19  0:52 Sarah Morgensen via Guix-patches via [this message]
2021-07-07 21:16 ` [bug#49107] [PATCH core-updates] gnu: fontconfig: Use (locally) deterministic caching Ludovic Courtès
2021-07-08  1:17   ` Sarah Morgensen via Guix-patches via
2021-07-12  8:30     ` bug#49107: " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d2647ed721b9f12b1267427409455e385ffaa12d.1624063731.git.iskarian@mgsn.dev \
    --to=guix-patches@gnu.org \
    --cc=49107@debbugs.gnu.org \
    --cc=iskarian@mgsn.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.