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