Skip to content

Commit 14b74fc

Browse files
committed
[WIP] ci: Add LLVM toolchain build job
1 parent 16c502d commit 14b74fc

File tree

1 file changed

+156
-1
lines changed

1 file changed

+156
-1
lines changed

.github/workflows/ci.yml

Lines changed: 156 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,161 @@ jobs:
833833
md5.sum
834834
sha256.sum
835835
836+
# Build LLVM toolchain
837+
build-llvm-toolchain:
838+
name: LLVM Toolchain (${{ matrix.host.name }})
839+
needs: setup
840+
runs-on:
841+
group: ${{ matrix.host.runner }}
842+
container: ${{ matrix.host.container }}
843+
844+
defaults:
845+
run:
846+
shell: bash
847+
848+
strategy:
849+
fail-fast: false
850+
matrix:
851+
host: ${{ fromJSON(needs.setup.outputs.hosts) }}
852+
853+
steps:
854+
- name: Set up build environment (Linux)
855+
if: ${{ runner.os == 'Linux' }}
856+
run: |
857+
# Create workspace directory
858+
WORKSPACE="${RUNNER_TEMP}/workspace"
859+
sudo mkdir -p ${WORKSPACE}
860+
861+
# Allow non-root access to the working directories
862+
sudo chmod -R 777 ${GITHUB_WORKSPACE}
863+
sudo chmod -R 777 ${RUNNER_TEMP}
864+
865+
# Install common dependencies
866+
sudo apt-get update
867+
sudo apt-get install -y qemu-system
868+
869+
# Install dependencies for cross compilation
870+
if [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
871+
# Install MinGW-w64 cross toolchain
872+
sudo apt-get install -y binutils-mingw-w64 gcc-mingw-w64 \
873+
g++-mingw-w64
874+
fi
875+
876+
# Set environment variables
877+
echo "TAR=tar" >> $GITHUB_ENV
878+
echo "WORKSPACE=${WORKSPACE}" >> $GITHUB_ENV
879+
880+
- name: Set up build environment (macOS)
881+
if: ${{ runner.os == 'macOS' }}
882+
run: |
883+
# Create case-sensitive workspace volume for macOS
884+
hdiutil create ${RUNNER_TEMP}/Workspace.sparseimage \
885+
-volname Workspace -type SPARSE -size 150g -fs HFSX
886+
hdiutil mount ${RUNNER_TEMP}/Workspace.sparseimage -mountpoint ${WORKSPACE}
887+
888+
# Install dependencies
889+
brew install qemu zstd
890+
arch -x86_64 brew install zstd
891+
892+
# Set environment variables
893+
echo "TAR=gtar" >> $GITHUB_ENV
894+
echo "WORKSPACE=${WORKSPACE}" >> $GITHUB_ENV
895+
896+
- name: Check out source code
897+
if: ${{ github.event_name != 'pull_request_target' }}
898+
uses: actions/checkout@v4
899+
with:
900+
submodules: recursive
901+
persist-credentials: false
902+
903+
- name: Check out source code (pull request)
904+
if: ${{ github.event_name == 'pull_request_target' }}
905+
uses: actions/checkout@v4
906+
with:
907+
ref: ${{ github.event.pull_request.head.sha }}
908+
submodules: recursive
909+
persist-credentials: false
910+
911+
- name: Setup debug session (pre)
912+
if: always() && needs.setup.outputs.debug == 'toolchain-pre'
913+
uses: mxschmitt/action-tmate@v3
914+
with:
915+
limit-access-to-actor: true
916+
917+
- name: Build LLVM toolchain
918+
run: |
919+
# Create build directory
920+
pushd ${WORKSPACE}
921+
mkdir -p llvm
922+
mkdir -p llvm-build
923+
cd llvm-build
924+
925+
# Configure and generate LLVM build scripts
926+
if [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
927+
LLVM_CMAKE_ARGS+="-DLLVM_TOOLCHAIN_CROSS_BUILD_MINGW=ON "
928+
elif [ "${{ matrix.host.name }}" == "macos-aarch64" ]; then
929+
LLVM_CMAKE_ARGS+="-DCMAKE_OSX_ARCHITECTURES=arm64 "
930+
elif [ "${{ matrix.host.name }}" == "macos-x86_64" ]; then
931+
LLVM_CMAKE_ARGS+="-DCMAKE_OSX_ARCHITECTURES=x86_64 "
932+
fi
933+
934+
cmake \
935+
-GNinja \
936+
--install-prefix ${WORKSPACE}/llvm \
937+
${LLVM_CMAKE_ARGS} \
938+
${GITHUB_WORKSPACE}/scripts/llvm \
939+
|& tee ${GITHUB_WORKSPACE}/llvm-cmake.log
940+
941+
# Build LLVM toolchain
942+
ninja llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-build.log
943+
944+
# Run LLVM tests
945+
ninja check-llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-test.log
946+
947+
# Install LLVM toolchain
948+
ninja install-llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-install.log
949+
popd
950+
951+
# Create archive
952+
ARCHIVE_NAME=toolchain_llvm_${{ matrix.host.name }}
953+
ARCHIVE_FILE=${ARCHIVE_NAME}.${{ matrix.host.archive }}
954+
955+
if [ "${{ matrix.host.archive }}" == "tar.xz" ]; then
956+
XZ_OPT="-T0" \
957+
${TAR} -Jcvf ${ARCHIVE_FILE} \
958+
--owner=0 --group=0 -C ${WORKSPACE} llvm
959+
elif [ "${{ matrix.host.archive }}" == "7z" ]; then
960+
pushd ${WORKSPACE}
961+
7z a -t7z -l ${GITHUB_WORKSPACE}/${ARCHIVE_FILE} llvm
962+
popd
963+
fi
964+
965+
# Compute checksum
966+
md5sum ${ARCHIVE_FILE} > md5.sum
967+
sha256sum ${ARCHIVE_FILE} > sha256.sum
968+
969+
- name: Setup debug session (post)
970+
if: always() && needs.setup.outputs.debug == 'toolchain-post'
971+
uses: mxschmitt/action-tmate@v3
972+
with:
973+
limit-access-to-actor: true
974+
975+
- name: Upload toolchain build log
976+
if: always()
977+
uses: actions/upload-artifact@v4
978+
with:
979+
name: log_toolchain_llvm_${{ matrix.host.name }}
980+
path: '*.log'
981+
982+
- name: Upload toolchain build artifact
983+
uses: actions/upload-artifact@v4
984+
with:
985+
name: toolchain_llvm_${{ matrix.host.name }}
986+
path: |
987+
toolchain_llvm_${{ matrix.host.name }}.${{ matrix.host.archive }}
988+
md5.sum
989+
sha256.sum
990+
836991
# Build host tools
837992
build-hosttools:
838993
name: Host Tools (${{ matrix.host.name }})
@@ -1075,7 +1230,7 @@ jobs:
10751230
# Build distribution bundle
10761231
build-dist-bundle:
10771232
name: Distribution Bundle (${{ matrix.host.name }})
1078-
needs: [ setup, build-gnu-toolchain, build-hosttools, build-cmake-pkg ]
1233+
needs: [ setup, build-gnu-toolchain, build-llvm-toolchain, build-hosttools, build-cmake-pkg ]
10791234
runs-on:
10801235
group: ${{ matrix.host.runner }}
10811236
container: ${{ matrix.host.container }}

0 commit comments

Comments
 (0)