1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
#!/usr/bin/env bash
#===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, 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
#
#===----------------------------------------------------------------------===##
set -ex
set -o pipefail
unset LANG
unset LC_ALL
unset LC_COLLATE
PROGNAME="$(basename "${0}")"
function usage() {
cat <<EOF
Usage:
${PROGNAME} [options] <BUILDER>
[-h|--help] Display this help and exit.
--llvm-root <DIR> Path to the root of the LLVM monorepo. By default, we try
to figure it out based on the current working directory.
--build-dir <DIR> The directory to use for building the library. By default,
this is '<llvm-root>/build/<builder>'.
EOF
}
if [[ $# == 0 ]]; then
usage
exit 0
fi
while [[ $# -gt 0 ]]; do
case ${1} in
-h|--help)
usage
exit 0
;;
--llvm-root)
MONOREPO_ROOT="${2}"
shift; shift
;;
--build-dir)
BUILD_DIR="${2}"
shift; shift
;;
*)
BUILDER="${1}"
shift
;;
esac
done
MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build/${BUILDER}}"
INSTALL_DIR="${BUILD_DIR}/install"
function clean() {
rm -rf "${BUILD_DIR}"
}
# Print the version of a few tools to aid diagnostics in some cases
cmake --version
ninja --version
case "${BUILDER}" in
check-format)
echo "*** Checking for trailing whitespace left in Clang source files ***"
if grep -rnI '[[:blank:]]$' clang/lib clang/include clang/docs; then
echo "*** Trailing whitespace has been found in Clang source files as described above ***"
exit 1
fi
;;
build-clang)
mkdir install
# We use Release here to avoid including debug information. Otherwise, the
# clang binary is very large, which is problematic because we need to upload
# the artifacts for other jobs to use. This may seem like nothing, but with
# the number of jobs we run daily, this can result in thousands of GB of
# network I/O.
cmake \
-S llvm \
-B ${BUILD_DIR} \
-G Ninja \
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=install \
-DLLVM_ENABLE_PROJECTS="clang;compiler-rt" \
ninja -C ${BUILD_DIR} install-clang install-clang-resource-headers
ccache -s
tar -cJvf install.tar.xz install/
buildkite-agent artifact upload --debug install.tar.xz
ninja -C ${BUILD_DIR} check-clang
;;
build-clang-windows)
cmake -S llvm -B ${BUILD_DIR} -G Ninja \
-D CMAKE_C_COMPILER_LAUNCHER=sccache \
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=install-windows \
-D LLVM_ENABLE_PROJECTS="clang;compiler-rt" \
-D LLVM_ENABLE_ASSERTIONS=ON \
-D LLVM_BUILD_EXAMPLES=ON \
-D COMPILER_RT_BUILD_LIBFUZZER=OFF \
-D COMPILER_RT_BUILD_ORC=OFF
ninja -C ${BUILD_DIR} install-clang install-clang-resource-headers
ninja -C ${BUILD_DIR} check-clang
;;
generic-cxx03)
buildkite-agent artifact download install.tar.xz .
tar -xvf install.tar.xz
export CC=$(pwd)/install/bin/clang
export CXX=$(pwd)/install/bin/clang++
chmod +x install/bin/clang install/bin/clang++
clean
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${BUILD_DIR}" -GNinja \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
-DLIBCXX_CXX_ABI=libcxxabi \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
-DLIBCXX_TEST_PARAMS="std=c++03" \
-DLIBCXXABI_TEST_PARAMS="std=c++03"
ninja -vC "${BUILD_DIR}" check-runtimes
;;
generic-cxx26)
buildkite-agent artifact download install.tar.xz .
tar -xvf install.tar.xz
export CC=$(pwd)/install/bin/clang
export CXX=$(pwd)/install/bin/clang++
chmod +x install/bin/clang install/bin/clang++
clean
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${BUILD_DIR}" -GNinja \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
-DLIBCXX_CXX_ABI=libcxxabi \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
-DLIBCXX_TEST_PARAMS="std=c++26" \
-DLIBCXXABI_TEST_PARAMS="std=c++26"
ninja -vC "${BUILD_DIR}" check-runtimes
;;
generic-modules)
buildkite-agent artifact download install.tar.xz .
tar -xvf install.tar.xz
export CC=$(pwd)/install/bin/clang
export CXX=$(pwd)/install/bin/clang++
chmod +x install/bin/clang install/bin/clang++
clean
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${BUILD_DIR}" -GNinja \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
-DLIBCXX_CXX_ABI=libcxxabi \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
-DLIBCXX_TEST_PARAMS="enable_modules=clang" \
-DLIBCXXABI_TEST_PARAMS="enable_modules=clang"
ninja -vC "${BUILD_DIR}" check-runtimes
;;
#################################################################
# Insert vendor-specific internal configurations below.
#
# This allows vendors to extend this file with their own internal
# configurations without running into merge conflicts with upstream.
#################################################################
#################################################################
*)
echo "${BUILDER} is not a known configuration"
exit 1
;;
esac
|