diff --git a/.github/workflows/release-binaries-all.yml b/.github/workflows/release-binaries-all.yml index eef49b5e3625d..edccc99cd9dc9 100644 --- a/.github/workflows/release-binaries-all.yml +++ b/.github/workflows/release-binaries-all.yml @@ -91,6 +91,7 @@ jobs: - ubuntu-22.04 - ubuntu-22.04-arm - macos-14 + - windows-2022 uses: ./.github/workflows/release-binaries.yml with: diff --git a/.github/workflows/release-binaries.yml b/.github/workflows/release-binaries.yml index 70e909f02f9e6..ee0d6e1280452 100644 --- a/.github/workflows/release-binaries.yml +++ b/.github/workflows/release-binaries.yml @@ -87,8 +87,16 @@ jobs: run: | ./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --user "$GITHUB_ACTOR" --user-token "$USER_TOKEN" check-permissions + # The name of the Windows binaries uses the version from source, so we need + # to fetch it here. + - id: version-from-source + if: runner.os == 'Windows' + uses: ./.github/workflows/get-llvm-version + - name: Collect Variables id: vars + env: + LLVM_VERSION_FROM_SOURCE: ${{ format('{0}.{1}.{2}', steps.version-from-source.outputs.major, steps.version-from-source.outputs.minor, steps.version-from-source.outputs.patch) }} shell: bash # In order for the test-release.sh script to run correctly, the LLVM # source needs to be at the following location relative to the build dir: @@ -104,7 +112,11 @@ jobs: release_version="$trimmed" ref="llvmorg-$release_version" else - release_version="${{ (github.event_name == 'pull_request' && format('PR{0}', github.event.pull_request.number)) || 'CI'}}-$GITHUB_SHA" + if [ "$RUNNER_OS" = "Windows" ]; then + release_version="$LLVM_VERSION_FROM_SOURCE" + else + release_version="${{ (github.event_name == 'pull_request' && format('PR{0}', github.event.pull_request.number)) || 'CI'}}-$GITHUB_SHA" + fi ref="$GITHUB_SHA" fi if [ -n "${{ inputs.upload }}" ]; then @@ -116,7 +128,19 @@ jobs: echo "ref=$ref" >> $GITHUB_OUTPUT echo "upload=$upload" >> $GITHUB_OUTPUT - release_binary_basename="LLVM-$release_version-$RUNNER_OS-$RUNNER_ARCH" + if [ "$RUNNER_OS" = "Windows" ]; then + case $RUNNER_ARCH in + "X64" ) + tar_arch="x86_64" + ;; + "ARM64" ) + tar_arch="aarch64" + ;; + esac + release_binary_basename="clang+llvm-$release_version-$tar_arch-pc-windows-msvc" + else + release_binary_basename="LLVM-$release_version-$RUNNER_OS-$RUNNER_ARCH" + fi echo "release-binary-basename=$release_binary_basename" >> $GITHUB_OUTPUT echo "release-binary-filename=$release_binary_basename.tar.xz" >> $GITHUB_OUTPUT @@ -139,7 +163,7 @@ jobs: fi case "${{ inputs.runs-on }}" in - ubuntu-22.04*) + ubuntu-22.04* | windows-2022) build_runs_on="depot-${{ inputs.runs-on }}-16" test_runs_on=$build_runs_on ;; @@ -185,6 +209,24 @@ jobs: digest: ${{ steps.digest.outputs.digest }} artifact-id: ${{ steps.artifact-upload.outputs.artifact-id }} steps: + # We need to hard code the python library path for Windows, so in order + # to do that we need to specify a specific python version. It's also + # good practice to do this on other OSes so the version of python doesn't + # get changed unexpectedly. + - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 + with: + python-version: '3.10' + + # For some reason this is needed on Windows or else the build system can't find python3.lib. + - name: Setup Python library path + if: runner.os == 'Windows' + run: | + echo "LIB=$env:LIB;C:\hostedtoolcache\windows\Python\3.10.11\x64\libs" >> $env:GITHUB_ENV + + - name: Setup crlf + if: runner.os == 'Windows' + run: | + git config --global core.autocrlf false - name: Checkout LLVM uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 @@ -202,8 +244,9 @@ jobs: fi echo "build-prefix=$build_prefix" >> $GITHUB_OUTPUT - - name: Configure + - name: Configure Linux/MacOS id: build + if: runner.os != 'Windows' shell: bash run: | # There were some issues on the ARM64 MacOS runners with trying to build x86 object, @@ -212,20 +255,39 @@ jobs: ${{ needs.prepare.outputs.target-cmake-flags }} \ -C clang/cmake/caches/Release.cmake - - name: Build + - name: Build Linux/MacOS + if: runner.os != 'Windows' shell: bash run: | ninja -v -C ${{ steps.setup-stage.outputs.build-prefix }}/build stage2-package release_dir=`find ${{ steps.setup-stage.outputs.build-prefix }}/build -iname 'stage2-bins'` mv $release_dir/${{ needs.prepare.outputs.release-binary-filename }} . + - name: Build Windows + id: build-windows + if: runner.os == 'Windows' + env: + LLVM_VERSION: ${{ needs.prepare.outputs.release-version }} + run: | + subst S: ${{ github.workspace }} + cd S:\llvm\utils\release\ + .\build_llvm_release.bat "--$($env:RUNNER_ARCH.ToLower())" --version $env:LLVM_VERSION --local-python --skip-checkout + $installer = (Get-ChildItem -Recurse -Filter "*.exe" | Select-Object -First 1).fullName + $tarball = (Get-ChildItem -Recurse -Filter "*.tar.xz" | Select-Object -First 1).fullName + # Move installer to top-level directory so it is easier to upload. + mv $installer $env:GITHUB_WORKSPACE + mv $tarball $env:GITHUB_WORKSPACE + echo "windows-installer-filename=$(Split-Path -Path $installer -Leaf)" >> $env:GITHUB_OUTPUT + - name: Generate sha256 digest for binaries id: digest shell: bash env: RELEASE_BINARY_FILENAME: ${{ needs.prepare.outputs.release-binary-filename }} + # This will be empty on non-Windows builds. + WINDOWS_INSTALLER_FILENAME: ${{ steps.build-windows.outputs.windows-installer-filename }} run: | - echo "digest=$(cat $RELEASE_BINARY_FILENAME | sha256sum | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT + echo "digest=$(cat $WINDOWS_INSTALLER_FILENAME $RELEASE_BINARY_FILENAME | sha256sum | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 id: artifact-upload @@ -233,11 +295,14 @@ jobs: name: ${{ runner.os }}-${{ runner.arch }}-release-binary # Due to path differences on Windows when running in bash vs running on node, # we need to search for files in the current workspace. + # The steps.build-windows.* variables will be empty on Linux/MacOS. path: | ${{ needs.prepare.outputs.release-binary-filename }} + ${{ steps.build-windows.outputs.windows-installer-filename }} - name: Run Tests # These almost always fail so don't let them fail the build and prevent the uploads. + if : runner.os != 'Windows' continue-on-error: true run: | ninja -C ${{ steps.setup-stage.outputs.build-prefix }}/build stage2-check-all