Skip to content

Commit 1883dc1

Browse files
authored
add support for riscv64, loongarch64, powerpc64 and ppc64le (#18)
- point the default uruntime download at our dwarfs-only fork (pkgforge-dev/Anylinux-uruntime), which publishes builds for every supported architecture (requires the 1.0.0 release to be published) - normalize rust arch spellings to uname -m (powerpc64 -> ppc64, powerpc64le -> ppc64le) so the download urls resolve - build all six architectures in the release workflow: the four new ones cross-compile with zig-cc - pin all github actions to commit shas
1 parent 6389b7a commit 1883dc1

4 files changed

Lines changed: 86 additions & 12 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,33 @@ jobs:
3232
RUNNER: ubuntu-24.04-arm,
3333
TARGET: aarch64-unknown-linux-musl,
3434
}
35+
- {
36+
NAME: riscv64-linux,
37+
RUNNER: ubuntu-latest,
38+
TARGET: riscv64gc-unknown-linux-musl,
39+
ZIGTARGET: riscv64-linux-musl,
40+
}
41+
- {
42+
NAME: loongarch64-linux,
43+
RUNNER: ubuntu-latest,
44+
TARGET: loongarch64-unknown-linux-musl,
45+
ZIGTARGET: loongarch64-linux-musl,
46+
}
47+
- {
48+
NAME: ppc64-linux,
49+
RUNNER: ubuntu-latest,
50+
TARGET: powerpc64-unknown-linux-musl,
51+
ZIGTARGET: powerpc64-linux-musl,
52+
}
53+
- {
54+
NAME: ppc64le-linux,
55+
RUNNER: ubuntu-latest,
56+
TARGET: powerpc64le-unknown-linux-musl,
57+
ZIGTARGET: powerpc64le-linux-musl,
58+
}
3559
steps:
3660
- name: Checkout
37-
uses: actions/checkout@v4
61+
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
3862

3963
- name: Set the release version
4064
shell: bash
@@ -47,13 +71,58 @@ jobs:
4771
sudo apt-get install -y --no-install-recommends musl-tools b3sum
4872
4973
- name: Install Rust toolchain
50-
uses: dtolnay/rust-toolchain@nightly
74+
uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # nightly
5175
with:
5276
targets: ${{ matrix.build.TARGET }}
5377
components: rust-src
5478

79+
- name: Install zig
80+
if: ${{ matrix.build.ZIGTARGET }}
81+
run: |
82+
curl -fL --retry 3 -o "$RUNNER_TEMP/zig.tar.xz" \
83+
"https://ziglang.org/download/0.16.0/zig-x86_64-linux-0.16.0.tar.xz"
84+
echo "70e49664a74374b48b51e6f3fdfbf437f6395d42509050588bd49abe52ba3d00 $RUNNER_TEMP/zig.tar.xz" | sha256sum -c -
85+
mkdir -p "$RUNNER_TEMP/zig"
86+
tar xJf "$RUNNER_TEMP/zig.tar.xz" -C "$RUNNER_TEMP/zig" --strip-components=1
87+
88+
- name: Create zig-cc linker wrapper
89+
if: ${{ matrix.build.ZIGTARGET }}
90+
run: |
91+
{
92+
echo '#!/bin/bash'
93+
echo 'args=()'
94+
echo 'for a in "$@"; do'
95+
echo ' case "$a" in'
96+
echo ' *fix-cortex-a53-843419*) continue ;;'
97+
echo ' -nostartfiles) continue ;;'
98+
echo ' crt1.o|Scrt1.o|rcrt1.o|crti.o|crtn.o) continue ;;'
99+
echo ' crtbegin.o|crtend.o|crtbeginS.o|crtendS.o) continue ;;'
100+
echo ' -lc) continue ;;'
101+
echo ' */self-contained/*.o) continue ;;'
102+
echo ' --target=*-unknown-linux-*)'
103+
echo ' t="${a#--target=}"'
104+
echo ' t="${t/-unknown-linux-/-linux-}"'
105+
echo ' args+=("-target" "$t")'
106+
echo ' ;;'
107+
echo ' *) args+=("$a") ;;'
108+
echo ' esac'
109+
echo 'done'
110+
echo "exec \"$RUNNER_TEMP/zig/zig\" cc -target ${{ matrix.build.ZIGTARGET }} \"\${args[@]}\""
111+
} > "$RUNNER_TEMP/zigcc"
112+
chmod +x "$RUNNER_TEMP/zigcc"
113+
55114
- name: Build
56-
run: cargo build --release --locked --target ${{ matrix.build.TARGET }} -Z build-std=std,panic_abort
115+
run: |
116+
if [ -n "${{ matrix.build.ZIGTARGET }}" ]; then
117+
TENV=$(echo "${{ matrix.build.TARGET }}" | tr 'a-z-' 'A-Z_')
118+
export CARGO_TARGET_${TENV}_LINKER="$RUNNER_TEMP/zigcc"
119+
# CARGO_TARGET_RUSTFLAGS (not RUSTFLAGS) so the flags do not leak
120+
# into build scripts
121+
export CARGO_TARGET_RUSTFLAGS="-C target-feature=+crt-static -C link-self-contained=no"
122+
export ZIG_GLOBAL_CACHE_DIR="$RUNNER_TEMP/zig-cache"
123+
export ZIG_LOCAL_CACHE_DIR="$RUNNER_TEMP/zig-cache"
124+
fi
125+
cargo build --release --locked --target ${{ matrix.build.TARGET }} -Z build-std=std,panic_abort
57126
58127
- name: Prepare release assets
59128
shell: bash
@@ -71,7 +140,7 @@ jobs:
71140
b3sum appimagetool-${{ matrix.build.NAME }}.tar.xz > appimagetool-${{ matrix.build.NAME }}.tar.xz.b3sum
72141
73142
- name: Upload to release
74-
uses: svenstaro/upload-release-action@v2
143+
uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de # v2
75144
with:
76145
repo_token: ${{ secrets.GITHUB_TOKEN }}
77146
file: appimagetool-${{ matrix.build.NAME }}*
@@ -80,7 +149,7 @@ jobs:
80149
tag: ${{ github.ref }}
81150

