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