From ce90e9c46cbf52e865e763b04fcc1aaf1b067b7f Mon Sep 17 00:00:00 2001 From: Iker Barriocanal <32816711+iker-barriocanal@users.noreply.github.com> Date: Tue, 1 Aug 2023 16:22:28 +0200 Subject: [PATCH] feat(ci): Build Relay for Linux ARM --- .cargo/config.toml | 3 +++ .github/workflows/build_binary.yml | 35 +++++++++++++++++++++++++++--- Dockerfile | 14 ++++++++++-- scripts/docker-build-linux.sh | 4 +++- 4 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000000..1cf09b7989 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,3 @@ +[target.aarch64-unknown-linux-gnu] +linker = "aarch64-linux-gnu-gcc" +runner = "qemu-aarch64" diff --git a/.github/workflows/build_binary.yml b/.github/workflows/build_binary.yml index bd80edf42b..41ff17310b 100644 --- a/.github/workflows/build_binary.yml +++ b/.github/workflows/build_binary.yml @@ -3,14 +3,14 @@ name: Binary Release Build on: push: branches: - - release/** + # - release/** # testing env: CARGO_TERM_COLOR: always jobs: - linux: - name: Linux + linux_x86: + name: Linux x86 runs-on: ubuntu-latest steps: @@ -38,6 +38,35 @@ jobs: name: ${{ github.sha }} path: target/x86_64-unknown-linux-gnu/release/relay-Linux-x86_64* + linux_arm: + name: Linux ARM + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Build in Docker + run: | + # Get the latest stable rust toolchain version available + TOOLCHAIN=$(curl -s 'https://static.rust-lang.org/dist/channel-rust-stable.toml' | awk '/\[pkg.rust\]/ {getline;print;}' | sed -r 's/^version = "([0-9.]+) .*/\1/') + scripts/docker-build-linux.sh "$TOOLCHAIN" + env: + BUILD_ARCH: aarch64 + RELAY_FEATURES: + + - name: Bundle Debug File + run: | + cd target/aarch64-unknown-linux-gnu/release/ + zip relay-Linux-aarch64-debug.zip relay.debug + mv relay relay-Linux-aarch64 + + - uses: actions/upload-artifact@v3 + with: + name: ${{ github.sha }} + path: target/aarch64-unknown-linux-gnu/release/relay-Linux-aarch64* + macos: name: macOS runs-on: macos-11 diff --git a/Dockerfile b/Dockerfile index 171ea556ae..2bd25d2c6d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,16 @@ RUN yum -y update \ llvm-toolset-7.0-clang-devel \ && yum clean all \ && rm -rf /var/cache/yum \ - && ln -s /usr/bin/cmake3 /usr/bin/cmake + && ln -s /usr/bin/cmake3 /usr/bin/cmake \ + && if [ ${BUILD_ARCH} == "aarch64" ]; then \ + yum -y install curl dnf ca-certificates gcc-aarch64-linux-gnu qemu-user \ + && dnf --forcearch aarch64 --release 7 install -y glibc glibc-devel --installroot "/usr/aarch64-linux-gnu/sys-root/" \ + && curl -L -s https://www.centos.org/keys/RPM-GPG-KEY-CentOS-7-aarch64 > /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7-aarch64 \ + && cat /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7-aarch64 >> /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 \ + && ln -s "/usr/aarch64-linux-gnu/sys-root/lib64/libgcc_s.so.1" "/usr/aarch64-linux-gnu/sys-root/lib64/libgcc_s.so" \ + # NOTE(iker): work-around to create a cmake toolchain file for arch-specific builds, since only objcopy is needed. + && rm -rf "/usr/bin/objcopy" && ln -s "/usr/bin/aarch64-linux-gnu-objcopy" "/usr/bin/objcopy" ; \ + fi ENV RUSTUP_HOME=/usr/local/rustup \ CARGO_HOME=/usr/local/cargo \ @@ -25,7 +34,8 @@ ENV RUSTUP_HOME=/usr/local/rustup \ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ | sh -s -- -y --profile minimal --default-toolchain=${RUST_TOOLCHAIN_VERSION} \ - && echo -e '[registries.crates-io]\nprotocol = "sparse"\n[net]\ngit-fetch-with-cli = true' > $CARGO_HOME/config + && echo -e '[registries.crates-io]\nprotocol = "sparse"\n[net]\ngit-fetch-with-cli = true' > $CARGO_HOME/config \ + && rustup target add aarch64-unknown-linux-gnu COPY --from=sentry-cli /bin/sentry-cli /bin/sentry-cli diff --git a/scripts/docker-build-linux.sh b/scripts/docker-build-linux.sh index 86caa12f78..3bd604950c 100755 --- a/scripts/docker-build-linux.sh +++ b/scripts/docker-build-linux.sh @@ -3,7 +3,9 @@ set -eux TOOLCHAIN=$1 -if [ "${BUILD_ARCH}" = "x86_64" ]; then +if [ "${BUILD_ARCH}" = "aarch64" ]; then + DOCKER_ARCH="amd64" +elif [ "${BUILD_ARCH}" = "x86_64" ]; then DOCKER_ARCH="amd64" elif [ "${BUILD_ARCH}" = "i686" ]; then DOCKER_ARCH="i386"