Skip to content

Commit 8ee0957

Browse files
committed
Build loongarch 64 musl binaries
1 parent 02d6370 commit 8ee0957

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

.github/workflows/release-test.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#
2+
# REF:
3+
# 1. https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrixinclude
4+
#
5+
name: Build Loongarch64 Musl Binary
6+
7+
on:
8+
push:
9+
branches:
10+
- release/loong64-musl
11+
tags:
12+
- 'v*'
13+
14+
defaults:
15+
run:
16+
shell: bash
17+
18+
jobs:
19+
standard:
20+
name: Std
21+
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
target:
26+
- loongarch64-unknown-linux-musl
27+
extra: ['bin']
28+
include:
29+
- target: loongarch64-unknown-linux-musl
30+
os: ubuntu-24.04
31+
32+
runs-on: ${{matrix.os}}
33+
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- name: Update Rust Toolchain Target
38+
run: |
39+
echo "targets = ['${{matrix.target}}']" >> rust-toolchain.toml
40+
41+
- name: Setup Rust toolchain
42+
uses: actions-rust-lang/setup-rust-toolchain@v1.9.0
43+
# WARN: Keep the rustflags to prevent from the winget submission error: `CAQuietExec: Error 0xc0000135`
44+
with:
45+
cache: false
46+
rustflags: ''
47+
48+
- name: Setup Nushell
49+
uses: hustcer/setup-nu@v3
50+
with:
51+
version: 0.103.0
52+
53+
- name: Install LoongArch64 Cross-compilation Toolchain
54+
run: |
55+
# Install build dependencies
56+
sudo apt-get update
57+
sudo apt-get install -y build-essential curl wget
58+
59+
echo "Downloading LoongArch64 musl cross-compilation toolchain..."
60+
# Download and install LoongArch64 musl cross-compilation toolchain
61+
# Use the correct URL from LoongsonLab releases
62+
wget -v https://github.com/LoongsonLab/oscomp-toolchains-for-oskernel/releases/download/loongarch64-linux-musl-cross-gcc-13.2.0/loongarch64-linux-musl-cross.tgz
63+
echo "Extracting toolchain..."
64+
tar -xf loongarch64-linux-musl-cross.tgz
65+
echo "Extracted directory contents:"
66+
ls -la loongarch64-linux-musl-cross/
67+
echo "Installing toolchain to /opt/"
68+
sudo mv loongarch64-linux-musl-cross /opt/
69+
# Add toolchain to PATH
70+
echo "/opt/loongarch64-linux-musl-cross/bin" >> $GITHUB_PATH
71+
echo "Toolchain installed successfully"
72+
73+
- name: Configure Cross-compilation Environment
74+
run: |
75+
# Verify PATH update
76+
export PATH="/opt/loongarch64-linux-musl-cross/bin:$PATH"
77+
echo "Cross-compiler found: $(which loongarch64-linux-musl-gcc)"
78+
# Add LoongArch64 musl target to Rust
79+
rustup target add loongarch64-unknown-linux-musl
80+
81+
# Set up environment variables for cross-compilation
82+
echo "CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_MUSL_LINKER=loongarch64-linux-musl-gcc" >> $GITHUB_ENV
83+
echo "CC_loongarch64_unknown_linux_musl=loongarch64-linux-musl-gcc" >> $GITHUB_ENV
84+
echo "CXX_loongarch64_unknown_linux_musl=loongarch64-linux-musl-g++" >> $GITHUB_ENV
85+
echo "AR_loongarch64_unknown_linux_musl=loongarch64-linux-musl-ar" >> $GITHUB_ENV
86+
echo "CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS=-C linker=loongarch64-linux-musl-gcc" >> $GITHUB_ENV
87+
88+
echo "Cross-compilation environment configured successfully"
89+
90+
- name: Release Nu Binary
91+
id: nu
92+
run: |
93+
# Update PATH for this step
94+
export PATH="/opt/loongarch64-linux-musl-cross/bin:$PATH"
95+
96+
# Verify cross-compiler is available
97+
echo "Verifying cross-compiler..."
98+
loongarch64-linux-musl-gcc --version
99+
100+
echo "Available Rust targets:"
101+
rustup target list --installed
102+
103+
echo "Starting build..."
104+
# Build nushell with cross-compilation
105+
cargo build --release --all --target loongarch64-unknown-linux-musl --features=static-link-openssl
106+
107+
echo "Build completed, checking output files..."
108+
ls -la target/loongarch64-unknown-linux-musl/release/
109+
echo "Looking for nu binaries:"
110+
find target/loongarch64-unknown-linux-musl/release/ -name "nu*" -type f

0 commit comments

Comments
 (0)