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