Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 213 additions & 0 deletions .github/workflows/busybox-eld.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
name: BusyBox with ELD

on:
pull_request: {} # Uncomment only to test this WF file update.
workflow_dispatch:
#schedule:
# - cron: "0 5 * * *"

permissions:
contents: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
fetch-clang-cross-toolchain:
if: github.repository == 'qualcomm/eld'
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
toolchain_asset: x86_64-unknown-linux-musl.tar.xz
enabled: 1
- arch: riscv32
toolchain_asset: riscv32-unknown-linux-musl.tar.xz
enabled: 0
- arch: riscv64
toolchain_asset: riscv64-unknown-linux-musl.tar.xz
enabled: 0
- arch: arm
toolchain_asset: arm-unknown-linux-musleabi.tar.xz
enabled: 0
- arch: aarch64
toolchain_asset: aarch64-unknown-linux-musl.tar.xz
enabled: 0
uses: ./.github/workflows/clang-cross-download.yml
with:
runner: ubuntu-latest
workspace: /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}
assets: ${{ matrix.toolchain_asset }}
upload_artifact: true
artifact_name: clang-cross-${{ matrix.arch }}

build-busybox-with-eld:
if: github.repository == 'qualcomm/eld'
needs: fetch-clang-cross-toolchain
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
busybox_arch: x86_64
target_triple: x86_64-unknown-linux-musl
toolchain_dir: x86_64-unknown-linux-musl
toolchain_asset: x86_64-unknown-linux-musl.tar.xz
qemu_bin: ""
enabled: 1
- arch: riscv32
busybox_arch: riscv
target_triple: riscv32-unknown-linux-musl
toolchain_dir: riscv32-unknown-linux-musl
toolchain_asset: riscv32-unknown-linux-musl.tar.xz
qemu_bin: qemu-riscv32
enabled: 0
- arch: riscv64
busybox_arch: riscv
target_triple: riscv64-unknown-linux-musl
toolchain_dir: riscv64-unknown-linux-musl
toolchain_asset: riscv64-unknown-linux-musl.tar.xz
qemu_bin: qemu-riscv64
enabled: 0
- arch: arm
busybox_arch: arm
target_triple: arm-unknown-linux-musleabi
toolchain_dir: arm-unknown-linux-musleabi
toolchain_asset: arm-unknown-linux-musleabi.tar.xz
qemu_bin: qemu-arm
enabled: 0
- arch: aarch64
busybox_arch: aarch64
target_triple: aarch64-unknown-linux-musl
toolchain_dir: aarch64-unknown-linux-musl
toolchain_asset: aarch64-unknown-linux-musl.tar.xz
qemu_bin: qemu-aarch64
enabled: 0
steps:
- name: Checkout eld
if: matrix.enabled == 1
uses: actions/checkout@v4
with:
repository: qualcomm/eld
ref: main
fetch-depth: 1

- name: Install dependencies
if: matrix.enabled == 1
shell: bash
run: |
sudo apt update
sudo apt install -y make
if [[ -n "${{ matrix.qemu_bin }}" ]]; then
sudo apt install -y qemu-user
fi

- name: Fetch latest nightly toolset
if: matrix.enabled == 1
uses: ./.github/workflows/FetchNightlyToolset

- name: Download clang-cross toolchain artifact
if: matrix.enabled == 1
uses: actions/download-artifact@v4
with:
name: clang-cross-${{ matrix.arch }}
path: clang-cross

- name: Extract clang-cross toolchain
if: matrix.enabled == 1
shell: bash
env:
TOOLCHAIN_DIR: ${{ matrix.toolchain_dir }}
run: |
set -euo pipefail
mkdir -p "${{ github.workspace }}/${TOOLCHAIN_DIR}"
tar -xf clang-cross/clang-cross-*.tar -C "${{ github.workspace }}/${TOOLCHAIN_DIR}" --strip-components=1

