| 1 | #!/usr/bin/env bash |
| 2 | #===----------------------------------------------------------------------===## |
| 3 | # |
| 4 | # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | # See https://llvm.org/LICENSE.txt for license information. |
| 6 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | # |
| 8 | #===----------------------------------------------------------------------===## |
| 9 | |
| 10 | # |
| 11 | # This script performs a monolithic build of the monorepo and runs the tests of |
| 12 | # most projects on Windows. This should be replaced by per-project scripts that |
| 13 | # run only the relevant tests. |
| 14 | # |
| 15 | |
| 16 | set -ex |
| 17 | set -o pipefail |
| 18 | |
| 19 | MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}" |
| 20 | BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}" |
| 21 | |
| 22 | rm -rf "${BUILD_DIR}" |
| 23 | |
| 24 | if [[ -n "${CLEAR_CACHE:-}" ]]; then |
| 25 | echo "clearing sccache" |
| 26 | rm -rf "$SCCACHE_DIR" |
| 27 | fi |
| 28 | |
| 29 | sccache --zero-stats |
| 30 | function show-stats { |
| 31 | mkdir -p artifacts |
| 32 | sccache --show-stats >> artifacts/sccache_stats.txt |
| 33 | } |
| 34 | trap show-stats EXIT |
| 35 | |
| 36 | projects="${1}" |
| 37 | targets="${2}" |
| 38 | |
| 39 | echo "--- cmake" |
| 40 | pip install -q -r "${MONOREPO_ROOT}"/mlir/python/requirements.txt |
| 41 | |
| 42 | # The CMAKE_*_LINKER_FLAGS to disable the manifest come from research |
| 43 | # on fixing a build reliability issue on the build server, please |
| 44 | # see https://github.com/llvm/llvm-project/pull/82393 and |
| 45 | # https://discourse.llvm.org/t/rfc-future-of-windows-pre-commit-ci/76840/40 |
| 46 | # for further information. |
| 47 | # We limit the number of parallel compile jobs to 24 control memory |
| 48 | # consumption and improve build reliability. |
| 49 | cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \ |
| 50 | -D LLVM_ENABLE_PROJECTS="${projects}" \ |
| 51 | -G Ninja \ |
| 52 | -D CMAKE_BUILD_TYPE=Release \ |
| 53 | -D LLVM_ENABLE_ASSERTIONS=ON \ |
| 54 | -D LLVM_BUILD_EXAMPLES=ON \ |
| 55 | -D COMPILER_RT_BUILD_LIBFUZZER=OFF \ |
| 56 | -D LLVM_LIT_ARGS="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --timeout=1200 --time-tests" \ |
| 57 | -D COMPILER_RT_BUILD_ORC=OFF \ |
| 58 | -D CMAKE_C_COMPILER_LAUNCHER=sccache \ |
| 59 | -D CMAKE_CXX_COMPILER_LAUNCHER=sccache \ |
| 60 | -D MLIR_ENABLE_BINDINGS_PYTHON=ON \ |
| 61 | -D CMAKE_EXE_LINKER_FLAGS="/MANIFEST:NO" \ |
| 62 | -D CMAKE_MODULE_LINKER_FLAGS="/MANIFEST:NO" \ |
| 63 | -D CMAKE_SHARED_LINKER_FLAGS="/MANIFEST:NO" \ |
| 64 | -D LLVM_PARALLEL_COMPILE_JOBS=16 \ |
| 65 | -D LLVM_PARALLEL_LINK_JOBS=4 |
| 66 | |
| 67 | echo "--- ninja" |
| 68 | # Targets are not escaped as they are passed as separate arguments. |
| 69 | ninja -C "${BUILD_DIR}" -k 0 ${targets} |