From faafd21a91931211432eb0f01f86adea04496610 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Tue, 30 Apr 2024 21:54:48 +0200 Subject: [PATCH] build: Use zig for linux builds There was an issue with the build that is resolved when using zig. aarch64 binaries had a bug in libgit2 involving file access. --- build/Dockerfile | 16 ++++------------ build/config.toml | 6 ------ 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index 662767f4..cf01fd8f 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -7,7 +7,7 @@ COPY . . # Copy cargo configuration we're going to use to specify compiler options. RUN mkdir -p .cargo && cp build/config.toml .cargo/config.toml # Install dependencies. -RUN apk update && apk add --no-cache mold clang git musl-dev minisign curl xz asciidoctor +RUN apk update && apk add --no-cache git musl-dev minisign curl xz asciidoctor # Build man pages and strip metadata. Removes all comments, since they include # non-reproducible information, such as version numbers. RUN asciidoctor --doctype manpage --backend manpage --destination-dir . *.1.adoc && \ @@ -19,16 +19,6 @@ RUN rustup target add \ x86_64-apple-darwin \ aarch64-apple-darwin -# Linux x86_64 and aarch64 build. -ENV CC=clang C_INCLUDE_PATH=/usr/include/x86_64-linux-musl -RUN cargo build --locked --release \ - --target=x86_64-unknown-linux-musl \ - --target=aarch64-unknown-linux-musl \ - -p radicle-node \ - -p radicle-httpd \ - -p radicle-remote-helper \ - -p radicle-cli - # Install dependencies for cross-compiling to macOS. # We use Zig as the linker to perform the compilation from a Linux host. # Zig is not yet available on Debian, so we download the official binary. @@ -48,10 +38,12 @@ RUN xz -d -c build/macos-sdk-11.3.tar.xz | tar -x # This env var is used by `cargo-zigbuild` to find the SDK. ENV SDKROOT /src/macos-sdk-11.3 -# Darwin x86_64 and aarch64 build. +# Build binaries. RUN cargo zigbuild --locked --release \ --target=x86_64-apple-darwin \ --target=aarch64-apple-darwin \ + --target=aarch64-unknown-linux-musl \ + --target=x86_64-unknown-linux-musl \ -p radicle-node \ -p radicle-httpd \ -p radicle-remote-helper \ diff --git a/build/config.toml b/build/config.toml index 1e7a14a0..b50ab676 100644 --- a/build/config.toml +++ b/build/config.toml @@ -1,18 +1,12 @@ [target.x86_64-unknown-linux-musl] -linker = "clang" rustflags = [ - "-C", "link-arg=-fuse-ld=mold", - "-C", "link-arg=--target=x86_64-unknown-linux-musl", "-C", "codegen-units=1", "-C", "incremental=false", "-C", "opt-level=3", ] [target.aarch64-unknown-linux-musl] -linker = "clang" rustflags = [ - "-C", "link-arg=-fuse-ld=mold", - "-C", "link-arg=--target=aarch64-unknown-linux-musl", "-C", "codegen-units=1", "-C", "incremental=false", "-C", "opt-level=3",