Skip to content

Commit 6053256

Browse files
committed
fix(ci): use musl-gcc like xlings project (self-contained sysroot)
Follow the exact same toolchain approach as openxlings/xlings CI: - Linux: musl-gcc 15.1.0 with --sdk/--cross/--cc/--cxx absolute paths - macOS: llvm 20.1.7 with --toolchain=llvm --sdk/--cc/--cxx - Windows: MSVC auto-detected musl-gcc bundles its own libc so no system crt1.o/stdio.h needed.
1 parent 28230e8 commit 6053256

2 files changed

Lines changed: 26 additions & 35 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@ jobs:
3333
- name: Detect changed packages
3434
id: detect
3535
run: |
36-
# Determine the base ref for comparison
3736
if [ "${{ github.event_name }}" = "pull_request" ]; then
3837
BASE="${{ github.event.pull_request.base.sha }}"
3938
else
4039
BASE="${{ github.event.before }}"
4140
fi
4241
43-
# Check if CI config itself changed — if so, build all
4442
CI_CHANGED=$(git diff --name-only "$BASE" HEAD -- .github/ .xlings.json || true)
4543
if [ -n "$CI_CHANGED" ]; then
4644
echo "build_all=true" >> "$GITHUB_OUTPUT"
@@ -49,20 +47,14 @@ jobs:
4947
echo "build_all=false" >> "$GITHUB_OUTPUT"
5048
fi
5149
52-
# Collect changed package names from packages/ and tests/ directories
5350
CHANGED_DIRS=$(git diff --name-only "$BASE" HEAD -- packages/ tests/ | \
5451
sed -n 's|^packages/./\([^/]*\)/.*|\1|p; s|^tests/./\([^/]*\)/.*|\1|p' | \
5552
sort -u)
5653
57-
# Build JSON array of changed packages
5854
JSON="["
5955
FIRST=true
6056
for pkg in $CHANGED_DIRS; do
61-
if [ "$FIRST" = true ]; then
62-
FIRST=false
63-
else
64-
JSON="$JSON,"
65-
fi
57+
if [ "$FIRST" = true ]; then FIRST=false; else JSON="$JSON,"; fi
6658
JSON="$JSON\"$pkg\""
6759
done
6860
JSON="$JSON]"
@@ -86,54 +78,56 @@ jobs:
8678
- uses: actions/checkout@v4
8779
- uses: ./.github/actions/setup-toolchain
8880

81+
# --- Configure (same pattern as openxlings/xlings CI) ---
82+
8983
- name: Configure (linux)
9084
if: runner.os == 'Linux'
9185
working-directory: tests
9286
run: |
93-
GCC_VERSION=$(python3 -c "import json; d=json.load(open('../.xlings.json')); print(d['workspace']['gcc']['linux'])")
94-
GCC_BIN="$HOME/.xlings/data/xpkgs/xim-x-gcc/${GCC_VERSION}/bin"
95-
echo "Using gcc ${GCC_VERSION} from ${GCC_BIN}"
96-
"${GCC_BIN}/gcc" --version | head -1
87+
MUSL_GCC_VERSION=$(python3 -c "import json; d=json.load(open('../.xlings.json')); print(d['workspace']['musl-gcc']['linux'])")
88+
MUSL_SDK="$HOME/.xlings/data/xpkgs/xim-x-musl-gcc/${MUSL_GCC_VERSION}"
89+
echo "Using musl-gcc ${MUSL_GCC_VERSION} from ${MUSL_SDK}"
90+
"${MUSL_SDK}/bin/x86_64-linux-musl-gcc" --version | head -1
9791
98-
# xlings gcc needs system sysroot for headers and CRT files
99-
export LIBRARY_PATH="/usr/lib/x86_64-linux-gnu:/usr/lib:/lib/x86_64-linux-gnu"
100-
export C_INCLUDE_PATH="/usr/include:/usr/include/x86_64-linux-gnu"
101-
export CPLUS_INCLUDE_PATH="/usr/include:/usr/include/x86_64-linux-gnu"
102-
export PATH="${GCC_BIN}:$PATH"
103-
104-
xmake f -P . -y -vv
92+
xmake f -P . -y -vv \
93+
--sdk="${MUSL_SDK}" \
94+
--cross=x86_64-linux-musl- \
95+
--cc="${MUSL_SDK}/bin/x86_64-linux-musl-gcc" \
96+
--cxx="${MUSL_SDK}/bin/x86_64-linux-musl-g++"
10597
10698
- name: Configure (macos)
10799
if: runner.os == 'macOS'
108100
working-directory: tests
109101
run: |
110102
LLVM_VERSION=$(python3 -c "import json; d=json.load(open('../.xlings.json')); print(d['workspace']['llvm']['macosx'])")
111-
LLVM_BIN="$HOME/.xlings/data/xpkgs/xim-x-llvm/${LLVM_VERSION}/bin"
112-
echo "Using llvm ${LLVM_VERSION} from ${LLVM_BIN}"
113-
"${LLVM_BIN}/clang" --version | head -1
103+
LLVM_SDK="$HOME/.xlings/data/xpkgs/xim-x-llvm/${LLVM_VERSION}"
104+
echo "Using llvm ${LLVM_VERSION} from ${LLVM_SDK}"
105+
"${LLVM_SDK}/bin/clang" --version | head -1
114106
115-
export PATH="${LLVM_BIN}:$PATH"
116-
xmake f -P . -y -vv --toolchain=llvm
107+
xmake f -P . -y -vv \
108+
--toolchain=llvm \
109+
--sdk="${LLVM_SDK}" \
110+
--cc="${LLVM_SDK}/bin/clang" \
111+
--cxx="${LLVM_SDK}/bin/clang++"
117112
118113
- name: Configure (windows)
119114
if: runner.os == 'Windows'
120115
working-directory: tests
121116
run: xmake f -P . -y -vv
122117

