Skip to content
Merged
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
28 changes: 25 additions & 3 deletions .github/workflows/base-build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

name: base-build

on:
Expand All @@ -6,6 +7,12 @@ on:
build-script:
required: true
type: string
is-nightly:
required: false
type: boolean
arch:
required: false
type: string

permissions:
contents: read
Expand All @@ -17,6 +24,8 @@ concurrency:
jobs:
build:
runs-on: self-hosted
env:
ARTIFACT_DIR: ${{ github.workspace }}/nightly-toolchain

steps:
- name: Cleanup workspace
Expand All @@ -25,8 +34,7 @@ jobs:
set -euo pipefail
echo "Cleaning workspace: ${GITHUB_WORKSPACE}"
shopt -s dotglob nullglob
rm -rf "${GITHUB_WORKSPACE}/"*
rm -rf "${GITHUB_WORKSPACE}/"..?*
rm -rf "${GITHUB_WORKSPACE:?}/"*

- name: Checkout source
uses: actions/checkout@v4
Expand All @@ -40,4 +48,18 @@ jobs:
shell: bash
run: |
set -euo pipefail
${{ inputs.build-script }}
build_script="${{ inputs.build-script }}"
if [ "${{ inputs.is-nightly }}" = "true" ]; then
build_script="$build_script --artifact-dir $ARTIFACT_DIR --nightly"
fi
echo "Running: $build_script"
$build_script

- name: Upload Artifact
if: ${{ inputs.is-nightly && success() }}
uses: actions/upload-artifact@v4
with:
name: cpullvm-toolchain-${{ github.ref_name }}-Linux-${{ inputs.arch }}
path: ${{ env.ARTIFACT_DIR }}/*.{txz,tgz}
if-no-files-found: ignore
retention-days: 30
9 changes: 7 additions & 2 deletions .github/workflows/nightly-aarch64.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: nightly-aarch64
name: Nightly-Linux-AArch64

on:
repository_dispatch:
types: [trigger-nightly-aarch64-linux]

schedule:
- cron: '0 5 * * *' # 9 PM PT (UTC)

jobs:
base:
uses: ./.github/workflows/base-build.yml
with:
build-script: "src/qualcomm-software/embedded/scripts/build.sh --artifact-dir /local/mnt/workspace/nightly-toolchain/${{ github.ref_name }} --aarch64-build"
build-script: "src/qualcomm-software/embedded/scripts/build.sh --aarch64-build"
is-nightly: true
arch: AArch64
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: nightly
name: Nightly-Linux-x86_64

on:
repository_dispatch:
types: [trigger-nightly-x86-linux]

schedule:
- cron: '0 5 * * *' # 9 PM PT (UTC)

jobs:
base:
uses: ./.github/workflows/base-build.yml
with:
build-script: "src/qualcomm-software/embedded/scripts/build.sh --artifact-dir /local/mnt/workspace/nightly-toolchain/${{ github.ref_name }}"
build-script: "src/qualcomm-software/embedded/scripts/build.sh"
is-nightly: true
arch: x86_64
62 changes: 44 additions & 18 deletions qualcomm-software/embedded/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#!/usr/bin/env bash

# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
Expand All @@ -12,6 +13,10 @@

set -euo pipefail

log() { echo -e "\033[1;34m[log]\033[0m $(date '+%F %T') $*"; }
warn() { echo -e "\033[1;33m[warn]\033[0m $(date '+%F %T') $*"; }
trap 'warn "Script failed at line $LINENO: \"$BASH_COMMAND\" (exit code: $?)"; exit 1' ERR

readonly ELD_REPO_URL="https://github.com/qualcomm/eld.git"
readonly ELD_BRANCH="release/21.x"

Expand All @@ -31,9 +36,10 @@ INSTALL_DIR_AARCH64="${INSTALL_DIR}/aarch64"
ARTIFACT_DIR=""
SKIP_TESTS="false"
JOBS="${JOBS:-$(nproc)}"
CLEAN="false"
AARCH64_BUILD="false"
NIGHTLY="false"

log() { echo -e "\033[1;34m[log]\033[0m $*"; }
warn() { echo -e "\033[1;33m[warn]\033[0m $*"; }

usage() {
cat <<'EOF'
Expand All @@ -45,26 +51,25 @@ Options:
--skip-tests Skip LLVM test steps
--aarch64-sysroot <path> AArch64 sysroot (default: /usr/aarch64-linux-gnu)
--aarch64-build AArch64 build
--nightly Nightly build
--clean Delete and recreate build/install dirs

Examples:
./build.sh --artifact-dir /tmp/artifacts
EOF
}

CLEAN="false"
AARCH64_BUILD="false"

# --- Parse args ---
while [[ $# -gt 0 ]]; do
case "$1" in
--artifact-dir) ARTIFACT_DIR="$2"; shift 2 ;;
--skip-tests) SKIP_TESTS="true"; shift ;;
--aarch64-build) AARCH64_BUILD="true"; shift ;;
--nightly) NIGHTLY="true"; shift ;;
--aarch64-sysroot) AARCH64_SYSROOT="$2"; shift 2 ;;
--clean) CLEAN="true"; shift ;;
-h|--help) usage; exit 0 ;;
*) echo "Unknown arg: $1"; usage; exit 1 ;;
*) warn "Unknown arg: $1"; usage; exit 1 ;;
esac
done

Expand Down Expand Up @@ -109,9 +114,9 @@ fi
if [[ ! -d "${REPO_ROOT}/llvm/tools/eld/.git" ]]; then
log "Cloning ELD to ${REPO_ROOT}/llvm/tools/eld"
git clone "${ELD_REPO_URL}" "${SRC_DIR}/llvm/tools/eld" -b "${ELD_BRANCH}"
# Pin ELD to known commit
ELD_PINNED_COMMIT="${ELD_PINNED_COMMIT:-65ea860802c41ef5c0becff9750a350495de27b0}"
pushd "${SRC_DIR}/llvm/tools/eld" >/dev/null
git checkout "65ea860802c41ef5c0becff9750a350495de27b0"
git checkout "${ELD_PINNED_COMMIT}"
popd >/dev/null
else
log "ELD already present under llvm/tools, leaving as-is"
Expand Down Expand Up @@ -332,7 +337,7 @@ for lib in "${musl_components[@]}"; do
done

# --- c++ libs ---
echo "Build c++ libs ..."
log "Build c++ libs ..."

declare -A Triples
Triples["aarch64-none-elf"]="aarch64-none-elf"
Expand Down Expand Up @@ -386,28 +391,49 @@ for VARIANT in "aarch64-none-elf" "aarch64-pacret-b-key-bti-none-elf" "armv7-non
ninja
ninja install
popd >/dev/null
echo "c++ libs install ..."
log "c++ libs install ..."
done
echo "Build and installation complete."
log "Build and installation complete."

# --- Create artifact ---
log "Creating artifact tarball"

short_sha="$(git -C "${SRC_DIR}" rev-parse --short HEAD)"
suffix="$(date +%Y%m%d)"
archive_root="${BUILD_DIR}"
archive_dir="${INSTALL_DIR}"
COMPRESS_EXT="tgz"
COMPRESS_FLAG="-czvf"
archive_name="cpullvm-toolchain-${ELD_BRANCH##*/}-Linux-x86_64-${short_sha}-${suffix}.${COMPRESS_EXT}"

