From 4223295fab5be3223dcad4a774146cd2c5a8b99c Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Tue, 27 Aug 2024 17:17:56 +0200 Subject: [PATCH 1/3] Compile portably for x86_64 Linux --- .github/workflows/release-linux.yml | 32 ++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index 55cd06228..06e4656a4 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -19,11 +19,13 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} DEBUG_FLAG: ${{ matrix.flavor == 'debug' && '-debug' || '' }} + TARGET_FLAG: ${{ matrix.flavor == 'release' && '--release' || '' }} + GLIBC_MAX_VERSION: '2.26' # Sufficiently old for all our target platforms strategy: matrix: arch: [x64] - flavor: [debug, release] + flavor: [release] steps: - name: Checkout sources @@ -34,16 +36,40 @@ jobs: sudo apt-get update sudo apt-get install -y cargo + # We're linking with zig to select the libc version + cargo install --locked cargo-zigbuild + sudo apt install python3-pip + pip3 install ziglang + + # Install static OpenSSL + sudo apt-get install -y libssl-dev + + # The openssl-sys crate expects to see all headers in one place but + # Ubuntu puts configured headers in an arch-specific folder. We + # merge these folders as a workaround. + sudo cp /usr/include/x86_64-linux-gnu/openssl/* /usr/include/openssl + - name: Compile ARK (${{ matrix.flavor }}) run: | cargo clean - cargo build ${{ matrix.flavor == 'release' && '--release' || '' }} + + # Instruct the openssl-sys crate to link to libssl statically. + # This is important for portability because distributions have + # various requirements for their dynamic libssl libraries. + export OPENSSL_STATIC=yes + export OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu + export OPENSSL_INCLUDE_DIR=/usr/include + + # Use the zig linker. This allows linking to a specific version of glibc. + # We use a sufficiently old version that is available on all platforms we target. + # See https://github.com/ziglang/glibc-abi-tool + cargo zigbuild --target x86_64-unknown-linux-gnu.$GLIBC_MAX_VERSION $TARGET_FLAG # Compress kernel to a zip file - name: Create archive run: | # Enter the build directory - pushd target/${{ matrix.flavor }} + pushd target/x86_64-unknown-linux-gnu/${{ matrix.flavor }} # Compress the kernel to an archive ARCHIVE="$GITHUB_WORKSPACE/ark-${{ inputs.version }}-${{ matrix.flavor }}-linux-x64.zip" From 2bbce533d4bbe0ad52760a62e3ca0fe37969aa75 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Thu, 29 Aug 2024 10:19:08 +0200 Subject: [PATCH 2/3] Remove openssl bits --- .github/workflows/release-linux.yml | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index 06e4656a4..f4429a4ac 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -25,7 +25,7 @@ jobs: strategy: matrix: arch: [x64] - flavor: [release] + flavor: [debug, release] steps: - name: Checkout sources @@ -41,25 +41,10 @@ jobs: sudo apt install python3-pip pip3 install ziglang - # Install static OpenSSL - sudo apt-get install -y libssl-dev - - # The openssl-sys crate expects to see all headers in one place but - # Ubuntu puts configured headers in an arch-specific folder. We - # merge these folders as a workaround. - sudo cp /usr/include/x86_64-linux-gnu/openssl/* /usr/include/openssl - - name: Compile ARK (${{ matrix.flavor }}) run: | cargo clean - # Instruct the openssl-sys crate to link to libssl statically. - # This is important for portability because distributions have - # various requirements for their dynamic libssl libraries. - export OPENSSL_STATIC=yes - export OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu - export OPENSSL_INCLUDE_DIR=/usr/include - # Use the zig linker. This allows linking to a specific version of glibc. # We use a sufficiently old version that is available on all platforms we target. # See https://github.com/ziglang/glibc-abi-tool From bf4783ed71dddc9d529f7949c9df798ef097b71c Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Thu, 29 Aug 2024 10:21:43 +0200 Subject: [PATCH 3/3] Cross-compile for arm64 --- .github/workflows/release-linux.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index f4429a4ac..2e3fde0c4 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -20,11 +20,12 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} DEBUG_FLAG: ${{ matrix.flavor == 'debug' && '-debug' || '' }} TARGET_FLAG: ${{ matrix.flavor == 'release' && '--release' || '' }} + ARCH_FLAG: ${{ matrix.arch == 'x64' && 'x86_64' || 'aarch64' }} GLIBC_MAX_VERSION: '2.26' # Sufficiently old for all our target platforms strategy: matrix: - arch: [x64] + arch: [x64, arm64] flavor: [debug, release] steps: @@ -41,6 +42,11 @@ jobs: sudo apt install python3-pip pip3 install ziglang + - name: Setup Build Environment for arm64 + if: matrix.arch == 'arm64' + run: | + rustup target add aarch64-unknown-linux-gnu + - name: Compile ARK (${{ matrix.flavor }}) run: | cargo clean @@ -48,16 +54,16 @@ jobs: # Use the zig linker. This allows linking to a specific version of glibc. # We use a sufficiently old version that is available on all platforms we target. # See https://github.com/ziglang/glibc-abi-tool - cargo zigbuild --target x86_64-unknown-linux-gnu.$GLIBC_MAX_VERSION $TARGET_FLAG + cargo zigbuild --target ${ARCH_FLAG}-unknown-linux-gnu.$GLIBC_MAX_VERSION $TARGET_FLAG # Compress kernel to a zip file - name: Create archive run: | # Enter the build directory - pushd target/x86_64-unknown-linux-gnu/${{ matrix.flavor }} + pushd target/${ARCH_FLAG}-unknown-linux-gnu/${{ matrix.flavor }} # Compress the kernel to an archive - ARCHIVE="$GITHUB_WORKSPACE/ark-${{ inputs.version }}-${{ matrix.flavor }}-linux-x64.zip" + ARCHIVE="$GITHUB_WORKSPACE/ark-${{ inputs.version }}-${{ matrix.flavor }}-linux-${{ matrix.arch }}.zip" [ -e LICENSE ] || cp "$GITHUB_WORKSPACE/LICENSE" LICENSE [ -e NOTICE ] || cp "$GITHUB_WORKSPACE/crates/ark/NOTICE" NOTICE zip -Xry $ARCHIVE ark LICENSE NOTICE @@ -67,5 +73,5 @@ jobs: - name: Upload archive uses: actions/upload-artifact@v4 with: - name: ark-${{ matrix.flavor }}-linux-x64-archive - path: ark-${{ inputs.version }}-${{ matrix.flavor }}-linux-x64.zip + name: ark-${{ matrix.flavor }}-linux-${{ matrix.arch }}-archive + path: ark-${{ inputs.version }}-${{ matrix.flavor }}-linux-${{ matrix.arch }}.zip