Skip to content

Commit 70d4cf8

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

3 files changed

Lines changed: 259 additions & 31 deletions

File tree

.github/workflows/busybox-eld.yml

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
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' && matrix.enabled == 1
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+
uses: actions/checkout@v4
92+
with:
93+
repository: qualcomm/eld
94+
ref: main
95+
fetch-depth: 1
96+
97+
- name: Install dependencies
98+
shell: bash
99+
run: |
100+
sudo apt update
101+
sudo apt install -y make
102+
if [[ -n "${{ matrix.qemu_bin }}" ]]; then
103+
sudo apt install -y qemu-user
104+
fi
105+
106+
- name: Fetch latest nightly toolset
107+
uses: ./.github/workflows/FetchNightlyToolset
108+
109+
- name: Download clang-cross toolchain artifact
110+
uses: actions/download-artifact@v4
111+
with:
112+
name: clang-cross-${{ matrix.arch }}
113+
path: clang-cross
114+
115+
- name: Extract clang-cross toolchain
116+
shell: bash
117+
env:
118+
TOOLCHAIN_DIR: ${{ matrix.toolchain_dir }}
119+
run: |
120+
set -euo pipefail
121+
mkdir -p "${{ github.workspace }}/${TOOLCHAIN_DIR}"
122+
tar -xf clang-cross/clang-cross-*.tar -C "${{ github.workspace }}/${TOOLCHAIN_DIR}" --strip-components=1
123+
124+
- name: Resolve toolchain paths
125+
shell: bash
126+
env:
127+
TARGET_TRIPLE: ${{ matrix.target_triple }}
128+
TOOLCHAIN_DIR: ${{ matrix.toolchain_dir }}
129+
run: |
130+
set -euo pipefail
131+
toolchain_base="${{ github.workspace }}/${TOOLCHAIN_DIR}"
132+
cross_root="$(find "${toolchain_base}" -type f -path "*/bin/${TARGET_TRIPLE}-clang" -print -quit | sed 's|/bin/.*$||')"
133+
if [[ -z "${cross_root}" ]]; then
134+
echo "Could not find ${TARGET_TRIPLE}-clang under ${toolchain_base}" >&2
135+
find "${toolchain_base}" -maxdepth 4 -type d -name bin -print >&2 || true
136+
exit 1
137+
fi
138+
eld_bin="$(command -v ld.eld || true)"
139+
if [[ -z "${eld_bin}" ]]; then
140+
echo "Could not find ld.eld in PATH after FetchNightlyToolset" >&2
141+
exit 1
142+
fi
143+
echo "CROSS_TOOLCHAIN_ROOT=${cross_root}" >> "${GITHUB_ENV}"
144+
echo "ELD_BIN=${eld_bin}" >> "${GITHUB_ENV}"
145+
echo "${cross_root}/bin" >> "${GITHUB_PATH}"
146+
echo "Using cross toolchain root: ${cross_root}"
147+
echo "Using ld.eld: ${eld_bin}"
148+
149+
- name: Clone BusyBox
150+
shell: bash
151+
run: |
152+
git clone --depth 1 https://github.com/mirror/busybox.git
153+
154+
- name: Build BusyBox with ELD
155+
shell: bash
156+
env:
157+
CROSS_TOOLCHAIN_ROOT: ${{ env.CROSS_TOOLCHAIN_ROOT }}
158+
TARGET_TRIPLE: ${{ matrix.target_triple }}
159+
BUSYBOX_ARCH: ${{ matrix.busybox_arch }}
160+
ELD_BIN: ${{ env.ELD_BIN }}
161+
run: |
162+
set -euo pipefail
163+
export PATH="${CROSS_TOOLCHAIN_ROOT}/bin:${PATH}"
164+
command -v "${TARGET_TRIPLE}-clang"
165+
command -v ld.eld
166+
"${TARGET_TRIPLE}"-clang --version
167+
"${ELD_BIN}" --version
168+
169+
cd busybox
170+
make defconfig
171+
make -j"$(nproc)" \
172+
ARCH="${BUSYBOX_ARCH}" \
173+
CC="${TARGET_TRIPLE}-clang --ld-path=${ELD_BIN}" \
174+
HOSTCC=clang
175+
176+
- name: Run BusyBox tests
177+
shell: bash
178+
env:
179+
CROSS_TOOLCHAIN_ROOT: ${{ env.CROSS_TOOLCHAIN_ROOT }}
180+
TARGET_TRIPLE: ${{ matrix.target_triple }}
181+
QEMU_BIN: ${{ matrix.qemu_bin }}
182+
run: |
183+
set -euo pipefail
184+
export PATH="${CROSS_TOOLCHAIN_ROOT}/bin:${PATH}"
185+
186+
if [[ -n "${QEMU_BIN}" ]]; then
187+
SYSROOT="${CROSS_TOOLCHAIN_ROOT}/${TARGET_TRIPLE}/sysroot"
188+
if [[ ! -d "${SYSROOT}" ]]; then
189+
SYSROOT="${CROSS_TOOLCHAIN_ROOT}/sysroot"
190+
fi
191+
if [[ ! -d "${SYSROOT}" ]]; then
192+
echo "Unable to find sysroot under ${CROSS_TOOLCHAIN_ROOT}" >&2
193+
exit 1
194+
fi
195+
196+
cd busybox
197+
mv busybox busybox.bin
198+
printf '%s\n' '#!/usr/bin/env bash' \
199+
"exec ${QEMU_BIN} -L ${SYSROOT} \"\$(dirname \"\$0\")/busybox.bin\" \"\$@\"" > busybox
200+
chmod +x busybox
201+
fi
202+
203+
cd busybox/testsuite
204+
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)