blob: 68303a3ea153a9208918a127e2922bf422ff62dc [file] [log] [blame]
Louis Dionnecf1a3d92023-06-12 21:45:481#!/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
16set -ex
17set -o pipefail
18
19MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
Mikhail Goncharov24846782023-09-11 11:20:3420BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}"
Louis Dionnecf1a3d92023-06-12 21:45:4821
Marc Auberer0a17eed2024-03-27 22:53:2522rm -rf "${BUILD_DIR}"
Louis Dionnecf1a3d92023-06-12 21:45:4823
Mikhail Goncharov24846782023-09-11 11:20:3424if [[ -n "${CLEAR_CACHE:-}" ]]; then
25 echo "clearing sccache"
26 rm -rf "$SCCACHE_DIR"
27fi
28
Louis Dionnecf1a3d92023-06-12 21:45:4829sccache --zero-stats
David Spickett889b3c92024-11-13 09:19:1030function at-exit {
David Spickett1b199d12025-01-13 09:05:1831 retcode=$?
32
Mikhail Goncharov24846782023-09-11 11:20:3433 mkdir -p artifacts
34 sccache --show-stats >> artifacts/sccache_stats.txt
David Spickett889b3c92024-11-13 09:19:1035
36 # If building fails there will be no results files.
37 shopt -s nullglob
Aiden Grossmana2464542024-12-16 09:01:0538 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 Spickett1b199d12025-01-13 09:05:1841 "windows-x64-test-results" $retcode "${BUILD_DIR}"/test-results.*.xml
Aiden Grossmana2464542024-12-16 09:01:0542 fi
Louis Dionnecf1a3d92023-06-12 21:45:4843}
David Spickett889b3c92024-11-13 09:19:1044trap at-exit EXIT
Louis Dionnecf1a3d92023-06-12 21:45:4845
46projects="${1}"
47targets="${2}"
48
49echo "--- cmake"
Marc Auberer0a17eed2024-03-27 22:53:2550pip install -q -r "${MONOREPO_ROOT}"/mlir/python/requirements.txt
David Spickett889b3c92024-11-13 09:19:1051pip install -q -r "${MONOREPO_ROOT}"/.ci/requirements.txt
Lucile Rose Nihlencd4e2462024-02-20 20:30:3852
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 Nihlend9dec102024-05-28 19:53:2158# We limit the number of parallel compile jobs to 24 control memory
59# consumption and improve build reliability.
Marc Auberer0a17eed2024-03-27 22:53:2560cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
Louis Dionnecf1a3d92023-06-12 21:45:4861 -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 Spickettf539d922024-11-12 13:24:4467 -D LLVM_LIT_ARGS="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --use-unique-output-file-name --timeout=1200 --time-tests" \
Louis Dionnecf1a3d92023-06-12 21:45:4868 -D COMPILER_RT_BUILD_ORC=OFF \
69 -D CMAKE_C_COMPILER_LAUNCHER=sccache \
Benjamin Maxwell21702522023-11-25 09:55:3270 -D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
Lucile Rose Nihlencd4e2462024-02-20 20:30:3871 -D MLIR_ENABLE_BINDINGS_PYTHON=ON \
72 -D CMAKE_EXE_LINKER_FLAGS="/MANIFEST:NO" \
73 -D CMAKE_MODULE_LINKER_FLAGS="/MANIFEST:NO" \
Lucile Rose Nihlend9dec102024-05-28 19:53:2174 -D CMAKE_SHARED_LINKER_FLAGS="/MANIFEST:NO" \
75 -D LLVM_PARALLEL_COMPILE_JOBS=16 \
76 -D LLVM_PARALLEL_LINK_JOBS=4
Louis Dionnecf1a3d92023-06-12 21:45:4877
78echo "--- ninja"
Mikhail Goncharov98a845c2023-09-13 11:02:5579# Targets are not escaped as they are passed as separate arguments.
Marc Auberer64f04102024-03-28 01:03:2480ninja -C "${BUILD_DIR}" -k 0 ${targets}