Skip to content

Commit 3e83bfd

Browse files
committed
musl.cc blocks GitHub Actions due to abuse. Cache the toolchains in the repo itself.
1 parent 9209cae commit 3e83bfd

5 files changed

Lines changed: 113 additions & 72 deletions

File tree

.github/workflows/armv7-musl-linux.yml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,12 @@ jobs:
1717
- uses: actions/checkout@v4
1818
- name: Install build tools
1919
run: sudo apt-get update && sudo apt-get install -y cmake make
20-
- name: Download musl.cc cross-compiler
20+
- name: Extract musl.cc cross-compiler
2121
run: |
2222
mkdir -p /opt/cross
2323
cd /opt/cross
24-
for attempt in 1 2 3; do
25-
echo "Attempt $attempt/3: Downloading arm-linux-musleabihf-cross.tgz..."
26-
if wget -O arm-linux-musleabihf-cross.tgz https://musl.cc/arm-linux-musleabihf-cross.tgz; then
27-
tar xzf arm-linux-musleabihf-cross.tgz
28-
rm arm-linux-musleabihf-cross.tgz
29-
echo "Download successful"
30-
exit 0
31-
else
32-
echo "Download attempt $attempt failed"
33-
if [ $attempt -lt 3 ]; then
34-
echo "Waiting 15 seconds before retry..."
35-
sleep 15
36-
fi
37-
fi
38-
done
39-
echo "All 3 download attempts failed"
40-
exit 1
24+
tar xzf ${{ github.workspace }}/cross-compilers/arm-linux-musleabihf-cross.tgz
25+
echo "Cross-compiler extracted successfully"
4126
- name: Configure and Build
4227
run: |
4328
mkdir -p build && cd build

.github/workflows/ppc64le-musl-linux.yml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,12 @@ jobs:
1717
- uses: actions/checkout@v4
1818
- name: Install build tools
1919
run: sudo apt-get update && sudo apt-get install -y cmake make
20-
- name: Download musl.cc cross-compiler
20+
- name: Extract musl.cc cross-compiler
2121
run: |
2222
mkdir -p /opt/cross
2323
cd /opt/cross
24-
for attempt in 1 2 3; do
25-
echo "Attempt $attempt/3: Downloading powerpc64le-linux-musl-cross.tgz..."
26-
if wget -O powerpc64le-linux-musl-cross.tgz https://musl.cc/powerpc64le-linux-musl-cross.tgz; then
27-
tar xzf powerpc64le-linux-musl-cross.tgz
28-
rm powerpc64le-linux-musl-cross.tgz
29-
echo "Download successful"
30-
exit 0
31-
else
32-
echo "Download attempt $attempt failed"
33-
if [ $attempt -lt 3 ]; then
34-
echo "Waiting 15 seconds before retry..."
35-
sleep 15
36-
fi
37-
fi
38-
done
39-
echo "All 3 download attempts failed"
40-
exit 1
24+
tar xzf ${{ github.workspace }}/cross-compilers/powerpc64le-linux-musl-cross.tgz
25+
echo "Cross-compiler extracted successfully"
4126
- name: Configure and Build
4227
run: |
4328
mkdir -p build && cd build

.github/workflows/riscv64-musl-linux.yml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,12 @@ jobs:
1717
- uses: actions/checkout@v4
1818
- name: Install build tools
1919
run: sudo apt-get update && sudo apt-get install -y cmake make
20-
- name: Download musl.cc cross-compiler
20+
- name: Extract musl.cc cross-compiler
2121
run: |
2222
mkdir -p /opt/cross
2323
cd /opt/cross
24-
for attempt in 1 2 3; do
25-
echo "Attempt $attempt/3: Downloading riscv64-linux-musl-cross.tgz..."
26-
if wget -O riscv64-linux-musl-cross.tgz https://musl.cc/riscv64-linux-musl-cross.tgz; then
27-
tar xzf riscv64-linux-musl-cross.tgz
28-
rm riscv64-linux-musl-cross.tgz
29-
echo "Download successful"
30-
exit 0
31-
else
32-
echo "Download attempt $attempt failed"
33-
if [ $attempt -lt 3 ]; then
34-
echo "Waiting 15 seconds before retry..."
35-
sleep 15
36-
fi
37-
fi
38-
done
39-
echo "All 3 download attempts failed"
40-
exit 1
24+
tar xzf ${{ github.workspace }}/cross-compilers/riscv64-linux-musl-cross.tgz
25+
echo "Cross-compiler extracted successfully"
4126
- name: Configure and Build
4227
run: |
4328
mkdir -p build && cd build

