@@ -833,6 +833,162 @@ 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 zstd
891+ arch -x86_64 brew install zstd
892+
893+ # Set environment variables
894+ echo "TAR=gtar" >> $GITHUB_ENV
895+ echo "WORKSPACE=${WORKSPACE}" >> $GITHUB_ENV
896+
897+ - name : Check out source code
898+ if : ${{ github.event_name != 'pull_request_target' }}
899+ uses : actions/checkout@v4
900+ with :
901+ submodules : recursive
902+ persist-credentials : false
903+
904+ - name : Check out source code (pull request)
905+ if : ${{ github.event_name == 'pull_request_target' }}
906+ uses : actions/checkout@v4
907+ with :
908+ ref : ${{ github.event.pull_request.head.sha }}
909+ submodules : recursive
910+ persist-credentials : false
911+
912+ - name : Setup debug session (pre)
913+ if : always() && needs.setup.outputs.debug == 'toolchain-pre'
914+ uses : mxschmitt/action-tmate@v3
915+ with :
916+ limit-access-to-actor : true
917+
918+ - name : Build LLVM toolchain
919+ run : |
920+ # Create build directory
921+ pushd ${WORKSPACE}
922+ mkdir -p llvm
923+ mkdir -p llvm-build
924+ cd llvm-build
925+
926+ # Configure and generate LLVM build scripts
927+ if [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
928+ LLVM_CMAKE_ARGS+="-DLLVM_TOOLCHAIN_CROSS_BUILD_MINGW=ON "
929+ elif [ "${{ matrix.host.name }}" == "macos-aarch64" ]; then
930+ LLVM_CMAKE_ARGS+="-DCMAKE_OSX_ARCHITECTURES=arm64 "
931+ elif [ "${{ matrix.host.name }}" == "macos-x86_64" ]; then
932+ LLVM_CMAKE_ARGS+="-DCMAKE_OSX_ARCHITECTURES=x86_64 "
933+ fi
934+
935+ cmake \
936+ -GNinja \
937+ --install-prefix ${WORKSPACE}/llvm \
938+ ${LLVM_CMAKE_ARGS} \
939+ ${GITHUB_WORKSPACE}/scripts/llvm \
940+ |& tee ${GITHUB_WORKSPACE}/llvm-cmake.log
941+
942+ # Build LLVM toolchain
943+ ninja llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-build.log
944+
945+ # Run LLVM tests
946+ ninja check-llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-test.log
947+
948+ # Install LLVM toolchain
949+ ninja install-llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-install.log
950+ popd
951+
952+ # Create archive
953+ ARCHIVE_NAME=toolchain_llvm_${{ matrix.host.name }}
954+ ARCHIVE_FILE=${ARCHIVE_NAME}.${{ matrix.host.archive }}
955+
956+ if [ "${{ matrix.host.archive }}" == "tar.xz" ]; then
957+ XZ_OPT="-T0" \
958+ ${TAR} -Jcvf ${ARCHIVE_FILE} \
959+ --owner=0 --group=0 -C ${WORKSPACE} llvm
960+ elif [ "${{ matrix.host.archive }}" == "7z" ]; then
961+ pushd ${WORKSPACE}
962+ 7z a -t7z -l ${GITHUB_WORKSPACE}/${ARCHIVE_FILE} llvm
963+ popd
964+ fi
965+
966+ # Compute checksum
967+ md5sum ${ARCHIVE_FILE} > md5.sum
968+ sha256sum ${ARCHIVE_FILE} > sha256.sum
969+
970+ - name : Setup debug session (post)
971+ if : always() && needs.setup.outputs.debug == 'toolchain-post'
972+ uses : mxschmitt/action-tmate@v3
973+ with :
974+ limit-access-to-actor : true
975+
976+ - name : Upload toolchain build log
977+ if : always()
978+ uses : actions/upload-artifact@v4
979+ with :
980+ name : log_toolchain_llvm_${{ matrix.host.name }}
981+ path : ' *.log'
982+
983+ - name : Upload toolchain build artifact
984+ uses : actions/upload-artifact@v4
985+ with :
986+ name : toolchain_llvm_${{ matrix.host.name }}
987+ path : |
988+ toolchain_llvm_${{ matrix.host.name }}.${{ matrix.host.archive }}
989+ md5.sum
990+ sha256.sum
991+
836992 # Build host tools
837993 build-hosttools :
838994 name : Host Tools (${{ matrix.host.name }})
@@ -1075,7 +1231,7 @@ jobs:
10751231 # Build distribution bundle
10761232 build-dist-bundle :
10771233 name : Distribution Bundle (${{ matrix.host.name }})
1078- needs : [ setup, build-gnu-toolchain, build-hosttools, build-cmake-pkg ]
1234+ needs : [ setup, build-gnu-toolchain, build-llvm-toolchain, build- hosttools, build-cmake-pkg ]
10791235 runs-on :
10801236 group : ${{ matrix.host.runner }}
10811237 container : ${{ matrix.host.container }}
0 commit comments