Skip to content

Commit a2fd9c7

Browse files
committed
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.
1 parent 54e754d commit a2fd9c7

File tree

10 files changed

+289
-107
lines changed

10 files changed

+289
-107
lines changed

.github/workflows/containers.yml

+8
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ jobs:
2222
uses: ./.github/workflows/container.yml
2323
with:
2424
name: 'fedora'
25+
debian-amd64:
26+
uses: ./.github/workflows/container.yml
27+
with:
28+
name: 'debian-amd64'
29+
debian-arm64:
30+
uses: ./.github/workflows/container.yml
31+
with:
32+
name: 'debian-arm64'

.github/workflows/release.yml

+1-13
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,7 @@ jobs:
6767

6868
runtimes:
6969
name: Runtimes
70-
runs-on: ubuntu-latest
71-
container:
72-
image: ghcr.io/inko-lang/ci:fedora
73-
needs:
74-
- tests
75-
env:
76-
RCLONE_S3_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_ACCESS_KEY_ID }}
77-
RCLONE_S3_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_SECRET_ACCESS_KEY }}
78-
RCLONE_S3_ENDPOINT: https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com
79-
steps:
80-
- uses: actions/checkout@v4
81-
- name: Upload runtimes
82-
run: make runtimes
70+
uses: ./.github/workflows/runtimes.yml
8371

8472
docs:
8573
name: Documentation