.github/workflows/s390x-musl-linux.yml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,12 @@ jobs:
1717
- uses: actions/checkout@v4
1818
- name: Install build tools
1919
run: sudo apt-get update && sudo apt-get install -y cmake make
20-
- name: Download musl.cc cross-compiler
20+
- name: Extract musl.cc cross-compiler
2121
run: |
2222
mkdir -p /opt/cross
2323
cd /opt/cross
24-
for attempt in 1 2 3; do
25-
echo "Attempt $attempt/3: Downloading s390x-linux-musl-cross.tgz..."
26-
if wget -O s390x-linux-musl-cross.tgz https://musl.cc/s390x-linux-musl-cross.tgz; then
27-
tar xzf s390x-linux-musl-cross.tgz
28-
rm s390x-linux-musl-cross.tgz
29-
echo "Download successful"
30-
exit 0
31-
else
32-
echo "Download attempt $attempt failed"
33-
if [ $attempt -lt 3 ]; then
34-
echo "Waiting 15 seconds before retry..."
35-
sleep 15
36-
fi
37-
fi
38-
done
39-
echo "All 3 download attempts failed"
40-
exit 1
24+
tar xzf ${{ github.workspace }}/cross-compilers/s390x-linux-musl-cross.tgz
25+
echo "Cross-compiler extracted successfully"
4126
- name: Configure and Build
4227
run: |
4328
mkdir -p build && cd build

scripts/download-musl-cc.sh

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/bin/bash
2+
#
3+
# Download musl.cc cross-compiler toolchains
4+
#
5+
# This script downloads pre-built cross-compiler toolchains from musl.cc
6+
# and stores them in the cross-compilers/ directory for Git LFS tracking.
7+
#
8+
# Usage: ./scripts/download-musl-cc.sh
9+
#
10+
# Before running this script, ensure Git LFS is installed:
11+
# brew install git-lfs (macOS)
12+
# apt-get install git-lfs (Ubuntu/Debian)
13+
# choco install git-lfs (Windows)
14+
#
15+
# Then initialize Git LFS in this repository:
16+
# git lfs install
17+
#
18+
19+
set -e
20+
21+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
22+
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
23+
CROSS_COMPILERS_DIR="$REPO_ROOT/cross-compilers"
24+
25+
# Create cross-compilers directory if it doesn't exist
26+
mkdir -p "$CROSS_COMPILERS_DIR"
27+
28+
# Array of architectures to download
29+
declare -a ARCHITECTURES=(
30+
"arm-linux-musleabihf"
31+
"riscv64-linux-musl"
32+
"s390x-linux-musl"
33+
"powerpc64le-linux-musl"
34+
)
35+
36+
# Colors for output
37+
GREEN='\033[0;32m'
38+
BLUE='\033[0;34m'
39+
RED='\033[0;31m'
40+
NC='\033[0m' # No Color
41+
42+
echo -e "${BLUE}Downloading musl.cc cross-compiler toolchains${NC}"
43+
echo "Destination: $CROSS_COMPILERS_DIR"
44+
echo ""
45+
46+
# Check if Git LFS is configured
47+
if ! git lfs version &>/dev/null; then
48+
echo -e "${RED}Error: Git LFS is not installed${NC}"
49+
echo ""
50+
echo "Install Git LFS first:"
51+
echo " macOS: brew install git-lfs"
52+
echo " Linux: apt-get install git-lfs"
53+
echo " Windows: choco install git-lfs"
54+
echo ""
55+
echo "Then initialize it in this repository:"
56+
echo " git lfs install"
57+
exit 1
58+
fi
59+
60+
# Download each toolchain
61+
for arch in "${ARCHITECTURES[@]}"; do
62+
filename="${arch}-cross.tgz"
63+
filepath="$CROSS_COMPILERS_DIR/$filename"
64+
url="https://musl.cc/${filename}"
65+
66+
# Skip if already exists
67+
if [ -f "$filepath" ]; then
68+
echo -e "${GREEN}${NC} $filename already exists, skipping"
69+
continue
70+
fi
71+
72+
echo -e "${BLUE}Downloading${NC} $filename..."
73+
74+
# Download with retries
75+
for attempt in 1 2 3; do
76+
if wget -O "$filepath" "$url"; then
77+
echo -e "${GREEN}${NC} Downloaded: $filename"
78+
break
79+
else
80+
if [ $attempt -lt 3 ]; then
81+
echo " Attempt $attempt failed, retrying in 15 seconds..."
82+
sleep 15
83+
else
84+
echo -e "${RED}${NC} Failed to download $filename after 3 attempts"
85+
rm -f "$filepath"
86+
exit 1
87+
fi
88+
fi
89+
done
90+
done
91+
92+
echo ""
93+
echo -e "${GREEN}All musl.cc cross-compilers downloaded successfully!${NC}"
94+
echo ""
95+
echo "Next steps:"
96+
echo " 1. Add these files to Git LFS tracking:"
97+
echo " git lfs track 'cross-compilers/*.tgz'"
98+
echo " 2. Commit and push:"
99+
echo " git add cross-compilers/ .gitattributes"
100+
echo " git commit -m 'Add musl.cc cross-compiler toolchains'"
101+
echo " git push"

0 commit comments

Comments
 (0)