From 6b519443eec5a7139aafee8ffd45b3a1ac2f4325 Mon Sep 17 00:00:00 2001 From: Kevin Gleason Date: Fri, 26 Aug 2022 15:39:33 +0000 Subject: [PATCH 1/5] Implement GitHub Actions for lint and buildAndTest --- .clang-format | 2 + .github/actions/setup-build/action.yml | 45 ++++++++++++ .github/workflows/buildAndTest.yml | 71 +++++++++++++++++++ .github/workflows/lint.yml | 25 +++++++ build_tools/github_actions/ci_build_llvm.sh | 61 ++++++++++++++++ .../github_actions/ci_build_stablehlo.sh | 55 ++++++++++++++ stablehlo/dialect/StablehloOps.cpp | 3 +- 7 files changed, 260 insertions(+), 2 deletions(-) create mode 100644 .clang-format create mode 100644 .github/actions/setup-build/action.yml create mode 100644 .github/workflows/buildAndTest.yml create mode 100644 .github/workflows/lint.yml create mode 100755 build_tools/github_actions/ci_build_llvm.sh create mode 100755 build_tools/github_actions/ci_build_stablehlo.sh diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000000..a74fda4b673 --- /dev/null +++ b/.clang-format @@ -0,0 +1,2 @@ +BasedOnStyle: LLVM +AlwaysBreakTemplateDeclarations: Yes diff --git a/.github/actions/setup-build/action.yml b/.github/actions/setup-build/action.yml new file mode 100644 index 00000000000..70dcae5e662 --- /dev/null +++ b/.github/actions/setup-build/action.yml @@ -0,0 +1,45 @@ +# Copyright 2022 The StableHLO Authors. + +# The setup-build action gets everything needed by buildAndTest into the workspace. +# This checks out the proper revision of the LLVM repository, installs ninja, and sets +# up the ccache for faster re-compilation. +name: "Setup build environment (ninja, ccache, llvm, lld)" + +inputs: + llvm-ref: + description: | + LLVM Commit Ref for checkout and build. Used for ccache value and checkout. + required: true + + +runs: + # Based on https://github.com/llvm/torch-mlir/blob/main/.github/actions/setup-build/action.yml + using: "composite" + + steps: + # Checkout llvm at revision specified in input argument. + - uses: actions/checkout@v2 + with: + repository: llvm/llvm-project + ref: ${{ inputs.llvm-ref }} + path: llvm-project + fetch-depth: 1 + + # Get ninja for cmake build. + - name: Install Ninja + uses: llvm/actions/install-ninja@55d844821959226fab4911f96f37071c1d4c3268 + + # Get LLD + - name: Install LLD + if: "runner.os == 'Linux'" + shell: bash + run: | + sudo apt-get install -y lld + + # Setup C++ caching using ccache. + # Cache key is a combination of OS arch and LLVM ref. + - name: Ccache for C++ compilation + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ runner.os }}-stablehlo_build_assets-${{ inputs.llvm-ref }} + max-size: 4G diff --git a/.github/workflows/buildAndTest.yml b/.github/workflows/buildAndTest.yml new file mode 100644 index 00000000000..945db205904 --- /dev/null +++ b/.github/workflows/buildAndTest.yml @@ -0,0 +1,71 @@ +# Copyright 2022 The StableHLO Authors. + +name: Build and Test + +on: + pull_request: + branches: [ main ] + push: + branches: [ main ] + schedule: + # Always regenerate once every day + - cron: '* 12 * * *' + workflow_dispatch: + +# Ensure that only a single job or workflow using the same +# concurrency group will run at a time. This would cancel +# any in-progress jobs in the same github workflow and github +# ref (e.g. refs/heads/main or refs/pull//merge). +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +# Build using CMake and run tests. +# Use Cached LLVM to improve build times. +# Current setup only builds on linux. +jobs: + build-test: + strategy: + fail-fast: false + matrix: + os-arch: [maci-x86_64, ubuntu-x86_64] + include: + - os-arch: ubuntu-x86_64 + os: ubuntu-22.04 + llvm-build-dir: "$GITHUB_WORKSPACE/llvm-build" + stablehlo-build-dir: "$GITHUB_WORKSPACE/build" + - os-arch: maci-x86_64 + os: macos-latest + llvm-build-dir: "$GITHUB_WORKSPACE/llvm-build-maci" + stablehlo-build-dir: "$GITHUB_WORKSPACE/build-maci" + runs-on: ${{ matrix.os }} + + steps: + + # Check out stablehlo repo + - name: Checkout stablehlo + uses: actions/checkout@v2 + + # Read llvm revision from `build_tools/llvm_version.txt` + - name: Get LLVM Revision + id: llvm-revision + shell: bash + run: | + echo "::set-output name=revision::$(cat ${{ github.workspace }}/build_tools/llvm_version.txt)" + + # Check out LLVM, download Ninja, setup ccache + - name: Setup workspace + uses: ./.github/actions/setup-build + with: + llvm-ref: ${{ steps.llvm-revision.outputs.revision }} + + # Configuration for linux + - name: Configure and Build LLVM os-arch='${{ matrix.os-arch }}' + shell: bash + run: | + ./build_tools/github_actions/ci_build_llvm.sh "$GITHUB_WORKSPACE/llvm-project/" ${{ matrix.llvm-build-dir }} + + # Configure for linux + - name: Build and Test StableHLO os-arch='${{ matrix.os-arch }}' + run: | + ./build_tools/github_actions/ci_build_stablehlo.sh ${{ matrix.llvm-build-dir }} ${{ matrix.stablehlo-build-dir }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000000..00c8b87b2ec --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +# Copyright 2022 The StableHLO Authors. + +name: Lint + +on: [pull_request] + +jobs: + # Based on https://github.com/iree-org/iree/blob/main/.github/workflows/lint.yml + clang-format: + if: "github.event_name == 'pull_request'" + runs-on: ubuntu-latest + steps: + - name: Installing dependencies + run: | + wget https://raw.githubusercontent.com/llvm-mirror/clang/master/tools/clang-format/git-clang-format -O /tmp/git-clang-format + chmod +x /tmp/git-clang-format + - name: Checking out repository + uses: actions/checkout@v2 + - name: Fetching Base Branch + # We have to explicitly fetch the base branch as well + run: git fetch --no-tags --prune --depth=1 origin "${GITHUB_BASE_REF?}:${GITHUB_BASE_REF?}" + - name: Running clang-format on changed source files + run: | + /tmp/git-clang-format "${GITHUB_BASE_REF?}" --style=google + git diff --exit-code diff --git a/build_tools/github_actions/ci_build_llvm.sh b/build_tools/github_actions/ci_build_llvm.sh new file mode 100755 index 00000000000..9c769a96398 --- /dev/null +++ b/build_tools/github_actions/ci_build_llvm.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# Copyright 2020 The TensorFlow Authors. All Rights Reserved. +# Copyright 2022 The StableHLO Authors. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is similar to build_mlir.sh, but passes different flags for +# cacheing in GitHub Actions to improve build speeds. + +if [[ $# -ne 2 ]] ; then + echo "Usage: $0 " + exit 1 +fi + +# LLVM source +LLVM_SRC_DIR="$1" +LLVM_BUILD_DIR="$2" + +# Check for LLD +FLAGS="" +LLD_FLAG="-DLLVM_ENABLE_LLD=ON" +if command -v lld &> /dev/null +then + echo "lld found, appending flag '$LLD_FLAG'" + FLAGS="$LLD_FLAG" +else + echo "lld not found, using default linker" +fi + +# Call cmake +echo "Using additional flags: '$FLAGS'" + +cmake -GNinja \ + "$FLAGS" \ + "-B$LLVM_BUILD_DIR" \ + "-H$LLVM_SRC_DIR/llvm" \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_CXX_COMPILER=clang++ \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DLLVM_BUILD_TOOLS=OFF \ + -DLLVM_ENABLE_ASSERTIONS=On \ + -DLLVM_ENABLE_BINDINGS=OFF \ + -DLLVM_ENABLE_PROJECTS=mlir \ + -DLLVM_INCLUDE_TESTS=OFF \ + -DLLVM_INCLUDE_TOOLS=ON \ + -DLLVM_INSTALL_UTILS=ON \ + -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" + +# Build LLVM/MLIR +cmake --build "$LLVM_BUILD_DIR" --target all --target mlir-cpu-runner diff --git a/build_tools/github_actions/ci_build_stablehlo.sh b/build_tools/github_actions/ci_build_stablehlo.sh new file mode 100755 index 00000000000..fe11c1978a0 --- /dev/null +++ b/build_tools/github_actions/ci_build_stablehlo.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Copyright 2020 The TensorFlow Authors. All Rights Reserved. +# Copyright 2022 The StableHLO Authors. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is similar to build_mlir.sh, but passes different flags for +# cacheing in GitHub Actions. + +# This file gets called on build directory where resources are placed +# during `ci_configure`, and builds stablehlo in the directory specified +# by the second argument. + +if [[ $# -ne 2 ]] ; then + echo "Usage: $0 " + exit 1 +fi + +LLVM_BUILD_DIR="$1" +STABLEHLO_BUILD_DIR="$2" + +# Check for LLD +FLAGS="" +LLD_FLAG="-DLLVM_ENABLE_LLD=ON" +if command -v lld &> /dev/null +then + echo "lld found, appending flag '$LLD_FLAG'" + FLAGS="$LLD_FLAG" +else + echo "lld not found, using default linker" +fi + +# Build StableHLO +cmake -GNinja \ + "$FLAGS" \ + -B"$STABLEHLO_BUILD_DIR" \ + -DCMAKE_CXX_COMPILER=clang++ \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_ASSERTIONS=On \ + -DMLIR_DIR="$LLVM_BUILD_DIR/lib/cmake/mlir" + +cd "$STABLEHLO_BUILD_DIR" +ninja check-stablehlo diff --git a/stablehlo/dialect/StablehloOps.cpp b/stablehlo/dialect/StablehloOps.cpp index a24c5c2f85e..7483aa6fd3b 100644 --- a/stablehlo/dialect/StablehloOps.cpp +++ b/stablehlo/dialect/StablehloOps.cpp @@ -1855,8 +1855,7 @@ LogicalResult verifyCollectivePermuteSourceTargetPairs( } LogicalResult CollectivePermuteOp::verify() { - return verifyCollectivePermuteSourceTargetPairs(*this, - source_target_pairs()); + return verifyCollectivePermuteSourceTargetPairs(*this, source_target_pairs()); } //===----------------------------------------------------------------------===// From 897d74e07f8d5ce4b4189ac711c08003b284fb51 Mon Sep 17 00:00:00 2001 From: Kevin Gleason Date: Tue, 30 Aug 2022 15:33:33 +0000 Subject: [PATCH 2/5] Incorporate Eugene's feedback. --- .github/actions/setup-build/action.yml | 19 +++++------ .github/workflows/buildAndTest.yml | 30 +++++++--------- .github/workflows/lint.yml | 3 +- build_tools/github_actions/ci_build_llvm.sh | 34 ++++++++----------- .../github_actions/ci_build_stablehlo.sh | 2 +- 5 files changed, 37 insertions(+), 51 deletions(-) diff --git a/.github/actions/setup-build/action.yml b/.github/actions/setup-build/action.yml index 70dcae5e662..f8cc0af6fa7 100644 --- a/.github/actions/setup-build/action.yml +++ b/.github/actions/setup-build/action.yml @@ -1,27 +1,24 @@ # Copyright 2022 The StableHLO Authors. # The setup-build action gets everything needed by buildAndTest into the workspace. -# This checks out the proper revision of the LLVM repository, installs ninja, and sets -# up the ccache for faster re-compilation. name: "Setup build environment (ninja, ccache, llvm, lld)" inputs: - llvm-ref: + llvm-version: description: | - LLVM Commit Ref for checkout and build. Used for ccache value and checkout. + LLVM version for checkout and build. Used for ccache value and checkout. required: true - runs: - # Based on https://github.com/llvm/torch-mlir/blob/main/.github/actions/setup-build/action.yml + # This is a composite action - has a list of steps to execute. using: "composite" steps: - # Checkout llvm at revision specified in input argument. + # Checkout llvm at version specified in input argument. - uses: actions/checkout@v2 with: repository: llvm/llvm-project - ref: ${{ inputs.llvm-ref }} + ref: ${{ inputs.llvm-version }} path: llvm-project fetch-depth: 1 @@ -29,7 +26,7 @@ runs: - name: Install Ninja uses: llvm/actions/install-ninja@55d844821959226fab4911f96f37071c1d4c3268 - # Get LLD + # Get LLD - Improves build speed on Linux - name: Install LLD if: "runner.os == 'Linux'" shell: bash @@ -37,9 +34,9 @@ runs: sudo apt-get install -y lld # Setup C++ caching using ccache. - # Cache key is a combination of OS arch and LLVM ref. + # Cache key is a combination of OS arch and LLVM version. - name: Ccache for C++ compilation uses: hendrikmuhs/ccache-action@v1.2 with: - key: ${{ runner.os }}-stablehlo_build_assets-${{ inputs.llvm-ref }} + key: ${{ runner.os }}-stablehlo_build_assets-${{ inputs.llvm-version }} max-size: 4G diff --git a/.github/workflows/buildAndTest.yml b/.github/workflows/buildAndTest.yml index 945db205904..072f3c30035 100644 --- a/.github/workflows/buildAndTest.yml +++ b/.github/workflows/buildAndTest.yml @@ -6,9 +6,9 @@ on: pull_request: branches: [ main ] push: - branches: [ main ] + branches: [ main, actions ] schedule: - # Always regenerate once every day + # Run buildAndTest workflow once a day - cron: '* 12 * * *' workflow_dispatch: @@ -22,7 +22,6 @@ concurrency: # Build using CMake and run tests. # Use Cached LLVM to improve build times. -# Current setup only builds on linux. jobs: build-test: strategy: @@ -32,40 +31,35 @@ jobs: include: - os-arch: ubuntu-x86_64 os: ubuntu-22.04 - llvm-build-dir: "$GITHUB_WORKSPACE/llvm-build" - stablehlo-build-dir: "$GITHUB_WORKSPACE/build" - os-arch: maci-x86_64 os: macos-latest - llvm-build-dir: "$GITHUB_WORKSPACE/llvm-build-maci" - stablehlo-build-dir: "$GITHUB_WORKSPACE/build-maci" runs-on: ${{ matrix.os }} steps: - - # Check out stablehlo repo - - name: Checkout stablehlo + # Check out StableHLO repo + - name: Checkout StableHLO uses: actions/checkout@v2 - # Read llvm revision from `build_tools/llvm_version.txt` - - name: Get LLVM Revision - id: llvm-revision + # Read LLVM version from `build_tools/llvm_version.txt` + - name: Get LLVM Version + id: llvm-version shell: bash run: | - echo "::set-output name=revision::$(cat ${{ github.workspace }}/build_tools/llvm_version.txt)" + echo "::set-output name=version::$(cat ${{ github.workspace }}/build_tools/llvm_version.txt)" - # Check out LLVM, download Ninja, setup ccache + # Check out LLVM, and install tools for compilation - name: Setup workspace uses: ./.github/actions/setup-build with: - llvm-ref: ${{ steps.llvm-revision.outputs.revision }} + llvm-version: ${{ steps.llvm-version.outputs.version }} # Configuration for linux - name: Configure and Build LLVM os-arch='${{ matrix.os-arch }}' shell: bash run: | - ./build_tools/github_actions/ci_build_llvm.sh "$GITHUB_WORKSPACE/llvm-project/" ${{ matrix.llvm-build-dir }} + ./build_tools/github_actions/ci_build_llvm.sh "$GITHUB_WORKSPACE/llvm-project/" "$GITHUB_WORKSPACE/llvm-build" # Configure for linux - name: Build and Test StableHLO os-arch='${{ matrix.os-arch }}' run: | - ./build_tools/github_actions/ci_build_stablehlo.sh ${{ matrix.llvm-build-dir }} ${{ matrix.stablehlo-build-dir }} + ./build_tools/github_actions/ci_build_stablehlo.sh "$GITHUB_WORKSPACE/llvm-build" "$GITHUB_WORKSPACE/stablehlo-build" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 00c8b87b2ec..67aa7d404c5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,10 +2,9 @@ name: Lint -on: [pull_request] +on: [pull_request, push] jobs: - # Based on https://github.com/iree-org/iree/blob/main/.github/workflows/lint.yml clang-format: if: "github.event_name == 'pull_request'" runs-on: ubuntu-latest diff --git a/build_tools/github_actions/ci_build_llvm.sh b/build_tools/github_actions/ci_build_llvm.sh index 9c769a96398..95f40100547 100755 --- a/build_tools/github_actions/ci_build_llvm.sh +++ b/build_tools/github_actions/ci_build_llvm.sh @@ -14,7 +14,7 @@ # limitations under the License. # This file is similar to build_mlir.sh, but passes different flags for -# cacheing in GitHub Actions to improve build speeds. +# caching in GitHub Actions to improve build speeds. if [[ $# -ne 2 ]] ; then echo "Usage: $0 " @@ -26,36 +26,32 @@ LLVM_SRC_DIR="$1" LLVM_BUILD_DIR="$2" # Check for LLD -FLAGS="" -LLD_FLAG="-DLLVM_ENABLE_LLD=ON" +LLVM_ENABLE_LLD="" if command -v lld &> /dev/null then - echo "lld found, appending flag '$LLD_FLAG'" - FLAGS="$LLD_FLAG" + LLVM_ENABLE_LLD="-DLLVM_ENABLE_LLD=ON" + echo "lld found, compiling with '$LLVM_ENABLE_LLD'" else echo "lld not found, using default linker" fi -# Call cmake -echo "Using additional flags: '$FLAGS'" - cmake -GNinja \ - "$FLAGS" \ - "-B$LLVM_BUILD_DIR" \ "-H$LLVM_SRC_DIR/llvm" \ + "-B$LLVM_BUILD_DIR" \ + -DLLVM_INSTALL_UTILS=ON \ + "$LLVM_ENABLE_LLD" \ + -DLLVM_ENABLE_PROJECTS=mlir \ + -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \ + -DLLVM_INCLUDE_TOOLS=ON \ + -DLLVM_ENABLE_BINDINGS=OFF \ + -DLLVM_BUILD_TOOLS=OFF \ + -DLLVM_INCLUDE_TESTS=OFF \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DLLVM_ENABLE_ASSERTIONS=On \ -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_C_COMPILER=clang \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DLLVM_BUILD_TOOLS=OFF \ - -DLLVM_ENABLE_ASSERTIONS=On \ - -DLLVM_ENABLE_BINDINGS=OFF \ - -DLLVM_ENABLE_PROJECTS=mlir \ - -DLLVM_INCLUDE_TESTS=OFF \ - -DLLVM_INCLUDE_TOOLS=ON \ - -DLLVM_INSTALL_UTILS=ON \ - -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" + -DCMAKE_C_COMPILER_LAUNCHER=ccache # Build LLVM/MLIR cmake --build "$LLVM_BUILD_DIR" --target all --target mlir-cpu-runner diff --git a/build_tools/github_actions/ci_build_stablehlo.sh b/build_tools/github_actions/ci_build_stablehlo.sh index fe11c1978a0..f130b9c2a60 100755 --- a/build_tools/github_actions/ci_build_stablehlo.sh +++ b/build_tools/github_actions/ci_build_stablehlo.sh @@ -14,7 +14,7 @@ # limitations under the License. # This file is similar to build_mlir.sh, but passes different flags for -# cacheing in GitHub Actions. +# caching in GitHub Actions. # This file gets called on build directory where resources are placed # during `ci_configure`, and builds stablehlo in the directory specified From 17fca58c2e9c73814973f06d1d0492fd064c9e5e Mon Sep 17 00:00:00 2001 From: Kevin Gleason Date: Tue, 30 Aug 2022 15:35:24 +0000 Subject: [PATCH 3/5] Incorporate Eugene's feedback. --- .github/workflows/buildAndTest.yml | 2 +- .github/workflows/lint.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildAndTest.yml b/.github/workflows/buildAndTest.yml index 072f3c30035..8abb9c4b2eb 100644 --- a/.github/workflows/buildAndTest.yml +++ b/.github/workflows/buildAndTest.yml @@ -6,7 +6,7 @@ on: pull_request: branches: [ main ] push: - branches: [ main, actions ] + branches: [ main ] schedule: # Run buildAndTest workflow once a day - cron: '* 12 * * *' diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 67aa7d404c5..edf18025084 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,10 +2,11 @@ name: Lint -on: [pull_request, push] +on: [pull_request] jobs: clang-format: + # This job can only be run on pull_request since GITHUB_BASE_REF is only set on PR. if: "github.event_name == 'pull_request'" runs-on: ubuntu-latest steps: From 280fee108ac44e0495fa5f392f79c60b04ab74ff Mon Sep 17 00:00:00 2001 From: Kevin Gleason Date: Thu, 1 Sep 2022 15:01:13 +0000 Subject: [PATCH 4/5] Addressed feedback - only run build and test on Linux --- .github/workflows/buildAndTest.yml | 7 +----- build_tools/github_actions/ci_build_llvm.sh | 13 ++--------- .../github_actions/ci_build_stablehlo.sh | 22 +++++-------------- 3 files changed, 9 insertions(+), 33 deletions(-) diff --git a/.github/workflows/buildAndTest.yml b/.github/workflows/buildAndTest.yml index 8abb9c4b2eb..192076f1cd2 100644 --- a/.github/workflows/buildAndTest.yml +++ b/.github/workflows/buildAndTest.yml @@ -27,16 +27,13 @@ jobs: strategy: fail-fast: false matrix: - os-arch: [maci-x86_64, ubuntu-x86_64] + os-arch: [ubuntu-x86_64] include: - os-arch: ubuntu-x86_64 os: ubuntu-22.04 - - os-arch: maci-x86_64 - os: macos-latest runs-on: ${{ matrix.os }} steps: - # Check out StableHLO repo - name: Checkout StableHLO uses: actions/checkout@v2 @@ -53,13 +50,11 @@ jobs: with: llvm-version: ${{ steps.llvm-version.outputs.version }} - # Configuration for linux - name: Configure and Build LLVM os-arch='${{ matrix.os-arch }}' shell: bash run: | ./build_tools/github_actions/ci_build_llvm.sh "$GITHUB_WORKSPACE/llvm-project/" "$GITHUB_WORKSPACE/llvm-build" - # Configure for linux - name: Build and Test StableHLO os-arch='${{ matrix.os-arch }}' run: | ./build_tools/github_actions/ci_build_stablehlo.sh "$GITHUB_WORKSPACE/llvm-build" "$GITHUB_WORKSPACE/stablehlo-build" diff --git a/build_tools/github_actions/ci_build_llvm.sh b/build_tools/github_actions/ci_build_llvm.sh index 95f40100547..0081a8ffb36 100755 --- a/build_tools/github_actions/ci_build_llvm.sh +++ b/build_tools/github_actions/ci_build_llvm.sh @@ -25,21 +25,12 @@ fi LLVM_SRC_DIR="$1" LLVM_BUILD_DIR="$2" -# Check for LLD -LLVM_ENABLE_LLD="" -if command -v lld &> /dev/null -then - LLVM_ENABLE_LLD="-DLLVM_ENABLE_LLD=ON" - echo "lld found, compiling with '$LLVM_ENABLE_LLD'" -else - echo "lld not found, using default linker" -fi - +# Configure LLVM cmake -GNinja \ "-H$LLVM_SRC_DIR/llvm" \ "-B$LLVM_BUILD_DIR" \ -DLLVM_INSTALL_UTILS=ON \ - "$LLVM_ENABLE_LLD" \ + -DLLVM_ENABLE_LLD=ON \ -DLLVM_ENABLE_PROJECTS=mlir \ -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \ -DLLVM_INCLUDE_TOOLS=ON \ diff --git a/build_tools/github_actions/ci_build_stablehlo.sh b/build_tools/github_actions/ci_build_stablehlo.sh index f130b9c2a60..534db670a9c 100755 --- a/build_tools/github_actions/ci_build_stablehlo.sh +++ b/build_tools/github_actions/ci_build_stablehlo.sh @@ -28,28 +28,18 @@ fi LLVM_BUILD_DIR="$1" STABLEHLO_BUILD_DIR="$2" -# Check for LLD -FLAGS="" -LLD_FLAG="-DLLVM_ENABLE_LLD=ON" -if command -v lld &> /dev/null -then - echo "lld found, appending flag '$LLD_FLAG'" - FLAGS="$LLD_FLAG" -else - echo "lld not found, using default linker" -fi - -# Build StableHLO +# Configure StableHLO cmake -GNinja \ - "$FLAGS" \ -B"$STABLEHLO_BUILD_DIR" \ + -DLLVM_ENABLE_LLD=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_ASSERTIONS=On \ + -DMLIR_DIR="$LLVM_BUILD_DIR/lib/cmake/mlir" \ -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_C_COMPILER=clang \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_BUILD_TYPE=Release \ - -DLLVM_ENABLE_ASSERTIONS=On \ - -DMLIR_DIR="$LLVM_BUILD_DIR/lib/cmake/mlir" +# Build and Check StableHLO cd "$STABLEHLO_BUILD_DIR" ninja check-stablehlo From 4ec1c7dcce0583db04f90fa30fbcb4d0a3ec909d Mon Sep 17 00:00:00 2001 From: Kevin Gleason Date: Thu, 1 Sep 2022 15:24:18 +0000 Subject: [PATCH 5/5] Remove Linux check for LLD install. --- .github/actions/setup-build/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/actions/setup-build/action.yml b/.github/actions/setup-build/action.yml index f8cc0af6fa7..8dcb8dbceab 100644 --- a/.github/actions/setup-build/action.yml +++ b/.github/actions/setup-build/action.yml @@ -28,7 +28,6 @@ runs: # Get LLD - Improves build speed on Linux - name: Install LLD - if: "runner.os == 'Linux'" shell: bash run: | sudo apt-get install -y lld