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 16c502d commit 14b74fc
Showing 1 changed file with 156 additions and 1 deletion.
157 changes: 156 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,161 @@ 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}
# 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 qemu-system
# 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: |
# 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}
# Install dependencies
brew install qemu zstd
arch -x86_64 brew install zstd
# 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
mkdir -p llvm-build
cd llvm-build
# Configure and generate LLVM build scripts
if [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
LLVM_CMAKE_ARGS+="-DLLVM_TOOLCHAIN_CROSS_BUILD_MINGW=ON "
elif [ "${{ matrix.host.name }}" == "macos-aarch64" ]; then
LLVM_CMAKE_ARGS+="-DCMAKE_OSX_ARCHITECTURES=arm64 "
elif [ "${{ matrix.host.name }}" == "macos-x86_64" ]; then
LLVM_CMAKE_ARGS+="-DCMAKE_OSX_ARCHITECTURES=x86_64 "
fi
cmake \
-GNinja \
--install-prefix ${WORKSPACE}/llvm \
${LLVM_CMAKE_ARGS} \
${GITHUB_WORKSPACE}/scripts/llvm \
|& tee ${GITHUB_WORKSPACE}/llvm-cmake.log
# 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
# Install LLVM toolchain
ninja install-llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-install.log
popd
# Create archive
ARCHIVE_NAME=toolchain_llvm_${{ matrix.host.name }}
ARCHIVE_FILE=${ARCHIVE_NAME}.${{ matrix.host.archive }}
if [ "${{ matrix.host.archive }}" == "tar.xz" ]; then
XZ_OPT="-T0" \
${TAR} -Jcvf ${ARCHIVE_FILE} \
--owner=0 --group=0 -C ${WORKSPACE} llvm
elif [ "${{ matrix.host.archive }}" == "7z" ]; then
pushd ${WORKSPACE}
7z a -t7z -l ${GITHUB_WORKSPACE}/${ARCHIVE_FILE} llvm
popd
fi
# 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 +1230,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 14b74fc

Please sign in to comment.