- name: Resolve toolchain paths
if: matrix.enabled == 1
shell: bash
env:
TARGET_TRIPLE: ${{ matrix.target_triple }}
TOOLCHAIN_DIR: ${{ matrix.toolchain_dir }}
run: |
set -euo pipefail
toolchain_base="${{ github.workspace }}/${TOOLCHAIN_DIR}"
cross_root="$(find "${toolchain_base}" -type f -path "*/bin/${TARGET_TRIPLE}-clang" -print -quit | sed 's|/bin/.*$||')"
if [[ -z "${cross_root}" ]]; then
echo "Could not find ${TARGET_TRIPLE}-clang under ${toolchain_base}" >&2
find "${toolchain_base}" -maxdepth 4 -type d -name bin -print >&2 || true
exit 1
fi
eld_bin="$(command -v ld.eld || true)"
if [[ -z "${eld_bin}" ]]; then
echo "Could not find ld.eld in PATH after FetchNightlyToolset" >&2
exit 1
fi
echo "CROSS_TOOLCHAIN_ROOT=${cross_root}" >> "${GITHUB_ENV}"
echo "ELD_BIN=${eld_bin}" >> "${GITHUB_ENV}"
echo "${cross_root}/bin" >> "${GITHUB_PATH}"
echo "Using cross toolchain root: ${cross_root}"
echo "Using ld.eld: ${eld_bin}"

- name: Clone BusyBox
if: matrix.enabled == 1
shell: bash
run: |
git clone https://github.com/mirror/busybox.git

- name: Build BusyBox with ELD
if: matrix.enabled == 1
shell: bash
env:
CROSS_TOOLCHAIN_ROOT: ${{ env.CROSS_TOOLCHAIN_ROOT }}
TARGET_TRIPLE: ${{ matrix.target_triple }}
BUSYBOX_ARCH: ${{ matrix.busybox_arch }}
ELD_BIN: ${{ env.ELD_BIN }}
run: |
set -euo pipefail
export PATH="${CROSS_TOOLCHAIN_ROOT}/bin:${PATH}"
command -v "${TARGET_TRIPLE}-clang"
command -v ld.eld
"${TARGET_TRIPLE}"-clang --version
"${ELD_BIN}" --version

cd busybox
make defconfig
make -j"$(nproc)" \
ARCH="${BUSYBOX_ARCH}" \
CC="${TARGET_TRIPLE}-clang --ld-path=${ELD_BIN}" \
HOSTCC=clang

- name: Run BusyBox tests
if: matrix.enabled == 1
shell: bash
env:
CROSS_TOOLCHAIN_ROOT: ${{ env.CROSS_TOOLCHAIN_ROOT }}
TARGET_TRIPLE: ${{ matrix.target_triple }}
QEMU_BIN: ${{ matrix.qemu_bin }}
run: |
set -euo pipefail
export PATH="${CROSS_TOOLCHAIN_ROOT}/bin:${PATH}"

if [[ -n "${QEMU_BIN}" ]]; then
SYSROOT="${CROSS_TOOLCHAIN_ROOT}/${TARGET_TRIPLE}/sysroot"
if [[ ! -d "${SYSROOT}" ]]; then
SYSROOT="${CROSS_TOOLCHAIN_ROOT}/sysroot"
fi
if [[ ! -d "${SYSROOT}" ]]; then
echo "Unable to find sysroot under ${CROSS_TOOLCHAIN_ROOT}" >&2
exit 1
fi

cd busybox
mv busybox busybox.bin
printf '%s\n' '#!/usr/bin/env bash' \
"exec ${QEMU_BIN} -L ${SYSROOT} \"\$(dirname \"\$0\")/busybox.bin\" \"\$@\"" > busybox
chmod +x busybox
fi

cd busybox/testsuite
env SKIP_KNOWN_BUGS=1 SKIP_INTERNET_TESTS=1 ./runtest
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ on:
- '.github/workflows/docs-multiversion.yaml'
- '.github/workflows/ci-win.yml'
- '.github/workflows/clang-cross-download.yml'
- '.github/workflows/FetchClangCrossToolchain.yml'
- '.github/workflows/clang-cross-schedule.yml'
- '.github/workflows/busybox-eld.yml'
- '.github/workflows/nightly-musl-builder.yml'
- '.github/workflows/picolibc-builder.yml'
- '.github/workflows/nightly-test.yml'
Expand Down
84 changes: 53 additions & 31 deletions .github/workflows/clang-cross-download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ on:
description: "Comma-separated list of asset names to download"
required: true
type: string
upload_artifact:
description: "Upload extracted toolchains as a GitHub artifact"
required: false
type: boolean
default: false
artifact_name:
description: "Artifact name when upload_artifact is true"
required: false
type: string
default: "clang-cross-toolchains"


