@@ -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+ # 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+ ## Install x86 packages
898+ arch -x86_64 /usr/local/bin/brew install zstd
899+ fi
900+
901+ # Set environment variables
902+ echo "TAR=gtar" >> $GITHUB_ENV
903+ echo "WORKSPACE=${WORKSPACE}" >> $GITHUB_ENV
904+
905+ - name : Check out source code
906+ if : ${{ github.event_name != 'pull_request_target' }}
907+ uses : actions/checkout@v4
908+ with :
909+ submodules : recursive
910+ persist-credentials : false
911+
912+ - name : Check out source code (pull request)
913+ if : ${{ github.event_name == 'pull_request_target' }}
914+ uses : actions/checkout@v4
915+ with :
916+ ref : ${{ github.event.pull_request.head.sha }}
917+ submodules : recursive
918+ persist-credentials : false
919+
920+ - name : Setup debug session (pre)
921+ if : always() && needs.setup.outputs.debug == 'toolchain-pre'
922+ uses : mxschmitt/action-tmate@v3
923+ with :
924+ limit-access-to-actor : true
925+
926+ - name : Build LLVM toolchain
927+ run : |
928+ # Create build directory
929+ pushd ${WORKSPACE}
930+ mkdir -p llvm
931+ mkdir -p llvm-build
932+ cd llvm-build
933+
934+ # Configure and generate LLVM build scripts
935+ if [ "${{ matrix.host.name }}" == "windows-x86_64" ]; then
936+ LLVM_CMAKE_ARGS+="-DLLVM_TOOLCHAIN_CROSS_BUILD_MINGW=ON "
937+ elif [ "${{ matrix.host.name }}" == "macos-aarch64" ]; then
938+ LLVM_CMAKE_ARGS+="-DCMAKE_OSX_ARCHITECTURES=arm64 "
939+ elif [ "${{ matrix.host.name }}" == "macos-x86_64" ]; then
940+ LLVM_CMAKE_ARGS+="-DCMAKE_OSX_ARCHITECTURES=x86_64 "
941+ fi
942+
943+ cmake \
944+ -GNinja \
945+ --install-prefix ${WORKSPACE}/llvm \
946+ ${LLVM_CMAKE_ARGS} \
947+ ${GITHUB_WORKSPACE}/scripts/llvm \
948+ |& tee ${GITHUB_WORKSPACE}/llvm-cmake.log
949+
950+ # Build LLVM toolchain
951+ ninja llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-build.log
952+
953+ # Run LLVM tests
954+ ninja check-llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-test.log
955+
956+ # Install LLVM toolchain
957+ ninja install-llvm-toolchain |& tee ${GITHUB_WORKSPACE}/llvm-install.log
958+ popd
959+
960+ # Create archive
961+ ARCHIVE_NAME=toolchain_llvm_${{ matrix.host.name }}
962+ ARCHIVE_FILE=${ARCHIVE_NAME}.${{ matrix.host.archive }}
963+
964+ if [ "${{ matrix.host.archive }}" == "tar.xz" ]; then
965+ XZ_OPT="-T0" \
966+ ${TAR} -Jcvf ${ARCHIVE_FILE} \
967+ --owner=0 --group=0 -C ${WORKSPACE} llvm
968+ elif [ "${{ matrix.host.archive }}" == "7z" ]; then
969+ pushd ${WORKSPACE}
970+ 7z a -t7z -l ${GITHUB_WORKSPACE}/${ARCHIVE_FILE} llvm
971+ popd
972+ fi
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