From a7e578845ba120c3ac452ddff67303c8772aa5b6 Mon Sep 17 00:00:00 2001 From: Scott Todd Date: Thu, 8 Aug 2024 15:34:17 -0700 Subject: [PATCH] Switch from build_runtime_*.sh to inlined CMake commands. (#18164) Similar to https://github.com/iree-org/iree/pull/18162, this reduces the reliance on scripts in [`build_tools/cmake/`](https://github.com/iree-org/iree/tree/main/build_tools/cmake) by inlining the CMake commands used for these build configurations. Summary of changes: * Deleted `build_tools/cmake/build_runtime_small.sh` and `build_tools/cmake/build_runtime_tracing.sh` * Fixed size-optimized ("small") options used in the "small runtime" job and resolved an unused variable warning/error in `runtime/src/iree/hal/drivers/hip/dynamic_symbols.c` that slipped through. When we landed https://github.com/iree-org/iree/pull/16811, it used old CMake variables in the `build_tools/cmake/build_runtime_small.sh` script. Oops! * Renamed jobs so they all begin with `runtime` | name before | name after | -- | -- `build_test_runtime` | `runtime` `small_runtime` | `runtime_small` `tracing` | `runtime_tracing` Seeing these runtime jobs next to each other, we could expand the build matrix even further ("all platforms" x "all configurations"). Leaving that for the future. Now it's easier to see what the jobs have in common and how they differ. --- .github/workflows/ci.yml | 115 +++++++++++------- build_tools/cmake/build_runtime_small.sh | 28 ----- build_tools/cmake/build_runtime_tracing.sh | 29 ----- .../iree/hal/drivers/hip/dynamic_symbols.c | 4 + 4 files changed, 77 insertions(+), 99 deletions(-) delete mode 100755 build_tools/cmake/build_runtime_small.sh delete mode 100755 build_tools/cmake/build_runtime_tracing.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2bfa1a96e3e..d5b45e8d30e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -148,10 +148,10 @@ jobs: # Jobs that build IREE in some non-default configuration ############################################################################## - build_test_runtime: + runtime: needs: setup - name: "build_test_runtime :: ${{ matrix.name }}" - if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'build_test_runtime') + name: "runtime :: ${{ matrix.name }}" + if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'runtime') runs-on: ${{ matrix.runs-on }} defaults: run: @@ -215,55 +215,86 @@ jobs: - name: CTest run: bash ./build_tools/cmake/ctest_all.sh "${BUILD_DIR}" - small_runtime: + runtime_small: needs: setup - if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'small_runtime') + if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'runtime_small') runs-on: ubuntu-20.04 env: BUILD_DIR: build-runtime steps: - - name: "Checking out repository" - uses: actions/checkout@v4.1.7 - - name: "Checking out runtime submodules" - run: ./build_tools/scripts/git/update_runtime_submodules.sh - - name: "Building size-optimized runtime" + - uses: actions/checkout@v4.1.7 + - name: Install requirements run: | - ./build_tools/github_actions/docker_run.sh \ - gcr.io/iree-oss/base@sha256:dc314b4fe30fc1315742512891357bffed4d1b62ffcb46258b1e0761c737b446 \ - ./build_tools/cmake/build_runtime_small.sh \ - "${BUILD_DIR}" - - name: "Testing runtime" + sudo apt update + sudo apt install -y ninja-build + echo "CC=clang" >> $GITHUB_ENV + echo "CXX=clang++" >> $GITHUB_ENV + - name: Checkout runtime submodules + run: bash ./build_tools/scripts/git/update_runtime_submodules.sh + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }} + save: ${{ needs.setup.outputs.write-caches == 1 }} + - name: CMake - configure run: | - ./build_tools/github_actions/docker_run.sh \ - gcr.io/iree-oss/base@sha256:dc314b4fe30fc1315742512891357bffed4d1b62ffcb46258b1e0761c737b446 \ - ./build_tools/cmake/ctest_all.sh \ - "${BUILD_DIR}" + cmake \ + -G Ninja \ + -B ${BUILD_DIR} \ + -DCMAKE_BUILD_TYPE=MinSizeRel \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DIREE_BUILD_COMPILER=OFF \ + -DIREE_RUNTIME_OPTIMIZATION_PROFILE=size \ + -DIREE_ENABLE_LLD=ON + - name: CMake - build + run: cmake --build ${BUILD_DIR} -- -k 0 + - name: CTest + run: bash ./build_tools/cmake/ctest_all.sh "${BUILD_DIR}" - tracing: + runtime_tracing: needs: setup - if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'tracing') + name: "runtime_tracing :: ${{ matrix.provider }} provider" + if: contains(fromJson(needs.setup.outputs.enabled-jobs), 'runtime_tracing') runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + include: + - provider: tracy + - provider: console env: BUILD_DIR: build-tracing + TRACING_PROVIDER: ${{ matrix.provider }} steps: - - name: "Checking out repository" - uses: actions/checkout@v4.1.7 - - name: "Checking out runtime submodules" - run: ./build_tools/scripts/git/update_runtime_submodules.sh - - name: "Building IREE runtime with tracing - Tracy" + - uses: actions/checkout@v4.1.7 + - name: Install requirements run: | - ./build_tools/github_actions/docker_run.sh \ - --env "TRACING_PROVIDER=tracy" \ - gcr.io/iree-oss/base@sha256:dc314b4fe30fc1315742512891357bffed4d1b62ffcb46258b1e0761c737b446 \ - ./build_tools/cmake/build_runtime_tracing.sh \ - "${BUILD_DIR}" - - name: "Building IREE runtime with tracing - console" + sudo apt update + sudo apt install -y ninja-build + echo "CC=clang" >> $GITHUB_ENV + echo "CXX=clang++" >> $GITHUB_ENV + - name: Checkout runtime submodules + run: bash ./build_tools/scripts/git/update_runtime_submodules.sh + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ github.job }}-${{ matrix.provider }} + save: ${{ needs.setup.outputs.write-caches == 1 }} + - name: CMake - configure run: | - ./build_tools/github_actions/docker_run.sh \ - --env "TRACING_PROVIDER=console" \ - gcr.io/iree-oss/base@sha256:dc314b4fe30fc1315742512891357bffed4d1b62ffcb46258b1e0761c737b446 \ - ./build_tools/cmake/build_runtime_tracing.sh \ - "${BUILD_DIR}" + cmake \ + -G Ninja \ + -B ${BUILD_DIR} \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DIREE_BUILD_COMPILER=OFF \ + -DIREE_ENABLE_LLD=ON \ + -DIREE_ENABLE_RUNTIME_TRACING=ON \ + -DIREE_TRACING_PROVIDER=${TRACING_PROVIDER} + - name: CMake - build + run: cmake --build ${BUILD_DIR} -- -k 0 ############################## Crosscompilation ############################## # Jobs that cross-compile IREE for other platforms @@ -365,16 +396,16 @@ jobs: needs: - setup - # Basic + # Toolchains - build_test_all_bazel # Accelerators # - test_nvidia_a100 - # Configurations - - build_test_runtime - - small_runtime - - tracing + # Runtime build variants + - runtime + - runtime_small + - runtime_tracing # Crosscompilation # - cross_compile_and_test diff --git a/build_tools/cmake/build_runtime_small.sh b/build_tools/cmake/build_runtime_small.sh deleted file mode 100755 index eb456e2aff26..000000000000 --- a/build_tools/cmake/build_runtime_small.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# Copyright 2021 The IREE Authors -# -# Licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Build IREE's runtime using CMake. Designed for CI, but can be run manually. -# This uses previously cached build results and does not clear build -# directories. - -set -xeuo pipefail - -BUILD_DIR="${1:-${IREE_RUNTIME_SMALL_BUILD_DIR:-build-runtime-small}}" - -source build_tools/cmake/setup_build.sh -# Note: not using ccache since the runtime build should be fast already. - -"${CMAKE_BIN?}" -B "${BUILD_DIR}" \ - -G Ninja . \ - -DPython3_EXECUTABLE="${IREE_PYTHON3_EXECUTABLE}" \ - -DPYTHON_EXECUTABLE="${IREE_PYTHON3_EXECUTABLE}" \ - -DCMAKE_BUILD_TYPE=MinSizeRel \ - -DIREE_SIZE_OPTIMIZED=ON \ - -DIREE_FORCE_LTO_COMPAT_BINUTILS_ON_LINUX=size \ - -DIREE_FORCE_GCC_BINUTILS_ON_LINUX=ON \ - -DIREE_BUILD_COMPILER=OFF -"${CMAKE_BIN?}" --build "${BUILD_DIR}" -- -k 0 diff --git a/build_tools/cmake/build_runtime_tracing.sh b/build_tools/cmake/build_runtime_tracing.sh deleted file mode 100755 index c52b21f7acfb..000000000000 --- a/build_tools/cmake/build_runtime_tracing.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# Copyright 2021 The IREE Authors -# -# Licensed under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Build IREE using CMake with tracing enabled. Designed for CI, but can be run -# manually. This uses previously cached build results and does not clear build -# directories. - -set -xeuo pipefail - -BUILD_DIR="${1:-${IREE_TRACING_BUILD_DIR:-build-tracing}}" -TRACING_PROVIDER="${TRACING_PROVIDER:-tracy}" - -source build_tools/cmake/setup_build.sh -# Note: not using ccache since the runtime build should be fast already. - -"${CMAKE_BIN?}" -B "${BUILD_DIR}" \ - -G Ninja . \ - -DPython3_EXECUTABLE="${IREE_PYTHON3_EXECUTABLE}" \ - -DPYTHON_EXECUTABLE="${IREE_PYTHON3_EXECUTABLE}" \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DIREE_ENABLE_LLD=ON \ - -DIREE_ENABLE_RUNTIME_TRACING=ON \ - -DIREE_TRACING_PROVIDER=${TRACING_PROVIDER} \ - -DIREE_BUILD_COMPILER=OFF -"${CMAKE_BIN?}" --build "${BUILD_DIR}" -- -k 0 diff --git a/runtime/src/iree/hal/drivers/hip/dynamic_symbols.c b/runtime/src/iree/hal/drivers/hip/dynamic_symbols.c index 83496cfb37be..7e3dbc7496b5 100644 --- a/runtime/src/iree/hal/drivers/hip/dynamic_symbols.c +++ b/runtime/src/iree/hal/drivers/hip/dynamic_symbols.c @@ -150,6 +150,7 @@ iree_status_t iree_hal_hip_dynamic_symbols_initialize( if (loaded_one) { status = iree_hal_hip_dynamic_symbols_resolve_all(out_syms); } else { +#if IREE_STATUS_MODE iree_string_view_t error_detail = iree_string_builder_view(&error_builder); status = iree_make_status( @@ -157,6 +158,9 @@ iree_status_t iree_hal_hip_dynamic_symbols_initialize( "HIP runtime library 'amdhip64.dll'/'libamdhip64.so' not available: " "please ensure installed and in dynamic library search path: %.*s", (int)error_detail.size, error_detail.data); +#else + return iree_make_status(IREE_STATUS_UNAVAILABLE); +#endif // IREE_STATUS_MODE } } if (!iree_status_is_ok(status)) {