@@ -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 qemu-system
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+ LLVM_CMAKE_ARGS+="-DLLVM_TOOLCHAIN_CROSS_BUILD_MINGW=ON "
953+ elif [ "${{ matrix.host.name }}" == "macos-aarch64" ]; then
954+ LLVM_CMAKE_ARGS+="-DCMAKE_OSX_ARCHITECTURES=arm64 "
955+ elif [ "${{ matrix.host.name }}" == "macos-x86_64" ]; then
956+ LLVM_CMAKE_ARGS+="-DCMAKE_OSX_ARCHITECTURES=x86_64 "
957+ fi
958+
959+ cmake \
960+ -GNinja \
961+ ${LLVM_CMAKE_ARGS} \
962+ ${GITHUB_WORKSPACE}/scripts/llvm \
963+ |& tee ${GITHUB_WORKSPACE}/llvm-cmake.log
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