Skip to content

Commit 00b608d

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

File tree

1 file changed

+176
-1
lines changed

1 file changed

+176
-1
lines changed

.github/workflows/ci.yml

Lines changed: 176 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,181 @@ 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+
WORKSPACE="/Volumes/Workspace"
885+
hdiutil create ${RUNNER_TEMP}/Workspace.sparseimage \
886+
-volname Workspace -type SPARSE -size 150g -fs HFSX
887+
hdiutil mount ${RUNNER_TEMP}/Workspace.sparseimage -mountpoint ${WORKSPACE}
888+
889+
# Install dependencies
890+
brew install qemu
891+
892+
# Install dependencies for cross compilation
893+
if [ "${{ matrix.host.name }}" == "macos-x86_64" ]; then
894+
# Install x86 Homebrew
895+
arch -x86_64 /bin/bash -c \
896+
"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
897+
898+
# Install x86 dependencies
899+
arch -x86_64 /usr/local/bin/brew install pkg-config zstd
900+
fi
901+
902+
# Set environment variables
903+
echo "TAR=gtar" >> $GITHUB_ENV
904+
echo "WORKSPACE=${WORKSPACE}" >> $GITHUB_ENV
905+
906+
- name: Check out source code
907+
if: ${{ github.event_name != 'pull_request_target' }}
908+
uses: actions/checkout@v4
909+
with:
910+
submodules: recursive
911+
persist-credentials: false
912+
913+
- name: Check out source code (pull request)
914+
if: ${{ github.event_name == 'pull_request_target' }}
915+
uses: actions/checkout@v4
916+
with:
917+
ref: ${{ github.event.pull_request.head.sha }}
918+
submodules: recursive
919+
persist-credentials: false
920+
921+
- name: Setup debug session (pre)
922+
if: always() && needs.setup.outputs.debug == 'toolchain-pre'
923+
uses: mxschmitt/action-tmate@v3
924+
with:
925+
limit-access-to-actor: true
926+
927+
- name: Build LLVM toolchain
928+
run: |
929+
# Set x86 Homebrew environment if cross compiling
930+
if [ "${{ matrix.host.name }}" == "macos-x86_64" ]; then
931+
eval "$(/usr/local/bin/brew shellenv)"
932+
fi
933+
934+
# DEBUG BEGIN
935+
which pkg-config
936+
pkg-config --libs libzstd
937+
# DEBUG END
938+
939+
# Create build directory
940+
pushd ${WORKSPACE}
941+
mkdir -p llvm
942+
mkdir -p llvm-build
943+
cd llvm-build
944+
945+
# Configure and generate LLVM build scripts
946+
if [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
947+
LLVM_CMAKE_ARGS+="-DLLVM_TOOLCHAIN_CROSS_BUILD_MINGW=ON "
948+
elif [ "${{ matrix.host.name }}" == "macos-aarch64" ]; then
949+
LLVM_CMAKE_ARGS+="-DCMAKE_OSX_ARCHITECTURES=arm64 "
950+
elif [ "${{ matrix.host.name }}" == "macos-x86_64" ]; then
951+
LLVM_CMAKE_ARGS+="-DCMAKE_OSX_ARCHITECTURES=x86_64 "
952+
fi
953+
954+
cmake \
955+
-GNinja \
956+
--install-prefix ${WORKSPACE}/llvm \
957+
${LLVM_CMAKE_ARGS} \
958+
${GITHUB_WORKSPACE}/scripts/llvm \
959+
|& tee ${GITHUB_WORKSPACE}/llvm-cmake.log
960+
961+
# Build LLVM toolchain
962+
ninja llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-build.log
963+
964+
# Run LLVM tests
965+
ninja check-llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-test.log
966+
967+
# Install LLVM toolchain
968+
ninja install-llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-install.log
969+
popd
970+
971+
# Create archive
972+
ARCHIVE_NAME=toolchain_llvm_${{ matrix.host.name }}
973+
ARCHIVE_FILE=${ARCHIVE_NAME}.${{ matrix.host.archive }}
974+
975+
if [ "${{ matrix.host.archive }}" == "tar.xz" ]; then
976+
XZ_OPT="-T0" \
977+
${TAR} -Jcvf ${ARCHIVE_FILE} \
978+
--owner=0 --group=0 -C ${WORKSPACE} llvm
979+
elif [ "${{ matrix.host.archive }}" == "7z" ]; then
980+
pushd ${WORKSPACE}
981+
7z a -t7z -l ${GITHUB_WORKSPACE}/${ARCHIVE_FILE} llvm
982+
popd
983+
fi
984+
985+
# Compute checksum
986+
md5sum ${ARCHIVE_FILE} > md5.sum
987+
sha256sum ${ARCHIVE_FILE} > sha256.sum
988+
989+
- name: Setup debug session (post)
990+
if: always() && needs.setup.outputs.debug == 'toolchain-post'
991+
uses: mxschmitt/action-tmate@v3
992+
with:
993+
limit-access-to-actor: true
994+
995+
- name: Upload toolchain build log
996+
if: always()
997+
uses: actions/upload-artifact@v4
998+
with:
999+
name: log_toolchain_llvm_${{ matrix.host.name }}
1000+
path: '*.log'
1001+
1002+
- name: Upload toolchain build artifact
1003+
uses: actions/upload-artifact@v4
1004+
with:
1005+
name: toolchain_llvm_${{ matrix.host.name }}
1006+
path: |
1007+
toolchain_llvm_${{ matrix.host.name }}.${{ matrix.host.archive }}
1008+
md5.sum
1009+
sha256.sum
1010+
8361011
# Build host tools
8371012
build-hosttools:
8381013
name: Host Tools (${{ matrix.host.name }})
@@ -1075,7 +1250,7 @@ jobs:
10751250
# Build distribution bundle
10761251
build-dist-bundle:
10771252
name: Distribution Bundle (${{ matrix.host.name }})
1078-
needs: [ setup, build-gnu-toolchain, build-hosttools, build-cmake-pkg ]
1253+
needs: [ setup, build-gnu-toolchain, build-llvm-toolchain, build-hosttools, build-cmake-pkg ]
10791254
runs-on:
10801255
group: ${{ matrix.host.runner }}
10811256
container: ${{ matrix.host.container }}

0 commit comments

Comments
 (0)