pijul_org / pijul

#391 Statically linking pijul

Opened by glehmann, on May 8, 2019
glehmann commented on May 8, 2019


I had quite a lot of problems to build pijul on my unbuntu 18.04, and I wonder if you would accept to distribute statically linked binaries for linux? That would require some changes in some dependent crates (like nettle or thrussh), so I wouldn't try it unless I know you are willing to distribute the binaries :)

Here is a first try in a docker container, that statically link libssl:

FROM buildpack-deps:buster

ENV RUSTUP_HOME=/usr/local/rustup \
    CARGO_HOME=/usr/local/cargo \

RUN set -eux; \
    url="https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init"; \
    wget "$url"; \
    chmod +x rustup-init; \
    ./rustup-init -y --no-modify-path --default-toolchain nightly; \
    rm rustup-init; \
    chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
    rustup --version; \
    cargo --version; \
    rustc --version;

ARG DEBIAN_FRONTEND=noninteractive
RUN echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/99extraRetries \
    && apt-get update \
	&& apt-get install -y --no-install-recommends \
       libsodium-dev \
       nettle-dev \
	   llvm-dev \
	   libclang-dev \
	   clang \
	&& apt-get clean

CMD env OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu OPENSSL_INCLUDE_DIR=/usr/include  OPENSSL_STATIC=yes cargo build --release

it is used this way, in pijul root source dir:

docker run --rm -v $PWD:/src -u $(id -u):$(id -g) $(docker build -q .)
pmeunier commented on May 8, 2019

I'm totally willing to distribute them, and even more willing to accept contributions in the form of the maintenance of these binaries each time we release a new version ;-)

pmeunier added tag
on June 26, 2019