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