tectonic-typesetting / tectonic

A modernized, complete, self-contained TeX/LaTeX engine, powered by XeTeX and TeXLive.
https://tectonic-typesetting.github.io/
Other
3.92k stars 161 forks source link

Distribute a static build #185

Closed malbarbo closed 3 years ago

malbarbo commented 6 years ago

I know what you're thinking: it's easier said than done!

But I did it! I built a static version of tectonic! It toke a lot of time, but the final patches are really small.

I used the following docker alpine container to do the build:

FROM alpine:edge

RUN apk update && \
    apk upgrade && \
    apk add \
        g++ \
        git \
        rust \
        cargo \
        fontconfig-dev \
        freetype-static \
        glib-static \
        graphite2-dev \
        graphite2-static \
        harfbuzz-dev \
        harfbuzz-static \
        icu-dev \
        icu-static \
        openssl-dev \
        zlib-dev

ENV TECTONIC_STATIC=1
ENV PKG_CONFIG_ALL_STATIC=1
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
ENV RUSTFLAGS="-C target-feature=+crt-static"

RUN mkdir /out/

CMD git clone https://github.com/malbarbo/tectonic --branch static && \
    cd tectonic && \
    sed -i -e 's/AES_cbc_encrypt/AES_cbc_encrypt2/g' \
              ./tectonic/dpx-dpxcrypt.h \
              ./tectonic/dpx-pdfencrypt.c \
              ./tectonic/dpx-dpxcrypt.c && \
    cargo build --release && \
    cp target/release/tectonic /out/
docker build . -t tectonic
docker run -v $(pwd):/out tectonic

The image install the requirements including static version of the libs.

The env vars indicates to tectonic, pkg-config and openssl packages and rustc to do a static build.

The rename of AES_cbc_encrypt to AES_cbc_encrypt2 is to avoid duplicate symbol between tectonic and openssl.

The following changes to tectonic are needed:

I can no longer work on it, but I would be glad if anyone could move on from here and add a static builder to travis.

malbarbo commented 6 years ago

For the curious, the static build have 50MB and 35MB stripped.

pkgw commented 6 years ago

Cool, and thanks for sharing! I will think about how to make this available. I am more than happy to accept PRs to integrate some of the changes needed here, but if you can't spend any more time on this, I understand.

pkgw commented 5 years ago

An update: I've upgraded the Travis infrastructure so that it is a bit more thinkable to generate static binaries on CI and upload them to GitHub releases — see the new driver script for some context.

ghost commented 5 years ago

This looks great! @malbarbo have you been able to work on this with the new driver script @pkgw mentioned? If not I can help complete this task.

malbarbo commented 5 years ago

@efx it would be great if you could complete the task!

ghost commented 5 years ago

I also noticed the work in #420 which could be applicable as well; as I get some "free time" I'll investigate that work compared with the above approach.

malbarbo commented 3 years ago

Now we have a static build! Thanks @pkgw.