Skip to content
Merged
90 changes: 75 additions & 15 deletions .github/workflows/release-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ jobs:
enable-pgo: ${{ steps.vars.outputs.enable-pgo }}
release-binary-basename: ${{ steps.vars.outputs.release-binary-basename }}
release-binary-filename: ${{ steps.vars.outputs.release-binary-filename }}
runs-on: ${{ steps.vars.outputs.runs-on }}
multi-stage: ${{ steps.vars.outputs.multi-stage }}

steps:
# It's good practice to use setup-python, but this is also required on macos-14
Expand Down Expand Up @@ -144,12 +146,25 @@ jobs:

echo "target-cmake-flags=$target_cmake_flags" >> $GITHUB_OUTPUT
echo "build-flang=$build_flang" >> $GITHUB_OUTPUT
case "${{ inputs.runs-on }}" in
ubuntu-22.04)
runs_on="depot-${{ inputs.runs-on }}-16"
multi_stage="false"
;;
*)
runs_on="${{ inputs.runs-on }}"
multi_stage="true"
;;
esac
echo "runs-on=$runs_on" >> $GITHUB_OUTPUT
echo "multi-stage=$multi_stage" >> $GITHUB_OUTPUT

build-stage1:
name: "Build Stage 1"
needs: prepare
if: github.repository == 'llvm/llvm-project'
runs-on: ${{ inputs.runs-on }}
if: >-
github.repository == 'llvm/llvm-project'
runs-on: ${{ needs.prepare.outputs.runs-on }}
steps:

- name: Checkout Actions
Expand Down Expand Up @@ -195,7 +210,7 @@ jobs:
key: sccache-${{ runner.os }}-${{ runner.arch }}-release
variant: sccache

- name: Build Stage 1 Clang
- name: Configure Stage 1 Clang
id: build
shell: bash
run: |
Expand All @@ -208,10 +223,35 @@ jobs:
-DBOOTSTRAP_CPACK_PACKAGE_FILE_NAME="${{ needs.prepare.outputs.release-binary-basename }}" \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
ninja -v -C ${{ steps.setup-stage.outputs.build-prefix }}/build
# There is a race condition on the MacOS builders and this command is here
# to help debug that when it happens.
ls -ltr ${{ steps.setup-stage.outputs.build-prefix }}/build
- name: Build Stage 1 Clang
shell: bash
run: |
if [ "${{ needs.prepare.outputs.multi-stage}}" = "false" ]; then
ninja -v -C ${{ steps.setup-stage.outputs.build-prefix }}/build stage2-package
mv ${{ steps.setup-stage.outputs.build-prefix }}/build/tools/clang/stage2-bins/${{ needs.prepare.outputs.release-binary-filename }} .
else
ninja -v -C ${{ steps.setup-stage.outputs.build-prefix }}/build
# There is a race condition on the MacOS builders and this command is here
# to help debug that when it happens.
ls -ltr ${{ steps.setup-stage.outputs.build-prefix }}/build
fi

- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
if: needs.prepare.outputs.multi-stage == 'false'
with:
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.
path: |
${{ needs.prepare.outputs.release-binary-filename }}

# Clean up some build files to reduce size of artifact.
- name: Clean Up Build Directory
if: needs.prepare.outputs.multi-stage == 'false'
shell: bash
run: |
find ${{ steps.setup-stage.outputs.build-prefix }}/build -iname ${{ needs.prepare.outputs.release-binary-filename }} -delete
rm -Rf ${{ steps.setup-stage.outputs.build-prefix }}/build/tools/clang/stage2-bins/_CPack_Packages

- name: Save Stage
uses: ./workflows-main/.github/workflows/release-binaries-save-stage
Expand All @@ -223,8 +263,10 @@ jobs:
needs:
- prepare
- build-stage1
if: github.repository == 'llvm/llvm-project'
runs-on: ${{ inputs.runs-on }}
if: >-
github.repository == 'llvm/llvm-project' &&
needs.prepare.outputs.multi-stage == 'true'
runs-on: ${{ needs.prepare.outputs.runs-on }}
steps:
- name: Checkout Actions
uses: actions/checkout@v4
Expand All @@ -242,7 +284,9 @@ jobs:

- name: Build Stage 2
# Re-enable once PGO builds are supported.
if: needs.prepare.outputs.enable-pgo == 'true'
if: >-
needs.prepare.outputs.enable-pgo == 'true' &&
needs.prepare.outputs.multi-stage == 'true'
shell: bash
run: |
ninja -C ${{ steps.setup-stage.outputs.build-prefix}}/build stage2-instrumented
Expand All @@ -257,8 +301,10 @@ jobs:
needs:
- prepare
- build-stage2
if: github.repository == 'llvm/llvm-project'
runs-on: ${{ inputs.runs-on }}
if: >-
github.repository == 'llvm/llvm-project' &&
needs.prepare.outputs.multi-stage == 'true'
runs-on: ${{ needs.prepare.outputs.runs-on }}
steps:
- name: Checkout Actions
uses: actions/checkout@v4
Expand Down Expand Up @@ -307,7 +353,9 @@ jobs:
needs:
- prepare
- build-stage3-clang
runs-on: ${{ inputs.runs-on }}
if: >-
needs.prepare.outputs.multi-stage == 'true'
runs-on: ${{ needs.prepare.outputs.runs-on }}
steps:
- name: Checkout Actions
uses: actions/checkout@v4
Expand Down Expand Up @@ -357,7 +405,7 @@ jobs:
needs:
- prepare
- build-stage3-flang
runs-on: ${{ inputs.runs-on }}
runs-on: ${{ needs.prepare.outputs.runs-on }}
steps:
- name: Checkout Actions
uses: actions/checkout@v4
Expand Down Expand Up @@ -409,6 +457,7 @@ jobs:
needs:
- prepare
- build-stage3-all
- build-stage1
if: >-
always() &&
github.event_name != 'pull_request' &&
Expand Down Expand Up @@ -469,6 +518,7 @@ jobs:
- prepare
- build-stage3-all
if: >-
always() &&
github.repository == 'llvm/llvm-project'
runs-on: ${{ inputs.runs-on }}
steps:
Expand All @@ -484,7 +534,17 @@ jobs:
id: setup-stage
uses: ./workflows/.github/workflows/release-binaries-setup-stage
with:
previous-artifact: build-stage3-all
previous-artifact: ${{ (needs.prepare.outputs.multi-stage == 'false' && 'build-stage1') || 'build-stage3-all' }}

# Need sccache installed, because some stage1 objects are being built for the tests.
# FIXME: This probably shouldn't be happening.
- name: Setup sccache
uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e # v1.2.9
with:
# Default to 2G to workaround: https://github.com/hendrikmuhs/ccache-action/issues/174
max-size: 2G
key: sccache-${{ runner.os }}-${{ runner.arch }}-release
variant: sccache

- name: Run Tests
shell: bash
Expand Down
Loading