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
10set -ex
11set -o pipefail
12unset LANG
13unset LC_ALL
14unset LC_COLLATE
15
16PROGNAME="$(basename "${0}")"
17
18function usage() {
19cat <<EOF
20Usage:
21${PROGNAME} [options] <BUILDER>
22
23[-h|--help]         Display this help and exit.
24
25--llvm-root <DIR>   Path to the root of the LLVM monorepo. By default, we try
26                    to figure it out based on the current working directory.
27
28--build-dir <DIR>   The directory to use for building the library. By default,
29                    this is '<llvm-root>/build/<builder>'.
30
31--osx-roots <DIR>   Path to pre-downloaded macOS dylibs. By default, we download
32                    them from Green Dragon. This is only relevant at all when
33                    running back-deployment testing if one wants to override
34                    the old dylibs we use to run the tests with different ones.
35Environment variables
36CC                  The C compiler to use, this value is used by CMake. This
37                    variable is optional.
38CXX                 The C++ compiler to use, this value is used by CMake. This
39                    variable is optional.
40
41GIT_CLANG_FORMAT    The git-clang-format binary to use in the 'format' builder.
42                    When the value is omitted, it defaults to
43                    'git-clang-format'. This variable or its fallback must work
44                    when running the 'format' builder.
45
46ENABLE_CLANG_TIDY   Whether to compile and run clang-tidy checks. This variable
47                    is optional
48EOF
49}
50
51if [[ $# == 0 ]]; then
52   usage
53   exit 0
54fi
55
56while [[ $# -gt 0 ]]; do
57    case ${1} in
58        -h|--help)
59            usage
60            exit 0
61            ;;
62        --llvm-root)
63            MONOREPO_ROOT="${2}"
64            shift; shift
65            ;;
66        --build-dir)
67            BUILD_DIR="${2}"
68            shift; shift
69            ;;
70        --osx-roots)
71            OSX_ROOTS="${2}"
72            shift; shift
73            ;;
74        *)
75            BUILDER="${1}"
76            shift
77            ;;
78    esac
79done
80
81MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
82BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build/${BUILDER}}"
83INSTALL_DIR="${BUILD_DIR}/install"
84
85# If we can find Ninja/CMake provided by Xcode, use those since we know their
86# version will generally work with the Clang shipped in Xcode (e.g. if Clang
87# knows about -std=c++20, the CMake bundled in Xcode will probably know about
88# that flag too).
89if xcrun --find ninja &>/dev/null; then NINJA="$(xcrun --find ninja)"; else NINJA="ninja"; fi
90if xcrun --find cmake &>/dev/null; then CMAKE="$(xcrun --find cmake)"; else CMAKE="cmake"; fi
91
92function clean() {
93    rm -rf "${BUILD_DIR}"
94}
95
96if [ -z "${ENABLE_CLANG_TIDY}" ]; then
97    ENABLE_CLANG_TIDY=Off
98fi
99
100function generate-cmake-base() {
101    echo "--- Generating CMake"
102    ${CMAKE} \
103          -S "${MONOREPO_ROOT}/runtimes" \
104          -B "${BUILD_DIR}" \
105          -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
106          -DCMAKE_BUILD_TYPE=RelWithDebInfo \
107          -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
108          -DLIBCXX_ENABLE_WERROR=YES \
109          -DLIBCXXABI_ENABLE_WERROR=YES \
110          -DLIBUNWIND_ENABLE_WERROR=YES \
111          -DLIBCXX_ENABLE_CLANG_TIDY=${ENABLE_CLANG_TIDY} \
112          -DLLVM_LIT_ARGS="-sv --show-unsupported --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
113          "${@}"
114}
115
116function generate-cmake() {
117    generate-cmake-base \
118          -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
119          -DLIBCXX_CXX_ABI=libcxxabi \
120          "${@}"
121}
122
123function generate-cmake-libcxx-win() {
124    # TODO: Clang-cl in MSVC configurations don't have access to compiler_rt
125    # builtins helpers for int128 division. See
126    # https://reviews.llvm.org/D91139#2429595 for a comment about longterm
127    # intent for handling the issue. In the meantime, define
128    # -D_LIBCPP_HAS_NO_INT128 (both when building the library itself and
129    # when building tests) to allow enabling filesystem for running tests,
130    # even if it uses a non-permanent ABI.
131    generate-cmake-base \
132          -DLLVM_ENABLE_RUNTIMES="libcxx" \
133          -DCMAKE_C_COMPILER=clang-cl \
134          -DCMAKE_CXX_COMPILER=clang-cl \
135          -DLIBCXX_ENABLE_FILESYSTEM=YES \
136          -DLIBCXX_EXTRA_SITE_DEFINES="_LIBCPP_HAS_NO_INT128" \
137          "${@}"
138}
139
140function check-runtimes() {
141    echo "--- Installing libc++, libc++abi and libunwind to a fake location"
142    ${NINJA} -vC "${BUILD_DIR}" install-cxx install-cxxabi install-unwind
143
144    echo "+++ Running the libc++ tests"
145    ${NINJA} -vC "${BUILD_DIR}" check-cxx
146
147    echo "+++ Running the libc++abi tests"
148    ${NINJA} -vC "${BUILD_DIR}" check-cxxabi
149
150    echo "+++ Running the libunwind tests"
151    ${NINJA} -vC "${BUILD_DIR}" check-unwind
152}
153
154# TODO: The goal is to test this against all configurations. We should also move
155#       this to the Lit test suite instead of being a separate CMake target.
156function check-abi-list() {
157    echo "+++ Running the libc++ ABI list test"
158    ${NINJA} -vC "${BUILD_DIR}" check-cxx-abilist || (
159        echo "+++ Generating the libc++ ABI list after failed check"
160        ${NINJA} -vC "${BUILD_DIR}" generate-cxx-abilist
161        false
162    )
163}
164
165function check-cxx-benchmarks() {
166    echo "--- Running the benchmarks"
167    ${NINJA} -vC "${BUILD_DIR}" check-cxx-benchmarks
168}
169
170# Print the version of a few tools to aid diagnostics in some cases
171${CMAKE} --version
172${NINJA} --version
173
174if [ ! -z "${CXX}" ]; then ${CXX} --version; fi
175
176case "${BUILDER}" in
177check-format)
178    clean
179    echo "+++ Checking formatting"
180    # We need to set --extensions so that clang-format checks extensionless files.
181    mkdir -p ${BUILD_DIR}
182    if [ -z "${GIT_CLANG_FORMAT}" ]; then
183       GIT_CLANG_FORMAT=git-clang-format
184    fi
185    ${GIT_CLANG_FORMAT} \
186        --diff \
187        --extensions ',h,hh,hpp,hxx,c,cc,cxx,cpp' HEAD~1 \
188        -- \
189            libcxx/{benchmarks,include,src,test} \
190            libcxxabi/{fuzz,include,src,test} \
191        | tee ${BUILD_DIR}/clang-format.patch
192    # Check if the diff is empty, fail otherwise.
193    ! grep -q '^--- a' ${BUILD_DIR}/clang-format.patch
194;;
195check-generated-output)
196    # `! foo` doesn't work properly with `set -e`, use `! foo || false` instead.
197    # https://stackoverflow.com/questions/57681955/set-e-does-not-respect-logical-not
198    clean
199    generate-cmake
200
201    # Reject patches that forgot to re-run the generator scripts.
202    echo "+++ Making sure the generator scripts were run"
203    ${NINJA} -vC "${BUILD_DIR}" libcxx-generate-files
204    git diff | tee ${BUILD_DIR}/generated_output.patch
205    git ls-files -o --exclude-standard | tee ${BUILD_DIR}/generated_output.status
206    ! grep -q '^--- a' ${BUILD_DIR}/generated_output.patch || false
207    if [ -s ${BUILD_DIR}/generated_output.status ]; then
208        echo "It looks like not all the generator scripts were run,"
209        echo "did you forget to build the libcxx-generate-files target?"
210        echo "Did you add all new files it generated?"
211        false
212    fi
213
214    # Reject patches that introduce non-ASCII characters or hard tabs.
215    # Depends on LC_COLLATE set at the top of this script.
216    ! grep -rn '[^ -~]' libcxx/include libcxx/src libcxx/test libcxx/benchmarks \
217           --exclude '*.dat' \
218           --exclude 'escaped_output.*.pass.cpp' \
219           --exclude 'format_tests.h' \
220           --exclude 'format.functions.tests.h' \
221           --exclude 'formatter.*.pass.cpp' \
222           --exclude 'grep.pass.cpp' \
223           --exclude 'locale-specific_form.pass.cpp' \
224           --exclude 'ostream.pass.cpp' \
225           --exclude 'std_format_spec_string_unicode.bench.cpp' \
226           --exclude 'underflow.pass.cpp' \
227           || false
228
229    # Reject code with trailing whitespace
230    ! grep -rn '[[:blank:]]$' libcxx/include libcxx/src libcxx/test libcxx/benchmarks || false
231;;
232#
233# Various Standard modes
234#
235generic-cxx03)
236    clean
237    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx03.cmake"
238    check-runtimes
239    check-abi-list
240;;
241generic-cxx11)
242    clean
243    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx11.cmake"
244    check-runtimes
245    check-abi-list
246;;
247generic-cxx14)
248    clean
249    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx14.cmake"
250    check-runtimes
251    check-abi-list
252;;
253generic-cxx17)
254    clean
255    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx17.cmake"
256    check-runtimes
257    check-abi-list
258;;
259generic-cxx20)
260    clean
261    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx20.cmake"
262    check-runtimes
263    check-abi-list
264;;
265generic-cxx2b)
266    clean
267    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx2b.cmake"
268    check-runtimes
269    check-abi-list
270;;
271#
272# Other compiler support
273#
274generic-gcc)
275    clean
276    generate-cmake -DLIBCXX_ENABLE_WERROR=NO \
277                   -DLIBCXXABI_ENABLE_WERROR=NO \
278                   -DLIBUNWIND_ENABLE_WERROR=NO
279    check-runtimes
280;;
281generic-gcc-cxx11)
282    clean
283    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx11.cmake" \
284                   -DLIBCXX_ENABLE_WERROR=NO \
285                   -DLIBCXXABI_ENABLE_WERROR=NO \
286                   -DLIBUNWIND_ENABLE_WERROR=NO
287    check-runtimes
288;;
289#
290# Sanitizers
291#
292generic-asan)
293    clean
294    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-asan.cmake"
295    check-runtimes
296;;
297generic-msan)
298    clean
299    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-msan.cmake"
300    check-runtimes
301;;
302generic-tsan)
303    clean
304    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-tsan.cmake"
305    check-runtimes
306;;
307generic-ubsan)
308    clean
309    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-ubsan.cmake"
310    check-runtimes
311;;
312#
313# Various build configurations
314#
315bootstrapping-build)
316    clean
317
318    echo "--- Generating CMake"
319    ${CMAKE} \
320          -S "${MONOREPO_ROOT}/llvm" \
321          -B "${BUILD_DIR}" \
322          -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
323          -DCMAKE_BUILD_TYPE=RelWithDebInfo \
324          -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
325          -DLLVM_ENABLE_PROJECTS="clang" \
326          -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
327          -DLLVM_RUNTIME_TARGETS="$(c++ --print-target-triple)" \
328          -DLLVM_TARGETS_TO_BUILD="host" \
329          -DRUNTIMES_BUILD_ALLOW_DARWIN=ON \
330          -DLLVM_ENABLE_ASSERTIONS=ON
331
332    echo "+++ Running the libc++ and libc++abi tests"
333    ${NINJA} -C "${BUILD_DIR}" check-runtimes
334
335    echo "--- Installing libc++ and libc++abi to a fake location"
336    ${NINJA} -C "${BUILD_DIR}" install-runtimes
337;;
338generic-static)
339    clean
340    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-static.cmake"
341    check-runtimes
342;;
343generic-merged)
344    clean
345    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-merged.cmake" \
346                   -DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in" \
347                   -DLIBCXXABI_TEST_CONFIG="llvm-libc++abi-merged.cfg.in" \
348                   -DLIBUNWIND_TEST_CONFIG="llvm-libunwind-merged.cfg.in"
349    check-runtimes
350;;
351generic-assertions)
352    clean
353    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-assertions.cmake"
354    check-runtimes
355    check-abi-list
356;;
357generic-debug-mode)
358    clean
359    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-debug-mode.cmake"
360    check-runtimes
361    # We don't check the ABI lists because the debug mode ABI is not stable
362;;
363generic-with_llvm_unwinder)
364    clean
365    generate-cmake -DLIBCXXABI_USE_LLVM_UNWINDER=ON
366    check-runtimes
367;;
368generic-modules)
369    clean
370    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-modules.cmake"
371    check-runtimes
372    check-abi-list
373;;
374#
375# Parts removed
376#
377generic-no-threads)
378    clean
379    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-threads.cmake"
380    check-runtimes
381;;
382generic-no-filesystem)
383    clean
384    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-filesystem.cmake"
385    check-runtimes
386;;
387generic-no-random_device)
388    clean
389    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-random_device.cmake"
390    check-runtimes
391;;
392generic-no-fstream)
393    clean
394    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-fstream.cmake"
395    check-runtimes
396;;
397generic-no-localization)
398    clean
399    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-localization.cmake"
400    check-runtimes
401;;
402generic-no-unicode)
403    clean
404    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-unicode.cmake"
405    check-runtimes
406;;
407generic-no-wide-characters)
408    clean
409    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-wide-characters.cmake"
410    check-runtimes
411;;
412generic-no-experimental)
413    clean
414    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-experimental.cmake"
415    check-runtimes
416    check-abi-list
417;;
418generic-noexceptions)
419    clean
420    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-noexceptions.cmake" \
421                   -DLIBCXX_ENABLE_CLANG_TIDY=ON
422    check-runtimes
423    check-abi-list
424;;
425#
426# Other miscellaneous jobs
427#
428generic-abi-unstable)
429    clean
430    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-abi-unstable.cmake"
431    check-runtimes
432;;
433apple-cxx20)
434    clean
435    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx20.cmake"
436    check-runtimes
437    check-abi-list
438;;
439apple-system)
440    clean
441
442    arch="$(uname -m)"
443    xcrun --sdk macosx                                              \
444        ${MONOREPO_ROOT}/libcxx/utils/ci/apple-install-libcxx.sh    \
445            --llvm-root ${MONOREPO_ROOT}                            \
446            --build-dir ${BUILD_DIR}                                \
447            --install-dir ${INSTALL_DIR}                            \
448            --symbols-dir "${BUILD_DIR}/symbols"                    \
449            --architectures "${arch}"                               \
450            --version "999.99"
451
452    # TODO: It would be better to run the tests against the fake-installed version of libc++ instead
453    xcrun --sdk macosx ninja -vC "${BUILD_DIR}/${arch}" check-cxx check-cxxabi check-cxx-abilist
454;;
455apple-system-backdeployment-assertions-*)
456    clean
457
458    if [[ "${OSX_ROOTS}" == "" ]]; then
459        echo "--- Downloading previous macOS dylibs"
460        PREVIOUS_DYLIBS_URL="https://dl.dropboxusercontent.com/s/gmcfxwgl9f9n6pu/libcxx-roots.tar.gz"
461        OSX_ROOTS="${BUILD_DIR}/macos-roots"
462        mkdir -p "${OSX_ROOTS}"
463        curl "${PREVIOUS_DYLIBS_URL}" | tar -xz --strip-components=1 -C "${OSX_ROOTS}"
464    fi
465
466    DEPLOYMENT_TARGET="${BUILDER#apple-system-backdeployment-assertions-}"
467
468    # TODO: On Apple platforms, we never produce libc++abi.1.dylib or libunwind.1.dylib,
469    #       only libc++abi.dylib and libunwind.dylib. Fix that in the build so that the
470    #       tests stop searching for @rpath/libc++abi.1.dylib and @rpath/libunwind.1.dylib.
471    cp "${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}/libc++abi.dylib" \
472       "${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}/libc++abi.1.dylib"
473    cp "${OSX_ROOTS}/macOS/libunwind/${DEPLOYMENT_TARGET}/libunwind.dylib" \
474       "${OSX_ROOTS}/macOS/libunwind/${DEPLOYMENT_TARGET}/libunwind.1.dylib"
475
476    arch="$(uname -m)"
477    PARAMS="target_triple=${arch}-apple-macosx${DEPLOYMENT_TARGET}"
478    PARAMS+=";cxx_runtime_root=${OSX_ROOTS}/macOS/libc++/${DEPLOYMENT_TARGET}"
479    PARAMS+=";abi_runtime_root=${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}"
480    PARAMS+=";unwind_runtime_root=${OSX_ROOTS}/macOS/libunwind/${DEPLOYMENT_TARGET}"
481    PARAMS+=";use_system_cxx_lib=True"
482    PARAMS+=";enable_assertions=True"
483    # TODO: Enable experimental features during back-deployment -- right now some of the availability
484    #       annotations are incorrect, leading to test failures that could be avoided.
485    PARAMS+=";enable_experimental=False"
486
487    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \
488                   -DLIBCXX_TEST_CONFIG="apple-libc++-backdeployment.cfg.in" \
489                   -DLIBCXXABI_TEST_CONFIG="apple-libc++abi-backdeployment.cfg.in" \
490                   -DLIBUNWIND_TEST_CONFIG="apple-libunwind-backdeployment.cfg.in" \
491                   -DLIBCXX_TEST_PARAMS="${PARAMS}" \
492                   -DLIBCXXABI_TEST_PARAMS="${PARAMS}" \
493                   -DLIBUNWIND_TEST_PARAMS="${PARAMS}"
494
495    check-runtimes
496;;
497apple-system-backdeployment-*)
498    clean
499
500    if [[ "${OSX_ROOTS}" == "" ]]; then
501        echo "--- Downloading previous macOS dylibs"
502        PREVIOUS_DYLIBS_URL="https://dl.dropboxusercontent.com/s/gmcfxwgl9f9n6pu/libcxx-roots.tar.gz"
503        OSX_ROOTS="${BUILD_DIR}/macos-roots"
504        mkdir -p "${OSX_ROOTS}"
505        curl "${PREVIOUS_DYLIBS_URL}" | tar -xz --strip-components=1 -C "${OSX_ROOTS}"
506    fi
507
508    DEPLOYMENT_TARGET="${BUILDER#apple-system-backdeployment-}"
509
510    # TODO: On Apple platforms, we never produce libc++abi.1.dylib or libunwind.1.dylib,
511    #       only libc++abi.dylib and libunwind.dylib. Fix that in the build so that the
512    #       tests stop searching for @rpath/libc++abi.1.dylib and @rpath/libunwind.1.dylib.
513    cp "${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}/libc++abi.dylib" \
514       "${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}/libc++abi.1.dylib"
515    cp "${OSX_ROOTS}/macOS/libunwind/${DEPLOYMENT_TARGET}/libunwind.dylib" \
516       "${OSX_ROOTS}/macOS/libunwind/${DEPLOYMENT_TARGET}/libunwind.1.dylib"
517
518    arch="$(uname -m)"
519    PARAMS="target_triple=${arch}-apple-macosx${DEPLOYMENT_TARGET}"
520    PARAMS+=";cxx_runtime_root=${OSX_ROOTS}/macOS/libc++/${DEPLOYMENT_TARGET}"
521    PARAMS+=";abi_runtime_root=${OSX_ROOTS}/macOS/libc++abi/${DEPLOYMENT_TARGET}"
522    PARAMS+=";unwind_runtime_root=${OSX_ROOTS}/macOS/libunwind/${DEPLOYMENT_TARGET}"
523    PARAMS+=";use_system_cxx_lib=True"
524    # TODO: Enable experimental features during back-deployment -- right now some of the availability
525    #       annotations are incorrect, leading to test failures that could be avoided.
526    PARAMS+=";enable_experimental=False"
527
528    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \
529                   -DLIBCXX_TEST_CONFIG="apple-libc++-backdeployment.cfg.in" \
530                   -DLIBCXXABI_TEST_CONFIG="apple-libc++abi-backdeployment.cfg.in" \
531                   -DLIBUNWIND_TEST_CONFIG="apple-libunwind-backdeployment.cfg.in" \
532                   -DLIBCXX_TEST_PARAMS="${PARAMS}" \
533                   -DLIBCXXABI_TEST_PARAMS="${PARAMS}" \
534                   -DLIBUNWIND_TEST_PARAMS="${PARAMS}"
535
536    check-runtimes
537;;
538benchmarks)
539    clean
540    generate-cmake
541    check-cxx-benchmarks
542;;
543documentation)
544    clean
545    generate-cmake -DLLVM_ENABLE_SPHINX=ON
546
547    echo "+++ Generating documentation"
548    ${NINJA} -vC "${BUILD_DIR}" docs-libcxx-html
549;;
550aarch64)
551    clean
552    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake"
553    check-runtimes
554;;
555aarch64-noexceptions)
556    clean
557    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake" \
558                   -DLIBCXX_ENABLE_EXCEPTIONS=OFF \
559                   -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF
560    check-runtimes
561;;
562# Aka Armv8 32 bit
563armv8)
564    clean
565    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Arm.cmake"
566    check-runtimes
567;;
568armv8-noexceptions)
569    clean
570    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Thumb-noexceptions.cmake"
571    check-runtimes
572;;
573# Armv7 32 bit. One building Arm only one Thumb only code.
574armv7)
575    clean
576    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Arm.cmake"
577    check-runtimes
578;;
579armv7-noexceptions)
580    clean
581    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Thumb-noexceptions.cmake"
582    check-runtimes
583;;
584clang-cl-dll)
585    clean
586    # TODO: Currently, building with the experimental library breaks running
587    # tests (the test linking look for the c++experimental library with the
588    # wrong name, and the statically linked c++experimental can't be linked
589    # correctly when libc++ visibility attributes indicate dllimport linkage
590    # anyway), thus just disable the experimental library. Remove this
591    # setting when cmake and the test driver does the right thing automatically.
592    generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False"
593    echo "+++ Running the libc++ tests"
594    ${NINJA} -vC "${BUILD_DIR}" check-cxx
595;;
596clang-cl-static)
597    clean
598    generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF
599    echo "+++ Running the libc++ tests"
600    ${NINJA} -vC "${BUILD_DIR}" check-cxx
601;;
602clang-cl-no-vcruntime)
603    clean
604    # Building libc++ in the same way as in clang-cl-dll above, but running
605    # tests with -D_HAS_EXCEPTIONS=0, which users might set in certain
606    # translation units while using libc++, even if libc++ is built with
607    # exceptions enabled.
608    generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" \
609                              -DLIBCXX_TEST_CONFIG="llvm-libc++-shared-no-vcruntime-clangcl.cfg.in"
610    echo "+++ Running the libc++ tests"
611    ${NINJA} -vC "${BUILD_DIR}" check-cxx
612;;
613mingw-dll)
614    clean
615    # Explicitly specify the compiler with a triple prefix. The CI
616    # environment has got two installations of Clang; the default one
617    # defaults to MSVC mode, while there's an installation of llvm-mingw
618    # further back in PATH. By calling the compiler with an explicit
619    # triple prefix, we use the one that is bundled with a mingw sysroot.
620    generate-cmake \
621          -DCMAKE_C_COMPILER=x86_64-w64-mingw32-clang \
622          -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-clang++ \
623          -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"
624    echo "+++ Running the libc++ tests"
625    ${NINJA} -vC "${BUILD_DIR}" check-cxx
626;;
627mingw-static)
628    clean
629    generate-cmake \
630          -DCMAKE_C_COMPILER=x86_64-w64-mingw32-clang \
631          -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-clang++ \
632          -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake" \
633          -DLIBCXX_ENABLE_SHARED=OFF \
634          -DLIBUNWIND_ENABLE_SHARED=OFF
635    echo "+++ Running the libc++ tests"
636    ${NINJA} -vC "${BUILD_DIR}" check-cxx
637;;
638mingw-dll-i686)
639    clean
640    generate-cmake \
641          -DCMAKE_C_COMPILER=i686-w64-mingw32-clang \
642          -DCMAKE_CXX_COMPILER=i686-w64-mingw32-clang++ \
643          -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"
644    echo "+++ Running the libc++ tests"
645    ${NINJA} -vC "${BUILD_DIR}" check-cxx
646;;
647aix)
648    clean
649    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AIX.cmake" \
650                   -DLIBCXX_TEST_CONFIG="ibm-libc++-shared.cfg.in" \
651                   -DLIBCXXABI_TEST_CONFIG="ibm-libc++abi-shared.cfg.in" \
652                   -DLIBUNWIND_TEST_CONFIG="ibm-libunwind-shared.cfg.in"
653    check-abi-list
654    check-runtimes
655;;
656#################################################################
657# Insert vendor-specific internal configurations below.
658#
659# This allows vendors to extend this file with their own internal
660# configurations without running into merge conflicts with upstream.
661#################################################################
662
663#################################################################
664*)
665    echo "${BUILDER} is not a known configuration"
666    exit 1
667;;
668esac
669