@@ -833,6 +833,175 @@ 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+ # Clean up working directories
862+ shopt -s dotglob
863+ sudo rm -rf ${GITHUB_WORKSPACE}/*
864+ sudo rm -rf ${WORKSPACE}/*
865+ shopt -u dotglob
866+
867+ # Allow non-root access to the working directories
868+ sudo chmod -R 777 ${GITHUB_WORKSPACE}
869+ sudo chmod -R 777 ${RUNNER_TEMP}
870+
871+ # Install common dependencies
872+ sudo apt-get update
873+ sudo apt-get install -y ninja-build qemu
874+ sudo pip install meson
875+
876+ # Install up-to-date CMake
877+ echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal-rc main' | sudo tee -a /etc/apt/sources.list.d/kitware.list >/dev/null
878+ sudo apt-get update
879+ sudo apt-get install cmake
880+
881+ # Install dependencies for cross compilation
882+ if [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
883+ # Install MinGW-w64 cross toolchain
884+ sudo apt-get install -y binutils-mingw-w64 gcc-mingw-w64 \
885+ g++-mingw-w64
886+ fi
887+
888+ # Set environment variables
889+ echo "TAR=tar" >> $GITHUB_ENV
890+ echo "WORKSPACE=${WORKSPACE}" >> $GITHUB_ENV
891+
892+ - name : Set up build environment (macOS)
893+ if : ${{ runner.os == 'macOS' }}
894+ run : |
895+ # Delete workspace from the previous run
896+ WORKSPACE="/Volumes/Workspace"
897+ if [ -d ${WORKSPACE} ]; then
898+ # Get disk device name
899+ OLDDISK=$(diskutil info -plist "${WORKSPACE}" |
900+ plutil -extract ParentWholeDisk xml1 - -o - |
901+ sed -n "s/.*<string>\(.*\)<\/string>.*/\1/p")
902+
903+ # Force unmount and eject to deallocate disk blocks
904+ if [ ! -z "${OLDDISK}" ]; then
905+ diskutil unmountDisk force ${OLDDISK}
906+ diskutil eject ${OLDDISK}
907+ fi
908+ fi
909+
910+ # Clean up working directories
911+ shopt -s dotglob
912+ rm -rf ${GITHUB_WORKSPACE}/*
913+ rm -f ${RUNNER_TEMP}/Workspace.sparseimage
914+ shopt -u dotglob
915+
916+ # Create case-sensitive workspace volume for macOS
917+ hdiutil create ${RUNNER_TEMP}/Workspace.sparseimage \
918+ -volname Workspace -type SPARSE -size 150g -fs HFSX
919+ hdiutil mount ${RUNNER_TEMP}/Workspace.sparseimage -mountpoint ${WORKSPACE}
920+
921+ # Set environment variables
922+ echo "TAR=gtar" >> $GITHUB_ENV
923+ echo "WORKSPACE=${WORKSPACE}" >> $GITHUB_ENV
924+
925+ - name : Check out source code
926+ if : ${{ github.event_name != 'pull_request_target' }}
927+ uses : actions/checkout@v4
928+ with :
929+ submodules : recursive
930+ persist-credentials : false
931+
932+ - name : Check out source code (pull request)
933+ if : ${{ github.event_name == 'pull_request_target' }}
934+ uses : actions/checkout@v4
935+ with :
936+ ref : ${{ github.event.pull_request.head.sha }}
937+ submodules : recursive
938+ persist-credentials : false
939+
940+ - name : Setup debug session (pre)
941+ if : always() && needs.setup.outputs.debug == 'toolchain-pre'
942+ uses : mxschmitt/action-tmate@v3
943+ with :
944+ limit-access-to-actor : true
945+
946+ - name : Build LLVM toolchain
947+ run : |
948+ # Create build directory
949+ pushd ${WORKSPACE}
950+ mkdir -p llvm-build
951+ cd llvm-build
952+
953+ # Configure and generate LLVM build scripts
954+ if [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
955+ cmake \
956+ -GNinja \
957+ -DLLVM_TOOLCHAIN_CROSS_BUILD_MINGW=ON \
958+ ${GITHUB_WORKSPACE}/scripts/llvm
959+ else
960+ cmake \
961+ -GNinja \
962+ ${GITHUB_WORKSPACE}/scripts/llvm
963+ fi
964+
965+ # Build LLVM toolchain
966+ ninja llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-build.log
967+
968+ # Run LLVM tests
969+ ninja check-llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-test.log
970+
971+ # Package
972+ ninja package-llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-package.log
973+ popd
974+
975+ # Prepare archive
976+ ARCHIVE_NAME=toolchain_gnu_${{ matrix.host.name }}
977+ ARCHIVE_FILE=${ARCHIVE_NAME}.${{ matrix.host.archive }}
978+
979+ # Compute checksum
980+ md5sum ${ARCHIVE_FILE} > md5.sum
981+ sha256sum ${ARCHIVE_FILE} > sha256.sum
982+
983+ - name : Setup debug session (post)
984+ if : always() && needs.setup.outputs.debug == 'toolchain-post'
985+ uses : mxschmitt/action-tmate@v3
986+ with :
987+ limit-access-to-actor : true
988+
989+ - name : Upload toolchain build log
990+ if : always()
991+ uses : actions/upload-artifact@v4
992+ with :
993+ name : log_toolchain_llvm_${{ matrix.host.name }}
994+ path : ' *.log'
995+
996+ - name : Upload toolchain build artifact
997+ uses : actions/upload-artifact@v4
998+ with :
999+ name : toolchain_llvm_${{ matrix.host.name }}
1000+ path : |
1001+ toolchain_llvm_${{ matrix.host.name }}.${{ matrix.host.archive }}
1002+ md5.sum
1003+ sha256.sum
1004+
8361005 # Build host tools
8371006 build-hosttools :
8381007 name : Host Tools (${{ matrix.host.name }})
@@ -1075,7 +1244,7 @@ jobs:
10751244 # Build distribution bundle
10761245 build-dist-bundle :
10771246 name : Distribution Bundle (${{ matrix.host.name }})
1078- needs : [ setup, build-gnu-toolchain, build-hosttools, build-cmake-pkg ]
1247+ needs : [ setup, build-gnu-toolchain, build-llvm-toolchain, build- hosttools, build-cmake-pkg ]
10791248 runs-on :
10801249 group : ${{ matrix.host.runner }}
10811250 container : ${{ matrix.host.container }}
0 commit comments