-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor building of release runtimes
This might still fail (sadly we can only figure that out by pushing the changes), but it should hopefully resolve cross-compilation of the runtime now requiring a full C toolchain due to the ring dependency. Since Fedora doesn't provide cross-compilation toolchains for userspace, we have to use Debian. Debian in turn doesn't allow installing musl for AMD64 and ARM64 in parallel, so we need two different images.
- Loading branch information
1 parent
54e754d
commit a2fd9c7
Showing
10 changed files
with
289 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
--- | ||
name: Build runtimes | ||
on: | ||
workflow_call: | ||
workflow_dispatch: | ||
|
||
env: | ||
CARGO_HOME: ${{ github.workspace }}/.cargo-home | ||
# We set an explicit version to only install the components we need for CI. | ||
RUSTUP_TOOLCHAIN: '1.78' | ||
|
||
jobs: | ||
linux-amd64: | ||
name: Linux AMD64 | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ghcr.io/inko-lang/ci:debian-amd64 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build runtimes | ||
run: bash ci/runtimes.sh amd64-linux | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: amd64-linux | ||
path: tmp/runtimes/${{ github.ref_name }}/*.tar.gz | ||
overwrite: true | ||
retention-days: 2 | ||
compression-level: 0 | ||
|
||
linux-arm64: | ||
name: Linux ARM64 | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ghcr.io/inko-lang/ci:debian-arm64 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build runtimes | ||
run: bash ci/runtimes.sh arm64-linux | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: arm64-linux | ||
path: tmp/runtimes/${{ github.ref_name }}/*.tar.gz | ||
overwrite: true | ||
retention-days: 2 | ||
compression-level: 0 | ||
|
||
macos-amd64: | ||
name: macOS AMD64 | ||
runs-on: macos-12 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install dependencies | ||
run: ./ci/mac.sh | ||
- name: Build runtimes | ||
run: bash ci/runtimes.sh amd64-mac | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: amd64-mac | ||
path: tmp/runtimes/${{ github.ref_name }}/*.tar.gz | ||
overwrite: true | ||
retention-days: 2 | ||
compression-level: 0 | ||
|
||
macos-arm64: | ||
name: macOS ARM64 | ||
runs-on: macos-14 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install dependencies | ||
run: ./ci/mac.sh | ||
- name: Build runtimes | ||
run: bash ci/runtimes.sh arm64-mac | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: arm64-mac | ||
path: tmp/runtimes/${{ github.ref_name }}/*.tar.gz | ||
overwrite: true | ||
retention-days: 2 | ||
compression-level: 0 | ||
|
||
freebsd-amd64: | ||
name: FreeBSD AMD64 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build runtimes | ||
uses: cross-platform-actions/[email protected] | ||
with: | ||
operating_system: freebsd | ||
version: '14.0' | ||
memory: 8G | ||
environment_variables: 'CARGO_HOME RUSTUP_HOME' | ||
image_url: 'https://github.com/inko-lang/freebsd-builder/releases/download/v0.8.0/freebsd-14.0-x86-64.qcow2' | ||
run: bash ci/runtimes.sh amd64-freebsd | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: amd64-freebsd | ||
path: tmp/runtimes/${{ github.ref_name }}/*.tar.gz | ||
overwrite: true | ||
retention-days: 2 | ||
compression-level: 0 | ||
|
||
upload: | ||
name: Upload runtimes | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ghcr.io/inko-lang/ci:fedora | ||
env: | ||
RCLONE_S3_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_ACCESS_KEY_ID }} | ||
RCLONE_S3_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_SECRET_ACCESS_KEY }} | ||
RCLONE_S3_ENDPOINT: https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com | ||
needs: | ||
- linux-amd64 | ||
- linux-arm64 | ||
- macos-amd64 | ||
- macos-arm64 | ||
- freebsd-amd64 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
path: tmp/runtimes | ||
merge-multiple: true | ||
- name: Upload runtimes | ||
run: rclone sync --dry-run --config rclone.conf --checksum --verbose tmp/runtimes "production:inko-releases/runtimes/${{ github.ref_name }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM debian:12 | ||
|
||
ENV LLVM_VERSION 17 | ||
ENV RUST_VERSION 1.78 | ||
|
||
ENV PATH /opt/cargo/bin:$PATH | ||
ENV CARGO_HOME /opt/cargo | ||
ENV RUSTUP_HOME /opt/rustup | ||
|
||
RUN apt update --quiet && apt install --quiet --yes curl build-essential tar git | ||
RUN curl https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc | ||
RUN /usr/bin/echo -e "deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-$LLVM_VERSION main" \ | ||
> /etc/apt/sources.list.d/llvm$LLVM_VERSION.list | ||
|
||
RUN apt update --quiet && apt install --quiet --yes \ | ||
llvm-$LLVM_VERSION llvm-$LLVM_VERSION-dev \ | ||
libstdc++-11-dev libclang-common-$LLVM_VERSION-dev zlib1g-dev \ | ||
libpolly-$LLVM_VERSION-dev libzstd-dev | ||
|
||
RUN curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location \ | ||
--silent --show-error --fail "https://sh.rustup.rs" | \ | ||
sh -s -- --quiet -y --no-modify-path --profile minimal \ | ||
--component clippy,rustfmt --default-toolchain $RUST_VERSION | ||
|
||
RUN apt install --quiet --yes musl-tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM debian:12 | ||
|
||
ENV LLVM_VERSION 17 | ||
ENV RUST_VERSION 1.78 | ||
|
||
ENV PATH /opt/cargo/bin:$PATH | ||
ENV CARGO_HOME /opt/cargo | ||
ENV RUSTUP_HOME /opt/rustup | ||
|
||
RUN apt update --quiet && apt install --quiet --yes curl build-essential tar git | ||
RUN curl https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc | ||
RUN /usr/bin/echo -e "deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-$LLVM_VERSION main" \ | ||
> /etc/apt/sources.list.d/llvm$LLVM_VERSION.list | ||
|
||
RUN apt update --quiet && apt install --quiet --yes \ | ||
llvm-$LLVM_VERSION llvm-$LLVM_VERSION-dev \ | ||
libstdc++-11-dev libclang-common-$LLVM_VERSION-dev zlib1g-dev \ | ||
libpolly-$LLVM_VERSION-dev libzstd-dev | ||
|
||
RUN curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location \ | ||
--silent --show-error --fail "https://sh.rustup.rs" | \ | ||
sh -s -- --quiet -y --no-modify-path --profile minimal \ | ||
--component clippy,rustfmt --default-toolchain $RUST_VERSION | ||
|
||
RUN dpkg --add-architecture arm64 \ | ||
&& apt install --quiet --yes gcc-aarch64-linux-gnu musl-tools:arm64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# The version of Rust to use. | ||
RUST_VERSION='1.78' | ||
|
||
# The directory to place the runtimes in. | ||
DIR="tmp/runtimes" | ||
|
||
function rustup_lib { | ||
local home | ||
local toolchain | ||
home="$(rustup show home)" | ||
toolchain="$(rustup show active-toolchain | awk '{print $1}')" | ||
|
||
echo "${home}/toolchains/${toolchain}/lib/rustlib/${1}/lib/" | ||
} | ||
|
||
function build { | ||
local rust_target | ||
local inko_target | ||
local out | ||
local target_dir | ||
rust_target="${1}" | ||
inko_target="${2}" | ||
out="${DIR}/${inko_target}.tar.gz" | ||
target_dir="${DIR}/${inko_target}" | ||
|
||
if [[ -f "${out}" ]] | ||
then | ||
return 0 | ||
fi | ||
|
||
rustup target add "${rust_target}" | ||
cargo build -p rt --release --target="${rust_target}" | ||
mkdir -p "${target_dir}" | ||
cp "target/${rust_target}/release/libinko.a" "${target_dir}" | ||
|
||
if [[ "${rust_target}" == *-musl ]] | ||
then | ||
cp "$(rustup_lib "${rust_target}")/self-contained/libunwind.a" \ | ||
"${target_dir}" | ||
fi | ||
|
||
tar --directory "${DIR}" --create --gzip --file "${out}" "${inko_target}" | ||
rm -rf "${target_dir}" | ||
} | ||
|
||
function install_rust { | ||
curl --proto '=https' \ | ||
--tlsv1.2 \ | ||
--retry 10 \ | ||
--retry-connrefused \ | ||
--location \ | ||
--silent \ | ||
--show-error \ | ||
--fail "https://sh.rustup.rs" | \ | ||
sh -s -- --profile minimal -y --default-toolchain "${RUST_VERSION}" | ||
|
||
export PATH="${CARGO_HOME}/bin:${PATH}" | ||
} | ||
|
||
function init_rust { | ||
rustup-init --quiet -y --no-modify-path --profile minimal \ | ||
--default-toolchain $RUST_VERSION | ||
|
||
export PATH="${CARGO_HOME}/bin:${PATH}" | ||
} | ||
|
||
mkdir -p "${DIR}" | ||
|
||
case "$1" in | ||
"amd64-linux") | ||
build "x86_64-unknown-linux-gnu" "amd64-linux-gnu" | ||
build "x86_64-unknown-linux-musl" "amd64-linux-musl" | ||
;; | ||
"arm64-linux") | ||
build "aarch64-unknown-linux-gnu" "arm64-linux-gnu" | ||
build "aarch64-unknown-linux-musl" "arm64-linux-musl" | ||
;; | ||
"amd64-mac") | ||
init_rust | ||
build "x86_64-apple-darwin" "amd64-mac-native" | ||
;; | ||
"arm64-mac") | ||
init_rust | ||
build "aarch64-apple-darwin" "arm64-mac-native" | ||
;; | ||
"amd64-freebsd") | ||
install_rust | ||
build "x86_64-unknown-freebsd" "amd64-freebsd-native" | ||
;; | ||
*) | ||
echo "the architecture '$1' is invalid" | ||
exit 1 | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.