.github/workflows/runtimes.yml

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
name: Build runtimes
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
env:
8+
CARGO_HOME: ${{ github.workspace }}/.cargo-home
9+
# We set an explicit version to only install the components we need for CI.
10+
RUSTUP_TOOLCHAIN: '1.78'
11+
12+
jobs:
13+
linux-amd64:
14+
name: Linux AMD64
15+
runs-on: ubuntu-latest
16+
container:
17+
image: ghcr.io/inko-lang/ci:debian-amd64
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Build runtimes
21+
run: bash ci/runtimes.sh amd64-linux
22+
- uses: actions/upload-artifact@v4
23+
with:
24+
name: amd64-linux
25+
path: tmp/runtimes/${{ github.ref_name }}/*.tar.gz
26+
overwrite: true
27+
retention-days: 2
28+
compression-level: 0
29+
30+
linux-arm64:
31+
name: Linux ARM64
32+
runs-on: ubuntu-latest
33+
container:
34+
image: ghcr.io/inko-lang/ci:debian-arm64
35+
steps:
36+
- uses: actions/checkout@v4
37+
- name: Build runtimes
38+
run: bash ci/runtimes.sh arm64-linux
39+
- uses: actions/upload-artifact@v4
40+
with:
41+
name: arm64-linux
42+
path: tmp/runtimes/${{ github.ref_name }}/*.tar.gz
43+
overwrite: true
44+
retention-days: 2
45+
compression-level: 0
46+
47+
macos-amd64:
48+
name: macOS AMD64
49+
runs-on: macos-12
50+
steps:
51+
- uses: actions/checkout@v4
52+
- name: Install dependencies
53+
run: ./ci/mac.sh
54+
- name: Build runtimes
55+
run: bash ci/runtimes.sh amd64-mac
56+
- uses: actions/upload-artifact@v4
57+
with:
58+
name: amd64-mac
59+
path: tmp/runtimes/${{ github.ref_name }}/*.tar.gz
60+
overwrite: true
61+
retention-days: 2
62+
compression-level: 0
63+
64+
macos-arm64:
65+
name: macOS ARM64
66+
runs-on: macos-14
67+
steps:
68+
- uses: actions/checkout@v4
69+
- name: Install dependencies
70+
run: ./ci/mac.sh
71+
- name: Build runtimes
72+
run: bash ci/runtimes.sh arm64-mac
73+
- uses: actions/upload-artifact@v4
74+
with:
75+
name: arm64-mac
76+
path: tmp/runtimes/${{ github.ref_name }}/*.tar.gz
77+
overwrite: true
78+
retention-days: 2
79+
compression-level: 0
80+
81+
freebsd-amd64:
82+
name: FreeBSD AMD64
83+
runs-on: ubuntu-latest
84+
steps:
85+
- uses: actions/checkout@v4
86+
- name: Build runtimes
87+
uses: cross-platform-actions/[email protected]
88+
with:
89+
operating_system: freebsd
90+
version: '14.0'
91+
memory: 8G
92+
environment_variables: 'CARGO_HOME RUSTUP_HOME'
93+
image_url: 'https://github.com/inko-lang/freebsd-builder/releases/download/v0.8.0/freebsd-14.0-x86-64.qcow2'
94+
run: bash ci/runtimes.sh amd64-freebsd
95+
- uses: actions/upload-artifact@v4
96+
with:
97+
name: amd64-freebsd
98+
path: tmp/runtimes/${{ github.ref_name }}/*.tar.gz
99+
overwrite: true
100+
retention-days: 2
101+
compression-level: 0
102+
103+
upload:
104+
name: Upload runtimes
105+
runs-on: ubuntu-latest
106+
container:
107+
image: ghcr.io/inko-lang/ci:fedora
108+
env:
109+
RCLONE_S3_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_ACCESS_KEY_ID }}
110+
RCLONE_S3_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_SECRET_ACCESS_KEY }}
111+
RCLONE_S3_ENDPOINT: https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com
112+
needs:
113+
- linux-amd64
114+
- linux-arm64
115+
- macos-amd64
116+
- macos-arm64
117+
- freebsd-amd64
118+
steps:
119+
- uses: actions/checkout@v4
120+
- uses: actions/download-artifact@v4
121+
with:
122+
path: tmp/runtimes
123+
merge-multiple: true
124+
- name: Upload runtimes
125+
run: rclone sync --dry-run --config rclone.conf --checksum --verbose tmp/runtimes "production:inko-releases/runtimes/${{ github.ref_name }}"

Makefile

+1-4
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,8 @@ std-docs/publish: std-docs/build
167167
rclone sync --config rclone.conf --checksum --verbose \
168168
std/build/idoc/public "production:${DOCS_BUCKET}/std/${DOCS_REF}"
169169

170-
runtimes:
171-
bash scripts/runtimes.sh ${VERSION}
172-
173170
.PHONY: release/source release/manifest release/changelog release/versions
174171
.PHONY: release/commit release/publish release/tag
175-
.PHONY: build install clean runtimes
172+
.PHONY: build install clean
176173
.PHONY: docs/setup docs/build docs/watch docs/publish
177174
.PHONY: std-docs/build std-docs/publish

ci/docker/debian-amd64/Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM debian:12
2+
3+
ENV LLVM_VERSION 17
4+
ENV RUST_VERSION 1.78
5+
6+
ENV PATH /opt/cargo/bin:$PATH
7+
ENV CARGO_HOME /opt/cargo
8+
ENV RUSTUP_HOME /opt/rustup
9+
10+
RUN apt update --quiet && apt install --quiet --yes curl build-essential tar git
11+
RUN curl https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
12+
RUN /usr/bin/echo -e "deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-$LLVM_VERSION main" \
13+
> /etc/apt/sources.list.d/llvm$LLVM_VERSION.list
14+
15+
RUN apt update --quiet && apt install --quiet --yes \
16+
llvm-$LLVM_VERSION llvm-$LLVM_VERSION-dev \
17+
libstdc++-11-dev libclang-common-$LLVM_VERSION-dev zlib1g-dev \
18+
libpolly-$LLVM_VERSION-dev libzstd-dev
19+
20+
RUN curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location \
21+
--silent --show-error --fail "https://sh.rustup.rs" | \
22+
sh -s -- --quiet -y --no-modify-path --profile minimal \
23+
--component clippy,rustfmt --default-toolchain $RUST_VERSION
24+
25+
RUN apt install --quiet --yes musl-tools

ci/docker/debian-arm64/Dockerfile

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM debian:12
2+
3+
ENV LLVM_VERSION 17
4+
ENV RUST_VERSION 1.78
5+
6+
ENV PATH /opt/cargo/bin:$PATH
7+
ENV CARGO_HOME /opt/cargo
8+
ENV RUSTUP_HOME /opt/rustup
9+
10+
RUN apt update --quiet && apt install --quiet --yes curl build-essential tar git
11+
RUN curl https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
12+
RUN /usr/bin/echo -e "deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-$LLVM_VERSION main" \
13+
> /etc/apt/sources.list.d/llvm$LLVM_VERSION.list
14+
15+
RUN apt update --quiet && apt install --quiet --yes \
16+
llvm-$LLVM_VERSION llvm-$LLVM_VERSION-dev \
17+
libstdc++-11-dev libclang-common-$LLVM_VERSION-dev zlib1g-dev \
18+
libpolly-$LLVM_VERSION-dev libzstd-dev
19+
20+
RUN curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location \
21+
--silent --show-error --fail "https://sh.rustup.rs" | \
22+
sh -s -- --quiet -y --no-modify-path --profile minimal \
23+
--component clippy,rustfmt --default-toolchain $RUST_VERSION
24+
25+
RUN dpkg --add-architecture arm64 \
26+
&& apt install --quiet --yes gcc-aarch64-linux-gnu musl-tools:arm64

ci/docker/fedora/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ENV CARGO_HOME /opt/cargo
1010
RUN sudo dnf install --assumeyes --quiet gcc make tar git rustup rclone \
1111
llvm$LLVM_VERSION llvm$LLVM_VERSION-devel \
1212
llvm$LLVM_VERSION-static libstdc++-devel libstdc++-static \
13-
libffi-devel zlib-devel musl-gcc
13+
libffi-devel zlib-devel
1414

1515
RUN rustup-init --quiet -y --no-modify-path --profile minimal \
1616
--component clippy,rustfmt --default-toolchain $RUST_VERSION

ci/runtimes.sh

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# The version of Rust to use.
6+
RUST_VERSION='1.78'
7+
8+
# The directory to place the runtimes in.
9+
DIR="tmp/runtimes"
10+
11+
function rustup_lib {
12+
local home
13+
local toolchain
14+
home="$(rustup show home)"
15+
toolchain="$(rustup show active-toolchain | awk '{print $1}')"
16+
17+
echo "${home}/toolchains/${toolchain}/lib/rustlib/${1}/lib/"
18+
}
19+
20+
function build {
21+
local rust_target
22+
local inko_target
23+
local out
24+
local target_dir
25+
rust_target="${1}"
26+
inko_target="${2}"
27+
out="${DIR}/${inko_target}.tar.gz"
28+
target_dir="${DIR}/${inko_target}"
29+
30+
if [[ -f "${out}" ]]
31+
then
32+
return 0
33+
fi
34+
35+
rustup target add "${rust_target}"
36+
cargo build -p rt --release --target="${rust_target}"
37+
mkdir -p "${target_dir}"
38+
cp "target/${rust_target}/release/libinko.a" "${target_dir}"
39+
40+
if [[ "${rust_target}" == *-musl ]]
41+
then
42+
cp "$(rustup_lib "${rust_target}")/self-contained/libunwind.a" \
43+
"${target_dir}"
44+
fi
45+
46+
tar --directory "${DIR}" --create --gzip --file "${out}" "${inko_target}"
47+
rm -rf "${target_dir}"
48+
}
49+
50+
function install_rust {
51+
curl --proto '=https' \
52+
--tlsv1.2 \
53+
--retry 10 \
54+
--retry-connrefused \
55+
--location \
56+
--silent \
57+
--show-error \
58+
--fail "https://sh.rustup.rs" | \
59+
sh -s -- --profile minimal -y --default-toolchain "${RUST_VERSION}"
60+
61+
export PATH="${CARGO_HOME}/bin:${PATH}"
62+
}
63+
64+
function init_rust {
65+
rustup-init --quiet -y --no-modify-path --profile minimal \
66+
--default-toolchain $RUST_VERSION
67+
68+
export PATH="${CARGO_HOME}/bin:${PATH}"
69+
}
70+
71+
mkdir -p "${DIR}"
72+
73+
case "$1" in
74+
"amd64-linux")
75+
build "x86_64-unknown-linux-gnu" "amd64-linux-gnu"
76+
build "x86_64-unknown-linux-musl" "amd64-linux-musl"
77+
;;
78+
"arm64-linux")
79+
build "aarch64-unknown-linux-gnu" "arm64-linux-gnu"
80+
build "aarch64-unknown-linux-musl" "arm64-linux-musl"
81+
;;
82+
"amd64-mac")
83+
init_rust
84+
build "x86_64-apple-darwin" "amd64-mac-native"
85+
;;
86+
"arm64-mac")
87+
init_rust
88+
build "aarch64-apple-darwin" "arm64-mac-native"
89+
;;
90+
"amd64-freebsd")
91+
install_rust
92+
build "x86_64-unknown-freebsd" "amd64-freebsd-native"
93+
;;
94+
*)
95+
echo "the architecture '$1' is invalid"
96+
exit 1
97+
;;
98+
esac

docs/source/setup/installation.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ Debian 12:
238238

239239
```bash
240240
curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
241-
sudo add-apt-repository "deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-17 main"
241+
echo -e "deb http://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-17 main" | sudo tee /etc/apt/sources.list.d/llvm17.list
242242
sudo apt-get update
243-
sudo apt-get install --yes git build-essential llvm-17 llvm-17-dev libstdc++-10-dev libclang-common-17-dev zlib1g-dev libpolly-17-dev libzstd-dev
243+
sudo apt-get install --yes git build-essential llvm-17 llvm-17-dev libstdc++-11-dev libclang-common-17-dev zlib1g-dev libpolly-17-dev libzstd-dev
244244
```
245245

246246
For older versions, refer to [LLVM's Debian/Ubuntu packages page][llvm-apt] and
@@ -291,9 +291,9 @@ For 23.10:
291291

292292
```bash
293293
curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
294-
sudo add-apt-repository "deb http://apt.llvm.org/mantic/ llvm-toolchain-mantic-17 main"
294+
echo -e "deb http://apt.llvm.org/mantic/ llvm-toolchain-mantic-17 main" | sudo tee /etc/apt/sources.list.d/llvm17.list
295295
sudo apt-get update
296-
sudo apt-get install --yes rustc cargo git build-essential llvm-17 llvm-17-dev libstdc++-10-dev libclang-common-17-dev zlib1g-dev libpolly-17-dev libzstd-dev
296+
sudo apt-get install --yes rustc cargo git build-essential llvm-17 llvm-17-dev libstdc++-11-dev libclang-common-17-dev zlib1g-dev libpolly-17-dev libzstd-dev
297297
```
298298

299299
For older versions, refer to [LLVM's Debian/Ubuntu packages page][llvm-apt] and

0 commit comments

Comments
 (0)