|
| 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 |
0 commit comments