if [[ "${AARCH64_BUILD}" == "true" ]]; then
log "Preparing AARCH64 build"
mkdir -p "${INSTALL_DIR_AARCH64}"
cp -r "${INSTALL_DIR}"/aarch64-* "${INSTALL_DIR}"/armv7-* "${INSTALL_DIR_AARCH64}/"
cp -r "${INSTALL_DIR}"/lib/clang/[0-9]*/lib "${INSTALL_DIR_AARCH64}"/lib/clang/[0-9]*/
tar_file="${BUILD_DIR_AARCH64}/${ELD_BRANCH##*/}_${short_sha}_aarch64_$(date +%Y%m%d).tgz"
tar -czvf "${tar_file}" "${INSTALL_DIR_AARCH64}"
else
tar_file="${BUILD_DIR}/${ELD_BRANCH##*/}_${short_sha}_$(date +%Y%m%d).tgz"
tar -czvf "${tar_file}" "${INSTALL_DIR}"
cp -r "${INSTALL_DIR}"/lib/clang/[0-9]*/lib "${INSTALL_DIR_AARCH64}/lib/clang/[0-9]*/"
archive_root="${BUILD_DIR_AARCH64}"
archive_dir="${INSTALL_DIR_AARCH64}"
archive_name="cpullvm-toolchain-${ELD_BRANCH##*/}-Linux-AArch64-${short_sha}-${suffix}.${COMPRESS_EXT}"
fi

if [[ "${NIGHTLY}" == "true" ]]; then
log "Applying NIGHTLY compression settings"
COMPRESS_EXT="txz"
COMPRESS_FLAG="-cJvf --threads=${JOBS:-$(nproc)}"
archive_name="${archive_name%.tgz}_nightly.${COMPRESS_EXT}"
fi

# Create tarball
tar_file="${archive_root}/${archive_name}"
log "Compressing ${archive_dir} into ${tar_file}"
tar ${COMPRESS_FLAG} "${tar_file}" "${archive_dir}"

# Copy artifact if destination provided
if [[ -n "${ARTIFACT_DIR}" ]]; then
mkdir -p "${ARTIFACT_DIR}"
cp "${tar_file}" "${ARTIFACT_DIR}/"
log "Artifact copied to ${ARTIFACT_DIR}/${tar_file}"
log "Artifact copied to ${ARTIFACT_DIR}/${archive_name}"
else
warn "Artifact left at ${tar_file}"
fi

Loading