Skip to content

Commit

Permalink
[WIP] ci: Add LLVM toolchain build job
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanosio committed Oct 22, 2024
1 parent 7b0201e commit a54d786
Showing 1 changed file with 165 additions and 1 deletion.
166 changes: 165 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,170 @@ jobs:
md5.sum
sha256.sum
# Build LLVM toolchain
build-llvm-toolchain:
name: LLVM Toolchain (${{ matrix.host.name }})
needs: setup
runs-on:
group: ${{ matrix.host.runner }}
container: ${{ matrix.host.container }}

defaults:
run:
shell: bash

strategy:
fail-fast: false
matrix:
host: ${{ fromJSON(needs.setup.outputs.hosts) }}

steps:
- name: Set up build environment (Linux)
if: ${{ runner.os == 'Linux' }}
run: |
# Create workspace directory
WORKSPACE="${RUNNER_TEMP}/workspace"
sudo mkdir -p ${WORKSPACE}
# Clean up working directories
shopt -s dotglob
sudo rm -rf ${GITHUB_WORKSPACE}/*
sudo rm -rf ${WORKSPACE}/*
shopt -u dotglob
# Allow non-root access to the working directories
sudo chmod -R 777 ${GITHUB_WORKSPACE}
sudo chmod -R 777 ${RUNNER_TEMP}
# Install common dependencies
sudo apt-get update
sudo apt-get install -y cmake ninja-build qemu
sudo pip install meson
# Install dependencies for cross compilation
if [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
# Install MinGW-w64 cross toolchain
sudo apt-get install -y binutils-mingw-w64 gcc-mingw-w64 \
g++-mingw-w64
fi
# Set environment variables
echo "TAR=tar" >> $GITHUB_ENV
echo "WORKSPACE=${WORKSPACE}" >> $GITHUB_ENV
- name: Set up build environment (macOS)
if: ${{ runner.os == 'macOS' }}
run: |
# Delete workspace from the previous run
WORKSPACE="/Volumes/Workspace"
if [ -d ${WORKSPACE} ]; then
# Get disk device name
OLDDISK=$(diskutil info -plist "${WORKSPACE}" |
plutil -extract ParentWholeDisk xml1 - -o - |
sed -n "s/.*<string>\(.*\)<\/string>.*/\1/p")
# Force unmount and eject to deallocate disk blocks
if [ ! -z "${OLDDISK}" ]; then
diskutil unmountDisk force ${OLDDISK}
diskutil eject ${OLDDISK}
fi
fi
# Clean up working directories
shopt -s dotglob
rm -rf ${GITHUB_WORKSPACE}/*
rm -f ${RUNNER_TEMP}/Workspace.sparseimage
shopt -u dotglob
# Create case-sensitive workspace volume for macOS
hdiutil create ${RUNNER_TEMP}/Workspace.sparseimage \
-volname Workspace -type SPARSE -size 150g -fs HFSX
hdiutil mount ${RUNNER_TEMP}/Workspace.sparseimage -mountpoint ${WORKSPACE}
# Set environment variables
echo "TAR=gtar" >> $GITHUB_ENV
echo "WORKSPACE=${WORKSPACE}" >> $GITHUB_ENV
- name: Check out source code
if: ${{ github.event_name != 'pull_request_target' }}
uses: actions/checkout@v4
with:
submodules: recursive
persist-credentials: false

- name: Check out source code (pull request)
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
submodules: recursive
persist-credentials: false

- name: Setup debug session (pre)
if: always() && needs.setup.outputs.debug == 'toolchain-pre'
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true

- name: Build LLVM toolchain
run: |
# Create build directory
pushd ${WORKSPACE}
mkdir -p llvm-build
cd llvm-build
# Configure and generate LLVM build scripts
if [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
cmake \
-GNinja \
-DLLVM_TOOLCHAIN_CROSS_BUILD_MINGW=ON \
${GITHUB_WORKSPACE}/scripts/llvm
else
cmake \
-GNinja \
${GITHUB_WORKSPACE}/scripts/llvm
fi
# Build LLVM toolchain
ninja llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-build.log
# Run LLVM tests
ninja check-llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-test.log
# Package
ninja package-llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-package.log
popd
# Prepare archive
ARCHIVE_NAME=toolchain_gnu_${{ matrix.host.name }}
ARCHIVE_FILE=${ARCHIVE_NAME}.${{ matrix.host.archive }}
# Compute checksum
md5sum ${ARCHIVE_FILE} > md5.sum
sha256sum ${ARCHIVE_FILE} > sha256.sum
- name: Setup debug session (post)
if: always() && needs.setup.outputs.debug == 'toolchain-post'
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true

- name: Upload toolchain build log
if: always()
uses: actions/upload-artifact@v4
with:
name: log_toolchain_llvm_${{ matrix.host.name }}
path: *.log

- name: Upload toolchain build artifact
uses: actions/upload-artifact@v4
with:
name: toolchain_llvm_${{ matrix.host.name }}
path: |
toolchain_llvm_${{ matrix.host.name }}.${{ matrix.host.archive }}
md5.sum
sha256.sum
# Build host tools
build-hosttools:
name: Host Tools (${{ matrix.host.name }})
Expand Down Expand Up @@ -1075,7 +1239,7 @@ jobs:
# Build distribution bundle
build-dist-bundle:
name: Distribution Bundle (${{ matrix.host.name }})
needs: [ setup, build-gnu-toolchain, build-hosttools, build-cmake-pkg ]
needs: [ setup, build-gnu-toolchain, build-llvm-toolchain, build-hosttools, build-cmake-pkg ]
runs-on:
group: ${{ matrix.host.runner }}
container: ${{ matrix.host.container }}
Expand Down

0 comments on commit a54d786

Please sign in to comment.