82151
- name: Attest Build Provenance
83-
uses: actions/attest-build-provenance@v2
152+
uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2
84153
with:
85154
subject-name: "appimagetool-${{ matrix.build.NAME }}"
86155
subject-path: appimagetool-${{ matrix.build.NAME }}*

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
A Rust implementation of `appimagetool` for the [Anylinux-AppImages](https://github.com/pkgforge-dev/Anylinux-AppImages) project.
88

9-
It takes a prepared AppDir and produces a finished `.AppImage` using DWARFS compression and the [uruntime](https://github.com/VHSgunzo/uruntime) AppImage runtime. Single binary, no Python, no C++ deps.
9+
It takes a prepared AppDir and produces a finished `.AppImage` using DWARFS compression and the [uruntime](https://github.com/pkgforge-dev/Anylinux-uruntime) AppImage runtime. Single binary, no Python, no C++ deps.
1010

1111
## Quick start
1212

‎src/config.rs‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,14 @@ impl Config {
119119
let appimage_arch = args
120120
.appimage_arch
121121
.or_else(|| env_opt("APPIMAGE_ARCH"))
122-
.unwrap_or_else(|| match env::consts::ARCH {
123-
"x86_64" => "x86_64".to_string(),
124-
"aarch64" => "aarch64".to_string(),
125-
other => other.to_string(),
126-
});
122+
.unwrap_or_else(|| env::consts::ARCH.to_string());
123+
// Normalize rust arch spellings to the uname -m equivalent so the
124+
// download URLs resolve (e.g. powerpc64le -> ppc64le).
125+
let appimage_arch = match appimage_arch.as_str() {
126+
"powerpc64" => "ppc64".to_string(),
127+
"powerpc64le" => "ppc64le".to_string(),
128+
other => other.to_string(),
129+
};
127130
let arch = args.arch.unwrap_or_else(|| appimage_arch.clone());
128131

129132
let appdir = args.appdir.unwrap_or_else(|| PathBuf::from("./AppDir"));

‎src/uruntime.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const MOUNT_MARKER: &[u8] = b"URUNTIME_MOUNT=";
1414
/// Default uruntime download URL pattern. Pinned for reproducible builds;
1515
/// override with `--runtime-url` / `URUNTIME_LINK` to track a different
1616
/// release. `{arch}` gets replaced with the target architecture.
17-
const DEFAULT_URL_TEMPLATE: &str = "https://github.com/VHSgunzo/uruntime/releases/download/v0.5.9/uruntime-appimage-dwarfs-lite-{arch}";
17+
/// Points at our dwarfs-only uruntime fork, which publishes builds for
18+
/// every architecture appimagetool supports.
19+
const DEFAULT_URL_TEMPLATE: &str = "https://github.com/pkgforge-dev/Anylinux-uruntime/releases/download/1.0.0/uruntime-appimage-lite-{arch}";
1820

1921
/// Ensure a runtime binary is available. Returns the path to the runtime.
2022
///

0 commit comments

Comments
 (0)