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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat(relay): Build Relay for ARM #2370

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
runner = "qemu-aarch64"
35 changes: 32 additions & 3 deletions .github/workflows/build_binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ FROM centos:7 AS relay-deps
ARG RUST_TOOLCHAIN_VERSION
ENV RUST_TOOLCHAIN_VERSION=${RUST_TOOLCHAIN_VERSION}

RUN yum -y update \
ARG BUILD_ARCH

RUN yum -y update && yum clean all \
&& yum -y install centos-release-scl epel-release \
# install a modern compiler toolchain
&& yum -y install cmake3 devtoolset-10 git \
Expand All @@ -19,6 +21,19 @@ RUN yum -y update \
&& rm -rf /var/cache/yum \
&& ln -s /usr/bin/cmake3 /usr/bin/cmake

RUN if [ ${BUILD_ARCH} == "aarch64" ]; then \
yum -y install git make libffi-devel curl dnf ca-certificates \
&& 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 \
# && yum -y install gcc glibc glibc-devel gcc-aarch64-linux-gnu \
&& dnf -y --release 7 install gcc glibc glibc-devel gcc-aarch64-linux-gnu \
&& dnf -y --release 7 --forcearch aarch64 --installroot "/usr/aarch64-linux-gnu/sys-root/" install gcc glibc glibc-devel \
&& 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 \
PATH=/usr/local/cargo/bin:$PATH
Expand All @@ -27,6 +42,10 @@ 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

RUN if [ ${BUILD_ARCH} == "aarch64" ]; then \
rustup target add aarch64-unknown-linux-gnu ; \
fi

COPY --from=sentry-cli /bin/sentry-cli /bin/sentry-cli

WORKDIR /work
Expand Down
5 changes: 4 additions & 1 deletion scripts/docker-build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -19,6 +21,7 @@ BUILD_IMAGE="us.gcr.io/sentryio/relay:deps"
docker pull $BUILD_IMAGE || true
docker buildx build \
--build-arg RUST_TOOLCHAIN_VERSION="$TOOLCHAIN" \
--build-arg BUILD_ARCH="$BUILD_ARCH" \
--platform "linux/${DOCKER_ARCH}" \
--cache-from=${BUILD_IMAGE} \
--target relay-deps \
Expand Down
Loading