Louis Dionne | cf1a3d9 | 2023-06-12 21:45:48 | [diff] [blame] | 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)"}" |
Mikhail Goncharov | 2484678 | 2023-09-11 11:20:34 | [diff] [blame] | 20 | BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}" |
Louis Dionne | cf1a3d9 | 2023-06-12 21:45:48 | [diff] [blame] | 21 | |
Marc Auberer | 0a17eed | 2024-03-27 22:53:25 | [diff] [blame] | 22 | rm -rf "${BUILD_DIR}" |
Louis Dionne | cf1a3d9 | 2023-06-12 21:45:48 | [diff] [blame] | 23 | |
Mikhail Goncharov | 2484678 | 2023-09-11 11:20:34 | [diff] [blame] | 24 | if [[ -n "${CLEAR_CACHE:-}" ]]; then |
| 25 | echo "clearing sccache" |
| 26 | rm -rf "$SCCACHE_DIR" |
| 27 | fi |
| 28 | |
Louis Dionne | cf1a3d9 | 2023-06-12 21:45:48 | [diff] [blame] | 29 | sccache --zero-stats |
David Spickett | 889b3c9 | 2024-11-13 09:19:10 | [diff] [blame] | 30 | function at-exit { |
David Spickett | 1b199d1 | 2025-01-13 09:05:18 | [diff] [blame] | 31 | retcode=$? |
| 32 | |
Mikhail Goncharov | 2484678 | 2023-09-11 11:20:34 | [diff] [blame] | 33 | mkdir -p artifacts |
| 34 | sccache --show-stats >> artifacts/sccache_stats.txt |
David Spickett | 889b3c9 | 2024-11-13 09:19:10 | [diff] [blame] | 35 | |
| 36 | # If building fails there will be no results files. |
| 37 | shopt -s nullglob |
Aiden Grossman | a246454 | 2024-12-16 09:01:05 | [diff] [blame] | 38 | if command -v buildkite-agent 2>&1 >/dev/null |
| 39 | then |
| 40 | python "${MONOREPO_ROOT}"/.ci/generate_test_report.py ":windows: Windows x64 Test Results" \ |
David Spickett | 1b199d1 | 2025-01-13 09:05:18 | [diff] [blame] | 41 | "windows-x64-test-results" $retcode "${BUILD_DIR}"/test-results.*.xml |
Aiden Grossman | a246454 | 2024-12-16 09:01:05 | [diff] [blame] | 42 | fi |
Louis Dionne | cf1a3d9 | 2023-06-12 21:45:48 | [diff] [blame] | 43 | } |
David Spickett | 889b3c9 | 2024-11-13 09:19:10 | [diff] [blame] | 44 | trap at-exit EXIT |
Louis Dionne | cf1a3d9 | 2023-06-12 21:45:48 | [diff] [blame] | 45 | |
| 46 | projects="${1}" |
| 47 | targets="${2}" |
| 48 | |
| 49 | echo "--- cmake" |
Marc Auberer | 0a17eed | 2024-03-27 22:53:25 | [diff] [blame] | 50 | pip install -q -r "${MONOREPO_ROOT}"/mlir/python/requirements.txt |
David Spickett | 889b3c9 | 2024-11-13 09:19:10 | [diff] [blame] | 51 | pip install -q -r "${MONOREPO_ROOT}"/.ci/requirements.txt |
Lucile Rose Nihlen | cd4e246 | 2024-02-20 20:30:38 | [diff] [blame] | 52 | |
| 53 | # The CMAKE_*_LINKER_FLAGS to disable the manifest come from research |
| 54 | # on fixing a build reliability issue on the build server, please |
| 55 | # see https://github.com/llvm/llvm-project/pull/82393 and |
| 56 | # https://discourse.llvm.org/t/rfc-future-of-windows-pre-commit-ci/76840/40 |
| 57 | # for further information. |
Lucile Rose Nihlen | d9dec10 | 2024-05-28 19:53:21 | [diff] [blame] | 58 | # We limit the number of parallel compile jobs to 24 control memory |
| 59 | # consumption and improve build reliability. |
Marc Auberer | 0a17eed | 2024-03-27 22:53:25 | [diff] [blame] | 60 | cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \ |
Louis Dionne | cf1a3d9 | 2023-06-12 21:45:48 | [diff] [blame] | 61 | -D LLVM_ENABLE_PROJECTS="${projects}" \ |
| 62 | -G Ninja \ |
| 63 | -D CMAKE_BUILD_TYPE=Release \ |
| 64 | -D LLVM_ENABLE_ASSERTIONS=ON \ |
| 65 | -D LLVM_BUILD_EXAMPLES=ON \ |
| 66 | -D COMPILER_RT_BUILD_LIBFUZZER=OFF \ |
David Spickett | f539d92 | 2024-11-12 13:24:44 | [diff] [blame] | 67 | -D LLVM_LIT_ARGS="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --use-unique-output-file-name --timeout=1200 --time-tests" \ |
Louis Dionne | cf1a3d9 | 2023-06-12 21:45:48 | [diff] [blame] | 68 | -D COMPILER_RT_BUILD_ORC=OFF \ |
| 69 | -D CMAKE_C_COMPILER_LAUNCHER=sccache \ |
Benjamin Maxwell | 2170252 | 2023-11-25 09:55:32 | [diff] [blame] | 70 | -D CMAKE_CXX_COMPILER_LAUNCHER=sccache \ |
Lucile Rose Nihlen | cd4e246 | 2024-02-20 20:30:38 | [diff] [blame] | 71 | -D MLIR_ENABLE_BINDINGS_PYTHON=ON \ |
| 72 | -D CMAKE_EXE_LINKER_FLAGS="/MANIFEST:NO" \ |
| 73 | -D CMAKE_MODULE_LINKER_FLAGS="/MANIFEST:NO" \ |
Lucile Rose Nihlen | d9dec10 | 2024-05-28 19:53:21 | [diff] [blame] | 74 | -D CMAKE_SHARED_LINKER_FLAGS="/MANIFEST:NO" \ |
| 75 | -D LLVM_PARALLEL_COMPILE_JOBS=16 \ |
| 76 | -D LLVM_PARALLEL_LINK_JOBS=4 |
Louis Dionne | cf1a3d9 | 2023-06-12 21:45:48 | [diff] [blame] | 77 | |
| 78 | echo "--- ninja" |
Mikhail Goncharov | 98a845c | 2023-09-13 11:02:55 | [diff] [blame] | 79 | # Targets are not escaped as they are passed as separate arguments. |
Marc Auberer | 64f0410 | 2024-03-28 01:03:24 | [diff] [blame] | 80 | ninja -C "${BUILD_DIR}" -k 0 ${targets} |