Skip to content

workflows/release-binaries: Enable builds on Linux/AArch64 #120786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/release-binaries-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ jobs:
matrix:
runs-on:
- ubuntu-22.04
- depot-ubuntu-22.04-arm-small
- windows-2022
- macos-13
- macos-14
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/release-binaries-setup-stage/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ runs:
using: "composite"
steps:
- name: Install Ninja
# This doesn't seem to work on Ubuntu any more, so just use apt-get
if: runner.os != 'Linux'
uses: llvm/actions/install-ninja@22e9f909d35b50bd1181709564bfe816eaeaae81 # main

- name: Install Ninja (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
sudo apt-get -y install ninja-build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this should work still, no?

Suggested change
- name: Install Ninja
# This doesn't seem to work on Ubuntu any more, so just use apt-get
if: runner.os != 'Linux'
uses: llvm/actions/install-ninja@22e9f909d35b50bd1181709564bfe816eaeaae81 # main
- name: Install Ninja (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt-get update
sudo apt-get -y install ninja-build
- name: Update apt
# Needed for the install-ninja action to work on Ubuntu for some reason.
if: runner.os == 'Linux'
run: sudo apt-get update
- name: Install Ninja
uses: llvm/actions/install-ninja@22e9f909d35b50bd1181709564bfe816eaeaae81 # main

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working now, so I dropped this part of the change.


- name: Setup Windows
if: startsWith(runner.os, 'Windows')
Expand Down
121 changes: 100 additions & 21 deletions .github/workflows/release-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
type: choice
options:
- ubuntu-22.04
- depot-ubuntu-22.04-arm-small
- windows-2022
- macos-13
- macos-14
Expand Down Expand Up @@ -56,10 +57,13 @@ jobs:
ref: ${{ steps.vars.outputs.ref }}
upload: ${{ steps.vars.outputs.upload }}
target-cmake-flags: ${{ steps.vars.outputs.target-cmake-flags }}
ccache: ${{ steps.vars.outputs.ccache }}
build-flang: ${{ steps.vars.outputs.build-flang }}
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 @@ -120,8 +124,21 @@ jobs:

# Detect necessary CMake flags
target="${{ runner.os }}-${{ runner.arch }}"
echo "enable-pgo=false" >> $GITHUB_OUTPUT
target_cmake_flags="-DLLVM_RELEASE_ENABLE_PGO=OFF"

# The hendrikmuhs/ccache-action action does not support installing sccache
# on arm64 Linux.
if [ "$target" = "Linux-ARM64" ]; then
echo ccache=ccache >> $GITHUB_OUTPUT
else
echo ccache=sccache >> $GITHUB_OUTPUT
fi

if [ "${{ runner.os }}" = "Linux" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [ "${{ runner.os }}" = "Linux" ]; then
if [ "$RUNNER_OS" = "Linux" ]; then

We don't need workflow interpolation here, and it's better to avoid it if we don't need it: https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable

In general I'd prefer to remove all workflow interpolation (even in instances where it is safe) to make auditing easier, but that would require plenty of changes across all workflows.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a patch to clean up the file: #120860

I'll update this patch with your suggestions too.

echo "enable-pgo=true" >> $GITHUB_OUTPUT
else
echo "enable-pgo=false" >> $GITHUB_OUTPUT
target_cmake_flags="-DLLVM_RELEASE_ENABLE_PGO=OFF"
fi
# The macOS builds try to cross compile some libraries so we need to
# add extra CMake args to disable them.
# See https://github.com/llvm/llvm-project/issues/99767
Expand All @@ -144,12 +161,29 @@ 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"
;;
depot-ubuntu-22.04-arm-small)
runs_on="depot-ubuntu-22.04-arm-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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
github.repository == 'llvm/llvm-project'
github.repository_owner == 'llvm'

Might make it easier to reuse workflow snippets in other org repos, but this is a very mild preference.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've put this change in a separate PR: #123797

runs-on: ${{ needs.prepare.outputs.runs-on }}
steps:

- name: Checkout Actions
Expand Down Expand Up @@ -192,10 +226,10 @@ jobs:
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
key: ${{ needs.prepare.outputs.ccache }}-${{ runner.os }}-${{ runner.arch }}-release
variant: ${{ needs.prepare.outputs.ccache }}

- name: Build Stage 1 Clang
- name: Configure Stage 1 Clang
id: build
shell: bash
run: |
Expand All @@ -206,12 +240,37 @@ jobs:
-C clang/cmake/caches/Release.cmake \
-DBOOTSTRAP_LLVM_PARALLEL_LINK_JOBS=1 \
-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
-DCMAKE_C_COMPILER_LAUNCHER=${{ needs.prepare.outputs.ccache }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ needs.prepare.outputs.ccache }}
- 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 +282,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 +303,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 +320,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 +372,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 +424,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 +476,7 @@ jobs:
needs:
- prepare
- build-stage3-all
- build-stage1
if: >-
always() &&
github.event_name != 'pull_request' &&
Expand Down Expand Up @@ -469,6 +537,7 @@ jobs:
- prepare
- build-stage3-all
if: >-
always() &&
github.repository == 'llvm/llvm-project'
runs-on: ${{ inputs.runs-on }}
steps:
Expand All @@ -484,7 +553,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: ${{ needs.prepare.outputs.ccache }}-${{ runner.os }}-${{ runner.arch }}-release
variant: ${{ needs.prepare.outputs.ccache }}

- name: Run Tests
shell: bash
Expand Down
Loading