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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

TikZ not working on arm64 #1662

Open
felixvanoost opened this issue Oct 25, 2023 · 8 comments
Open

TikZ not working on arm64 #1662

felixvanoost opened this issue Oct 25, 2023 · 8 comments

Comments

@felixvanoost
Copy link
Contributor

TikZ returns an Exec format error (exit code 126) when running on arm64. I thought I had checked all the libraries before opening #1487, but this doesn't seem to have been the case... 馃槄

After some digging I realised that the kroki-builder-dvisvgm stage doesn't install the correct cross-compiler tools to actually build the arm64 binary from an amd64 host. From v0.23.0, platform=arm64, we can see that the binary type is always x86-64:

/usr/bin/dvisvgm: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=82a54975c5565c66b9eb969f1656f7aea2b1afd1, for GNU/Linux 3.2.0, with debug_info, not stripped

This issue hasn't shown up in CI because the workflows only use native builds that don't require cross-compilation. There are 3 ways to resolve this:

  1. Attempt to fix cross-compilation. I've already spent some time on this, but I haven't been able to make it work yet. There are 4 possible uses cases to handle as well, making it quite messy.
  2. Revert to QEMU. Go back to using emulation for the kroki-builder-dvisvgm stage, which produces the correct result but takes forever to build. This wouldn't affect the CI normally because they're all running natively, but it would make the release workflow take much longer than it currently does.
  3. Build dvisvgm binaries in a separate Yuzutech repo. This could be done with the native Arm runner.

I can work on a fix for either 1 or 2 if needed.

@felixvanoost
Copy link
Contributor Author

@ggrossetie any thoughts on the preferred approach?

@ggrossetie
Copy link
Member

Hey!
I think we should opt for the 3rd solution. I already have an ARM64 runner so I can configure it to build the dvisvgm binary.

@felixvanoost
Copy link
Contributor Author

@ggrossetie I saw the announcement a couple of months ago; would you consider joining the beta? Looks like it's only available to business accounts for now.

Is there anything I can do suport this issue?

@ggrossetie
Copy link
Member

I saw the announcement a couple of months ago; would you consider joining the beta? Looks like it's only available to business accounts for now.

I thought it was GA :/
@felixvanoost Do you have a repository that build dvisvgm binaries? If so, we can move it to the yuzutech organization and I can setup a build on my ARM64 runner.

@felixvanoost
Copy link
Contributor Author

felixvanoost commented Apr 6, 2024

@ggrossetie I don't have one currently but can create one if it helps. The kroki-builder-dvisvgm code in the existing Dockerfile works for both amd64 and arm64 as long as each binary is built using the same build and target architecture. The part that isn't working is cross-compilation.

FROM --platform=$BUILDPLATFORM ubuntu:jammy AS kroki-builder-dvisvgm

RUN apt-get update && apt-get install --no-install-recommends --yes \
    build-essential \
    pkg-config \
    libclipper-dev \
    libfreetype-dev \
    libkpathsea-dev \
    ghostscript \
    libssl-dev \
    zlib1g-dev \
    curl \
    ca-certificates

ARG DVISVGM_VERSION=3.0.4

ARG BUILDARCH
ARG TARGETARCH
RUN curl -LO https://github.com/mgieseki/dvisvgm/releases/download/$DVISVGM_VERSION/dvisvgm-$DVISVGM_VERSION.tar.gz && \
    tar xf dvisvgm-$DVISVGM_VERSION.tar.gz && \
    cd dvisvgm-$DVISVGM_VERSION && \
    case $BUILDARCH in \
        "amd64") MAKE_BUILD_ARCH=x86_64 ;; \
        "arm64") MAKE_BUILD_ARCH=aarch64 ;; \
        *) MAKE_BUILD_ARCH=$BUILDARCH ;; \
    esac && \
    case $TARGETARCH in \
        "amd64") MAKE_TARGET_ARCH=x86_64 ;; \
        "arm64") MAKE_TARGET_ARCH=aarch64 ;; \
        *) MAKE_TARGET_ARCH=$TARGETARCH ;; \
    esac && \
    ./configure --enable-bundled-libs --build $MAKE_BUILD_ARCH-linux-gnu --host $MAKE_TARGET_ARCH-linux-gnu && \
    make && \
    make install

In short, you should be able to copy this code directly to a new repo and set up a workflow that builds one dvisvgm binary on an arm64 host and the other on an amd64 host.

We know this will work because the Kroki nightly CI worflow that runs on an arm64 host builds and passes all the tests without issues. This is also why I didn't catch the issue earlier, because the main and nightly workflows run on native hosts but the release workflow cross-compiles to arm64 from an amd64 host.

@felixvanoost
Copy link
Contributor Author

felixvanoost commented Apr 6, 2024

Update: It turns out that up-to-date dvisvgm binaries are available via apt for Ubuntu 24.04 (Noble), which will become the new LTS release in about 3 weeks:

https://packages.ubuntu.com/noble/dvisvgm

I can open a PR for the change once an updated version of the eclipse-temurin image is released.

@ggrossetie
Copy link
Member

Yes that would be awesome, thanks 馃憤馃徎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants