Skip to content

Commit 4420854

Browse files
committed
[workflow][test] add busybox workflow
Signed-off-by: Shankar Easwaran <seaswara@qti.qualcomm.com>
1 parent a7d892c commit 4420854

3 files changed

Lines changed: 268 additions & 31 deletions

File tree

.github/workflows/busybox-eld.yml

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
name: BusyBox with ELD
2+
3+
on:
4+
pull_request: {} # Uncomment only to test this WF file update.
5+
workflow_dispatch:
6+
#schedule:
7+
# - cron: "0 5 * * *"
8+
9+
permissions:
10+
contents: write
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
fetch-clang-cross-toolchain:
18+
if: github.repository == 'qualcomm/eld'
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- arch: x86_64
24+
toolchain_asset: x86_64-unknown-linux-musl.tar.xz
25+
enabled: 1
26+
- arch: riscv32
27+
toolchain_asset: riscv32-unknown-linux-musl.tar.xz
28+
enabled: 0
29+
- arch: riscv64
30+
toolchain_asset: riscv64-unknown-linux-musl.tar.xz
31+
enabled: 0
32+
- arch: arm
33+
toolchain_asset: arm-unknown-linux-musleabi.tar.xz
34+
enabled: 0
35+
- arch: aarch64
36+
toolchain_asset: aarch64-unknown-linux-musl.tar.xz
37+
enabled: 0
38+
uses: ./.github/workflows/clang-cross-download.yml
39+
with:
40+
runner: ubuntu-latest
41+
workspace: /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}
42+
assets: ${{ matrix.toolchain_asset }}
43+
upload_artifact: true
44+
artifact_name: clang-cross-${{ matrix.arch }}
45+
46+
build-busybox-with-eld:
47+
if: github.repository == 'qualcomm/eld'
48+
needs: fetch-clang-cross-toolchain
49+
runs-on: ubuntu-latest
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
include:
54+
- arch: x86_64
55+
busybox_arch: x86_64
56+
target_triple: x86_64-unknown-linux-musl
57+
toolchain_dir: x86_64-unknown-linux-musl
58+
toolchain_asset: x86_64-unknown-linux-musl.tar.xz
59+
qemu_bin: ""
60+
enabled: 1
61+
- arch: riscv32
62+
busybox_arch: riscv
63+
target_triple: riscv32-unknown-linux-musl
64+
toolchain_dir: riscv32-unknown-linux-musl
65+
toolchain_asset: riscv32-unknown-linux-musl.tar.xz
66+
qemu_bin: qemu-riscv32
67+
enabled: 0
68+
- arch: riscv64
69+
busybox_arch: riscv
70+
target_triple: riscv64-unknown-linux-musl
71+
toolchain_dir: riscv64-unknown-linux-musl
72+
toolchain_asset: riscv64-unknown-linux-musl.tar.xz
73+
qemu_bin: qemu-riscv64
74+
enabled: 0
75+
- arch: arm
76+
busybox_arch: arm
77+
target_triple: arm-unknown-linux-musleabi
78+
toolchain_dir: arm-unknown-linux-musleabi
79+
toolchain_asset: arm-unknown-linux-musleabi.tar.xz
80+
qemu_bin: qemu-arm
81+
enabled: 0
82+
- arch: aarch64
83+
busybox_arch: aarch64
84+
target_triple: aarch64-unknown-linux-musl
85+
toolchain_dir: aarch64-unknown-linux-musl
86+
toolchain_asset: aarch64-unknown-linux-musl.tar.xz
87+
qemu_bin: qemu-aarch64
88+
enabled: 0
89+
steps:
90+
- name: Checkout eld
91+
if: matrix.enabled == 1
92+
uses: actions/checkout@v4
93+
with:
94+
repository: qualcomm/eld
95+
ref: main
96+
fetch-depth: 1
97+
98+
- name: Install dependencies
99+
if: matrix.enabled == 1
100+
shell: bash
101+
run: |
102+
sudo apt update
103+
sudo apt install -y make
104+
if [[ -n "${{ matrix.qemu_bin }}" ]]; then
105+
sudo apt install -y qemu-user
106+
fi
107+
108+
- name: Fetch latest nightly toolset
109+
if: matrix.enabled == 1
110+
uses: ./.github/workflows/FetchNightlyToolset
111+
112+
- name: Download clang-cross toolchain artifact
113+
if: matrix.enabled == 1
114+
uses: actions/download-artifact@v4
115+
with:
116+
name: clang-cross-${{ matrix.arch }}
117+
path: clang-cross
118+
119+
- name: Extract clang-cross toolchain
120+
if: matrix.enabled == 1
121+
shell: bash
122+
env:
123+
TOOLCHAIN_DIR: ${{ matrix.toolchain_dir }}
124+
run: |
125+
set -euo pipefail
126+
mkdir -p "${{ github.workspace }}/${TOOLCHAIN_DIR}"
127+
tar -xf clang-cross/clang-cross-*.tar -C "${{ github.workspace }}/${TOOLCHAIN_DIR}" --strip-components=1
128+
129+
- name: Resolve toolchain paths
130+
if: matrix.enabled == 1
131+
shell: bash
132+
env:
133+
TARGET_TRIPLE: ${{ matrix.target_triple }}
134+
TOOLCHAIN_DIR: ${{ matrix.toolchain_dir }}
135+
run: |
136+
set -euo pipefail
137+
toolchain_base="${{ github.workspace }}/${TOOLCHAIN_DIR}"
138+
cross_root="$(find "${toolchain_base}" -type f -path "*/bin/${TARGET_TRIPLE}-clang" -print -quit | sed 's|/bin/.*$||')"
139+
if [[ -z "${cross_root}" ]]; then
140+
echo "Could not find ${TARGET_TRIPLE}-clang under ${toolchain_base}" >&2
141+
find "${toolchain_base}" -maxdepth 4 -type d -name bin -print >&2 || true
142+
exit 1
143+
fi
144+
eld_bin="$(command -v ld.eld || true)"
145+
if [[ -z "${eld_bin}" ]]; then
146+
echo "Could not find ld.eld in PATH after FetchNightlyToolset" >&2
147+
exit 1
148+
fi
149+
echo "CROSS_TOOLCHAIN_ROOT=${cross_root}" >> "${GITHUB_ENV}"
150+
echo "ELD_BIN=${eld_bin}" >> "${GITHUB_ENV}"
151+
echo "${cross_root}/bin" >> "${GITHUB_PATH}"
152+
echo "Using cross toolchain root: ${cross_root}"
153+
echo "Using ld.eld: ${eld_bin}"
154+
155+
- name: Clone BusyBox
156+
if: matrix.enabled == 1
157+
shell: bash
158+
run: |
159+
git clone --depth 1 https://github.com/mirror/busybox.git
160+
161+
- name: Build BusyBox with ELD
162+
if: matrix.enabled == 1
163+
shell: bash
164+
env:
165+
CROSS_TOOLCHAIN_ROOT: ${{ env.CROSS_TOOLCHAIN_ROOT }}
166+
TARGET_TRIPLE: ${{ matrix.target_triple }}
167+
BUSYBOX_ARCH: ${{ matrix.busybox_arch }}
168+
ELD_BIN: ${{ env.ELD_BIN }}
169+
run: |
170+
set -euo pipefail
171+
export PATH="${CROSS_TOOLCHAIN_ROOT}/bin:${PATH}"
172+
command -v "${TARGET_TRIPLE}-clang"
173+
command -v ld.eld
174+
"${TARGET_TRIPLE}"-clang --version
175+
"${ELD_BIN}" --version
176+
177+
cd busybox
178+
make defconfig
179+
make -j"$(nproc)" \
180+
ARCH="${BUSYBOX_ARCH}" \
181+
CC="${TARGET_TRIPLE}-clang --ld-path=${ELD_BIN}" \
182+
HOSTCC=clang
183+
184+
- name: Run BusyBox tests
185+
if: matrix.enabled == 1
186+
shell: bash
187+
env:
188+
CROSS_TOOLCHAIN_ROOT: ${{ env.CROSS_TOOLCHAIN_ROOT }}
189+
TARGET_TRIPLE: ${{ matrix.target_triple }}
190+
QEMU_BIN: ${{ matrix.qemu_bin }}
191+
run: |
192+
set -euo pipefail
193+
export PATH="${CROSS_TOOLCHAIN_ROOT}/bin:${PATH}"
194+
195+
if [[ -n "${QEMU_BIN}" ]]; then
196+
SYSROOT="${CROSS_TOOLCHAIN_ROOT}/${TARGET_TRIPLE}/sysroot"
197+
if [[ ! -d "${SYSROOT}" ]]; then
198+
SYSROOT="${CROSS_TOOLCHAIN_ROOT}/sysroot"
199+
fi
200+
if [[ ! -d "${SYSROOT}" ]]; then
201+
echo "Unable to find sysroot under ${CROSS_TOOLCHAIN_ROOT}" >&2
202+
exit 1
203+
fi
204+
205+
cd busybox
206+
mv busybox busybox.bin
207+
printf '%s\n' '#!/usr/bin/env bash' \
208+
"exec ${QEMU_BIN} -L ${SYSROOT} \"\$(dirname \"\$0\")/busybox.bin\" \"\$@\"" > busybox
209+
chmod +x busybox
210+
fi
211+
212+
cd busybox/testsuite
213+
SKIP_KNOWN_BUGS=1 SKIP_INTERNET_TESTS=1 ./runtest

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ on:
1010
- '.github/workflows/docs-multiversion.yaml'
1111
- '.github/workflows/ci-win.yml'
1212
- '.github/workflows/clang-cross-download.yml'
13+
- '.github/workflows/FetchClangCrossToolchain.yml'
1314
- '.github/workflows/clang-cross-schedule.yml'
15+
- '.github/workflows/busybox-eld.yml'
1416
- '.github/workflows/nightly-musl-builder.yml'
1517
- '.github/workflows/picolibc-builder.yml'
1618
- '.github/workflows/nightly-test.yml'

.github/workflows/clang-cross-download.yml

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ on:
1717
description: "Comma-separated list of asset names to download"
1818
required: true
1919
type: string
20+
upload_artifact:
21+
description: "Upload extracted toolchains as a GitHub artifact"
22+
required: false
23+
type: boolean
24+
default: false
25+
artifact_name:
26+
description: "Artifact name when upload_artifact is true"
27+
required: false
28+
type: string
29+
default: "clang-cross-toolchains"
2030

2131

2232
permissions:
@@ -26,11 +36,13 @@ jobs:
2636
runs-on: ${{ inputs.runner }}
2737
steps:
2838
- name: Download and extract release assets
39+
id: fetch
2940
shell: bash
3041
env:
3142
WORKSPACE: ${{ inputs.workspace }}
3243
ASSETS: ${{ inputs.assets }}
3344
run: |
45+
set -euo pipefail
3446
api_url="https://api.github.com/repos/cross-tools/clang-cross/releases/latest"
3547
release_json="$(curl -fsSL "${api_url}")"
3648
tag="$(printf '%s' "${release_json}" | jq -r '.tag_name')"
@@ -57,41 +69,51 @@ jobs:
5769
5870
if [[ "${all_extracted}" == "true" ]]; then
5971
echo "Latest release ${tag} already fully extracted."
60-
exit 0
61-
fi
62-
63-
if [[ -d "${root_dir}" ]]; then
64-
find "${root_dir}" -mindepth 1 -maxdepth 1 -type d ! -name "${tag}" -exec rm -rf {} +
65-
fi
66-
rm -rf "${base_dir}"
67-
mkdir -p "${base_dir}"
68-
69-
for asset in "${asset_list[@]}"; do
70-
asset="$(printf '%s' "${asset}" | xargs)"
71-
if [[ -z "${asset}" ]]; then
72-
continue
72+
else
73+
if [[ -d "${root_dir}" ]]; then
74+
find "${root_dir}" -mindepth 1 -maxdepth 1 -type d ! -name "${tag}" -exec rm -rf {} +
7375
fi
76+
rm -rf "${base_dir}"
77+
mkdir -p "${base_dir}"
7478
75-
marker="${base_dir}/.extracted-${asset}"
76-
url="$(printf '%s' "${release_json}" | jq -r --arg name "${asset}" '.assets[] | select(.name == $name) | .browser_download_url')"
77-
if [[ -z "${url}" || "${url}" == "null" ]]; then
78-
echo "Asset not found in release ${tag}: ${asset}" >&2
79-
exit 1
80-
fi
79+
for asset in "${asset_list[@]}"; do
80+
asset="$(printf '%s' "${asset}" | xargs)"
81+
if [[ -z "${asset}" ]]; then
82+
continue
83+
fi
84+
85+
marker="${base_dir}/.extracted-${asset}"
86+
url="$(printf '%s' "${release_json}" | jq -r --arg name "${asset}" '.assets[] | select(.name == $name) | .browser_download_url')"
87+
if [[ -z "${url}" || "${url}" == "null" ]]; then
88+
echo "Asset not found in release ${tag}: ${asset}" >&2
89+
exit 1
90+
fi
8191
82-
tmp_tar="${base_dir}/${asset}"
83-
echo "Downloading ${asset}..."
84-
curl -fsSL -o "${tmp_tar}" "${url}"
92+
tmp_tar="${base_dir}/${asset}"
93+
echo "Downloading ${asset}..."
94+
curl -fsSL -o "${tmp_tar}" "${url}"
8595
86-
echo "Extracting ${asset}..."
87-
tar -xJf "${tmp_tar}" -C "${base_dir}"
88-
rm -f "${tmp_tar}"
89-
asset_base="${asset%.tar.xz}"
90-
asset_base="${asset_base%.tar.gz}"
91-
asset_base="${asset_base%.tar}"
92-
ln -sfn "${base_dir}/${asset_base}" "${WORKSPACE}/${asset_base}"
93-
touch "${marker}"
94-
done
96+
echo "Extracting ${asset}..."
97+
tar -xJf "${tmp_tar}" -C "${base_dir}"
98+
rm -f "${tmp_tar}"
99+
asset_base="${asset%.tar.xz}"
100+
asset_base="${asset_base%.tar.gz}"
101+
asset_base="${asset_base%.tar}"
102+
ln -sfn "${base_dir}/${asset_base}" "${WORKSPACE}/${asset_base}"
103+
touch "${marker}"
104+
done
105+
fi
95106
96107
echo "Symlinks in ${WORKSPACE}:"
97108
find "${WORKSPACE}" -maxdepth 1 -type l -lname "${root_dir}/*" -printf "%p -> %l\n"
109+
110+
artifact_tar="${RUNNER_TEMP}/clang-cross-${tag}.tar"
111+
tar -cf "${artifact_tar}" -C "${base_dir}" .
112+
echo "artifact_tar=${artifact_tar}" >> "${GITHUB_OUTPUT}"
113+
114+
- name: Upload extracted toolchains artifact
115+
if: ${{ inputs.upload_artifact }}
116+
uses: actions/upload-artifact@v4
117+
with:
118+
name: ${{ inputs.artifact_name }}
119+
path: ${{ steps.fetch.outputs.artifact_tar }}

0 commit comments

Comments
 (0)