Subject: bug#48064: [PATCH core-updates] build-system/texlive: Change default format to pdftex

From: Thiago Jung Bauermann <[email-masked]>
Date: Fri, 2 Jul 2021 13:00:10 -0300

LuaTeX has a bug where sometimes it corrupts the heap and aborts. This
causes the build of texlive packages to fail at random. The problem is
being tracked at https://issues.guix.gnu.org/48064.

While a fix isn't found, switch the default TeX format (and consequently
also the engine) to pdftex to avoid the issue.

* guix/build-system/texlive.scm (texlive-build): Change default value of
the ‘tex-format’ key parameter to “pdftex”.
---
 guix/build-system/texlive.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Hello,

Originally I had a bigger patch which changed packages individually to
build with pdfTeX, because I thought the bug in LuaTeX was triggered only
by specific packages. As I changed more and more packages though, I
realized that any package can trigger the problem and the heap corruption
happens at random.

Therefore, to work around the LuaTeX bug we need to build all packages with
pdfTeX. I tested the patch with this script:

--8<---------------cut here---------------start------------->8---
#!/bin/bash

set -e

LOG_FILE="$1"
ROUNDS=$2

function verify_package() {
    local package="$1"
    local log_file="$2"

    if ! guix build "$package"; then
        echo "failure while building $package" >> "$log_file"
        return
    fi

    echo "success while building $package" >> "$log_file"

    if ! guix build --check --rounds=$ROUNDS "$package"; then
        echo "failure while checking $package" >> "$log_file"
        return
    fi

    echo "success while checking $package" >> "$log_file"

    return
}

guix describe >> "$LOG_FILE"
echo rounds = "$ROUNDS" >> "$LOG_FILE"
echo >> "$LOG_FILE"

for package in $(guix package --list-available='^texlive' | cut -f1)
do
    verify_package $package "$LOG_FILE"
done
--8<---------------cut here---------------end--------------->8---

and called it with `./verify-texlive-packages.sh verify-packages.log 5`.

I see some packages fail during `guix build --check` because they don't
build deterministically for some reason (which is a separate problem), but
I don't see any package failing to build anymore.

diff --git a/guix/build-system/texlive.scm b/guix/build-system/texlive.scm
index 0efa139fc124..00a36d5862d4 100644
--- a/guix/build-system/texlive.scm
+++ b/guix/build-system/texlive.scm
@@ -128,7 +128,7 @@ level package ID."
                         (tests? #f)
                         tex-directory
                         (build-targets #f)
-                        (tex-format "luatex")
+                        (tex-format "pdftex")
                         (phases '(@ (guix build texlive-build-system)
                                     %standard-phases))
                         (outputs '("out"))