permissions:
Expand All @@ -26,11 +36,13 @@ jobs:
runs-on: ${{ inputs.runner }}
steps:
- name: Download and extract release assets
id: fetch
shell: bash
env:
WORKSPACE: ${{ inputs.workspace }}
ASSETS: ${{ inputs.assets }}
run: |
set -euo pipefail
api_url="https://api.github.com/repos/cross-tools/clang-cross/releases/latest"
release_json="$(curl -fsSL "${api_url}")"
tag="$(printf '%s' "${release_json}" | jq -r '.tag_name')"
Expand All @@ -57,41 +69,51 @@ jobs:

if [[ "${all_extracted}" == "true" ]]; then
echo "Latest release ${tag} already fully extracted."
exit 0
fi

if [[ -d "${root_dir}" ]]; then
find "${root_dir}" -mindepth 1 -maxdepth 1 -type d ! -name "${tag}" -exec rm -rf {} +
fi
rm -rf "${base_dir}"
mkdir -p "${base_dir}"

for asset in "${asset_list[@]}"; do
asset="$(printf '%s' "${asset}" | xargs)"
if [[ -z "${asset}" ]]; then
continue
else
if [[ -d "${root_dir}" ]]; then
find "${root_dir}" -mindepth 1 -maxdepth 1 -type d ! -name "${tag}" -exec rm -rf {} +
fi
rm -rf "${base_dir}"
mkdir -p "${base_dir}"

marker="${base_dir}/.extracted-${asset}"
url="$(printf '%s' "${release_json}" | jq -r --arg name "${asset}" '.assets[] | select(.name == $name) | .browser_download_url')"
if [[ -z "${url}" || "${url}" == "null" ]]; then
echo "Asset not found in release ${tag}: ${asset}" >&2
exit 1
fi
for asset in "${asset_list[@]}"; do
asset="$(printf '%s' "${asset}" | xargs)"
if [[ -z "${asset}" ]]; then
continue
fi

marker="${base_dir}/.extracted-${asset}"
url="$(printf '%s' "${release_json}" | jq -r --arg name "${asset}" '.assets[] | select(.name == $name) | .browser_download_url')"
if [[ -z "${url}" || "${url}" == "null" ]]; then
echo "Asset not found in release ${tag}: ${asset}" >&2
exit 1
fi

tmp_tar="${base_dir}/${asset}"
echo "Downloading ${asset}..."
curl -fsSL -o "${tmp_tar}" "${url}"
tmp_tar="${base_dir}/${asset}"
echo "Downloading ${asset}..."
curl -fsSL -o "${tmp_tar}" "${url}"

echo "Extracting ${asset}..."
tar -xJf "${tmp_tar}" -C "${base_dir}"
rm -f "${tmp_tar}"
asset_base="${asset%.tar.xz}"
asset_base="${asset_base%.tar.gz}"
asset_base="${asset_base%.tar}"
ln -sfn "${base_dir}/${asset_base}" "${WORKSPACE}/${asset_base}"
touch "${marker}"
done
echo "Extracting ${asset}..."
tar -xJf "${tmp_tar}" -C "${base_dir}"
rm -f "${tmp_tar}"
asset_base="${asset%.tar.xz}"
asset_base="${asset_base%.tar.gz}"
asset_base="${asset_base%.tar}"
ln -sfn "${base_dir}/${asset_base}" "${WORKSPACE}/${asset_base}"
touch "${marker}"
done
fi

echo "Symlinks in ${WORKSPACE}:"
find "${WORKSPACE}" -maxdepth 1 -type l -lname "${root_dir}/*" -printf "%p -> %l\n"

artifact_tar="${RUNNER_TEMP}/clang-cross-${tag}.tar"
tar -cf "${artifact_tar}" -C "${base_dir}" .
echo "artifact_tar=${artifact_tar}" >> "${GITHUB_OUTPUT}"

- name: Upload extracted toolchains artifact
if: ${{ inputs.upload_artifact }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact_name }}
path: ${{ steps.fetch.outputs.artifact_tar }}
Loading