118+
# --- Build and test ---
119+
123120
- name: Build and test (unix)
124121
if: runner.os != 'Windows'
125122
working-directory: tests
126123
env:
127124
BUILD_ALL: ${{ needs.detect-changes.outputs.build_all }}
128125
CHANGED_PACKAGES: ${{ needs.detect-changes.outputs.packages }}
129126
run: |
130-
# Put correct compiler on PATH and set system paths for xmake subprocesses
127+
# Same compiler PATH as configure step
131128
if [ "$(uname)" = "Linux" ]; then
132-
GCC_VERSION=$(python3 -c "import json; d=json.load(open('../.xlings.json')); print(d['workspace']['gcc']['linux'])")
133-
export PATH="$HOME/.xlings/data/xpkgs/xim-x-gcc/${GCC_VERSION}/bin:$PATH"
134-
export LIBRARY_PATH="/usr/lib/x86_64-linux-gnu:/usr/lib:/lib/x86_64-linux-gnu"
135-
export C_INCLUDE_PATH="/usr/include:/usr/include/x86_64-linux-gnu"
136-
export CPLUS_INCLUDE_PATH="/usr/include:/usr/include/x86_64-linux-gnu"
129+
MUSL_GCC_VERSION=$(python3 -c "import json; d=json.load(open('../.xlings.json')); print(d['workspace']['musl-gcc']['linux'])")
130+
export PATH="$HOME/.xlings/data/xpkgs/xim-x-musl-gcc/${MUSL_GCC_VERSION}/bin:$PATH"
137131
else
138132
LLVM_VERSION=$(python3 -c "import json; d=json.load(open('../.xlings.json')); print(d['workspace']['llvm']['macosx'])")
139133
export PATH="$HOME/.xlings/data/xpkgs/xim-x-llvm/${LLVM_VERSION}/bin:$PATH"
@@ -156,12 +150,10 @@ jobs:
156150
echo "Building changed targets: $TARGETS"
157151
fi
158152
159-
# Build and run each target
160153
for target in $TARGETS; do
161154
echo "=== Building $target ==="
162155
xmake build -P . -y "$target"
163156
164-
# llmapi requires API key, only build don't run
165157
if [ "$target" = "llmapi_test" ]; then
166158
echo "Skipping run for $target (requires API key)"
167159
continue
@@ -182,7 +174,6 @@ jobs:
182174
BUILD_ALL: ${{ needs.detect-changes.outputs.build_all }}
183175
CHANGED_PACKAGES: ${{ needs.detect-changes.outputs.packages }}
184176
run: |
185-
# Collect test targets
186177
$targets = @()
187178
if ($env:BUILD_ALL -eq "true") {
188179
$targets = Get-ChildItem -Recurse -Filter "xmake.lua" -Path "*/*" |

.xlings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"workspace": {
33
"xmake": "3.0.7",
4-
"gcc": { "linux": "15.1.0" },
4+
"musl-gcc": { "linux": "15.1.0" },
55
"llvm": { "macosx": "20.1.7" }
66
}
77
}

0 commit comments

Comments
 (0)