Debian Codegraph @

libcxx/utils/ci/run-buildbot

raw
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
10 set -e
11 set -o pipefail
12 unset LANG
13 unset LC_ALL
14 unset LC_COLLATE
15
16 PROGNAME="$(basename "${0}")"
17
18 function usage() {
19 cat <<EOF
20 Usage:
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 Environment variables
32 CC The C compiler to use, this value is used by CMake. This
33 variable is optional.
34
35 CXX The C++ compiler to use, this value is used by CMake. This
36 variable is optional.
37
38 CMAKE The CMake binary to use. This variable is optional.
39
40 CLANG_FORMAT The clang-format binary to use when generating the format
41 ignore list.
42
43 EOF
44 }
45
46 if [[ $# == 0 ]]; then
47 usage
48 exit 0
49 fi
50
51 while [[ $# -gt 0 ]]; do
52 case ${1} in
53 -h|--help)
54 usage
55 exit 0
56 ;;
57 --llvm-root)
58 MONOREPO_ROOT="${2}"
59 shift; shift
60 ;;
61 --build-dir)
62 BUILD_DIR="${2}"
63 shift; shift
64 ;;
65 *)
66 BUILDER="${1}"
67 shift
68 ;;
69 esac
70 done
71
72 MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
73 BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build/${BUILDER}}"
74 INSTALL_DIR="${BUILD_DIR}/install"
75
76 # If we can find Ninja/CMake provided by Xcode, use those since we know their
77 # version will generally work with the Clang shipped in Xcode (e.g. if Clang
78 # knows about -std=c++20, the CMake bundled in Xcode will probably know about
79 # that flag too).
80 if xcrun --find ninja &>/dev/null; then
81 NINJA="$(xcrun --find ninja)"
82 elif which ninja &>/dev/null; then
83 # The current implementation of modules needs the absolute path to the ninja
84 # binary.
85 # TODO MODULES Is this still needed when CMake has libc++ module support?
86 NINJA="$(which ninja)"
87 else
88 NINJA="ninja"
89 fi
90
91 if [ -z "${CMAKE}" ]; then
92 if xcrun --find cmake &>/dev/null; then
93 CMAKE="$(xcrun --find cmake)"
94 else
95 CMAKE="cmake"
96 fi
97 fi
98
99 function step() {
100 endstep
101 set +x
102 if [[ ! -z ${GITHUB_ACTIONS+x} ]]; then
103 echo "::group::$1"
104 export IN_GROUP=1
105 else
106 echo "--- $1"
107 fi
108 set -x
109 }
110
111 function endstep() {
112 set +x
113 if [[ ! -z ${GITHUB_ACTIONS+x} ]] && [[ ! -z ${IN_GROUP+x} ]]; then
114 echo "::endgroup::"
115 unset IN_GROUP
116 fi
117 set -x
118 }
119
120 function error() {
121 echo "::error::$1"
122 }
123
124 function clean() {
125 rm -rf "${BUILD_DIR}"
126 }
127
128 function generate-cmake-base() {
129 step "Generating CMake"
130
131 # We can remove -DCMAKE_INSTALL_MESSAGE=NEVER once https://gitlab.kitware.com/cmake/cmake/-/issues/26085 is fixed.
132 ${CMAKE} \
133 -S "${MONOREPO_ROOT}/runtimes" \
134 -B "${BUILD_DIR}" \
135 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
136 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
137 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
138 -DLIBCXX_ENABLE_WERROR=YES \
139 -DLIBCXXABI_ENABLE_WERROR=YES \
140 -DLIBUNWIND_ENABLE_WERROR=YES \
141 -DCMAKE_INSTALL_MESSAGE=NEVER \
142 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
143 "${@}"
144 }
145
146 function generate-cmake() {
147 generate-cmake-base \
148 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
149 -DLIBCXX_CXX_ABI=libcxxabi \
150 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
151 "${@}"
152 }
153
154 function generate-cmake-libcxx-win() {
155 generate-cmake-base \
156 -DLLVM_ENABLE_RUNTIMES="libcxx" \
157 -DCMAKE_C_COMPILER=clang-cl \
158 -DCMAKE_CXX_COMPILER=clang-cl \
159 "${@}"
160 }
161
162 function generate-cmake-android() {
163 generate-cmake-base \
164 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
165 -DLIBCXX_CXX_ABI=libcxxabi \
166 "${@}"
167 }
168
169 function check-runtimes() {
170 step "Building libc++ test dependencies"
171 ${NINJA} -vC "${BUILD_DIR}" cxx-test-depends
172
173 step "Running the libc++ tests"
174 ${NINJA} -vC "${BUILD_DIR}" check-cxx
175
176 step "Running the libc++abi tests"
177 ${NINJA} -vC "${BUILD_DIR}" check-cxxabi
178
179 step "Running the libunwind tests"
180 ${NINJA} -vC "${BUILD_DIR}" check-unwind
181 }
182
183 # TODO: The goal is to test this against all configurations. We should also move
184 # this to the Lit test suite instead of being a separate CMake target.
185 function check-abi-list() {
186 step "Running the libc++ ABI list test"
187 ${NINJA} -vC "${BUILD_DIR}" check-cxx-abilist || (
188 error "Generating the libc++ ABI list after failed check"
189 ${NINJA} -vC "${BUILD_DIR}" generate-cxx-abilist
190 false
191 )
192 }
193
194 function test-armv7m-picolibc() {
195 clean
196
197 # To make it easier to get this builder up and running, build picolibc
198 # from scratch. Anecdotally, the build-picolibc script takes about 16 seconds.
199 # This could be optimised by building picolibc into the Docker container.
200 step "Building picolibc from source"
201 ${MONOREPO_ROOT}/libcxx/utils/ci/build-picolibc.sh \
202 --build-dir "${BUILD_DIR}" \
203 --install-dir "${INSTALL_DIR}" \
204 --target armv7m-none-eabi
205
206 step "Generating CMake for compiler-rt"
207 flags="--sysroot=${INSTALL_DIR}"
208 # LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON means that we produce a file
209 # libclang_rt.builtins.a that will be installed to
210 # ${INSTALL_DIR}/lib/armv7m-unknown-none-eabi/.
211 # With LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF, the filename includes the
212 # architecture name, which is not what Clang's driver expects to find.
213 # The install location will however be wrong with
214 # LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON, so we correct that below.
215 ${CMAKE} \
216 -S "${MONOREPO_ROOT}/compiler-rt" \
217 -B "${BUILD_DIR}/compiler-rt" \
218 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
219 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
220 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
221 -DCMAKE_C_FLAGS="${flags}" \
222 -DCMAKE_CXX_FLAGS="${flags}" \
223 -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \
224 "${@}"
225
226 step "Generating CMake for libc++"
227 generate-cmake \
228 -DLIBCXX_TEST_CONFIG="armv7m-picolibc-libc++.cfg.in" \
229 -DLIBCXXABI_TEST_CONFIG="armv7m-picolibc-libc++abi.cfg.in" \
230 -DLIBUNWIND_TEST_CONFIG="armv7m-picolibc-libunwind.cfg.in" \
231 -DCMAKE_C_FLAGS="${flags}" \
232 -DCMAKE_CXX_FLAGS="${flags}" \
233 "${@}"
234
235 step "Installing compiler-rt"
236 ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
237 # Move compiler-rt libs into the same directory as all the picolib objects.
238 mv "${INSTALL_DIR}/lib/armv7m-unknown-none-eabi"/* "${INSTALL_DIR}/lib"
239
240 check-runtimes
241 }
242
243 # Print the version of a few tools to aid diagnostics in some cases
244 step "Diagnose tools in use"
245 ${CMAKE} --version
246 ${NINJA} --version
247 if [ ! -z "${CXX}" ]; then ${CXX} --version; fi
248
249 case "${BUILDER}" in
250 check-generated-output)
251 # `! foo` doesn't work properly with `set -e`, use `! foo || false` instead.
252 # https://stackoverflow.com/questions/57681955/set-e-does-not-respect-logical-not
253 clean
254 generate-cmake
255
256 # Reject patches that forgot to re-run the generator scripts.
257 step "Making sure the generator scripts were run"
258 set +x # Printing all the commands below just creates extremely confusing output
259 ${NINJA} -vC "${BUILD_DIR}" libcxx-generate-files
260 git diff | tee ${BUILD_DIR}/generated_output.patch
261 git ls-files -o --exclude-standard | tee ${BUILD_DIR}/generated_output.status
262 ! grep -q '^--- a' ${BUILD_DIR}/generated_output.patch || false
263 if [ -s ${BUILD_DIR}/generated_output.status ]; then
264 echo "It looks like not all the generator scripts were run,"
265 echo "did you forget to build the libcxx-generate-files target?"
266 echo "Did you add all new files it generated?"
267 false
268 fi
269
270 # This depends on LC_COLLATE set at the top of this script.
271 step "Reject patches that introduce non-ASCII characters or hard tabs."
272 ! grep -rn '[^ -~]' libcxx/include libcxx/src libcxx/test \
273 --exclude '*.dat' \
274 --exclude '*unicode*.cpp' \
275 --exclude '*print*.sh.cpp' \
276 --exclude 'escaped_output.*.pass.cpp' \
277 --exclude 'format_tests.h' \
278 --exclude 'format.functions.tests.h' \
279 --exclude 'formatter.*.pass.cpp' \
280 --exclude 'grep.pass.cpp' \
281 --exclude 'locale-specific_form.pass.cpp' \
282 --exclude 'ostream.pass.cpp' \
283 --exclude 'transcoding.pass.cpp' \
284 --exclude 'underflow.pass.cpp' \
285 || false
286 ;;
287 #
288 # Various Standard modes
289 #
290 frozen-cxx03-headers)
291 clean
292 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx03-frozen.cmake"
293 check-runtimes
294 check-abi-list
295 ;;
296 generic-cxx03)
297 clean
298 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx03.cmake"
299 check-runtimes
300 check-abi-list
301 ;;
302 generic-cxx11)
303 clean
304 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx11.cmake"
305 check-runtimes
306 check-abi-list
307 ;;
308 generic-cxx14)
309 clean
310 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx14.cmake"
311 check-runtimes
312 check-abi-list
313 ;;
314 generic-cxx17)
315 clean
316 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx17.cmake"
317 check-runtimes
318 check-abi-list
319 ;;
320 generic-cxx20)
321 clean
322 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx20.cmake"
323 check-runtimes
324 check-abi-list
325 ;;
326 generic-cxx23)
327 clean
328 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx23.cmake"
329 check-runtimes
330 check-abi-list
331 ;;
332 generic-cxx26)
333 clean
334 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx26.cmake"
335 check-runtimes
336 check-abi-list
337 ;;
338 #
339 # Other compiler support
340 #
341 generic-gcc)
342 clean
343 generate-cmake -DLIBCXX_ENABLE_WERROR=NO \
344 -DLIBCXXABI_ENABLE_WERROR=NO \
345 -DLIBUNWIND_ENABLE_WERROR=NO
346 check-runtimes
347 ;;
348 generic-gcc-cxx11)
349 clean
350 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-cxx11.cmake" \
351 -DLIBCXX_ENABLE_WERROR=NO \
352 -DLIBCXXABI_ENABLE_WERROR=NO \
353 -DLIBUNWIND_ENABLE_WERROR=NO
354 check-runtimes
355 ;;
356 #
357 # Sanitizers
358 #
359 generic-asan)
360 clean
361 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-asan.cmake"
362 check-runtimes
363 ;;
364 generic-msan)
365 clean
366 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-msan.cmake"
367 check-runtimes
368 ;;
369 generic-tsan)
370 clean
371 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-tsan.cmake"
372 check-runtimes
373 ;;
374 generic-ubsan)
375 clean
376 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-ubsan.cmake"
377 check-runtimes
378 ;;
379 #
380 # Various build configurations
381 #
382 bootstrapping-build)
383 clean
384
385 step "Generating CMake"
386 ${CMAKE} \
387 -S "${MONOREPO_ROOT}/llvm" \
388 -B "${BUILD_DIR}" \
389 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
390 -DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
391 -DCMAKE_BUILD_TYPE=Release \
392 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
393 -DLLVM_ENABLE_PROJECTS="clang;lldb" \
394 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
395 -DLLVM_RUNTIME_TARGETS="$(${CXX} --print-target-triple)" \
396 -DLLVM_HOST_TRIPLE="$(${CXX} --print-target-triple)" \
397 -DLLVM_TARGETS_TO_BUILD="host" \
398 -DRUNTIMES_BUILD_ALLOW_DARWIN=ON \
399 -DLLVM_ENABLE_ASSERTIONS=ON \
400 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests"
401
402 step "Running the libc++ and libc++abi tests"
403 ${NINJA} -vC "${BUILD_DIR}" check-runtimes
404
405 step "Installing libc++ and libc++abi to a fake location"
406 ${NINJA} -vC "${BUILD_DIR}" install-runtimes
407
408 step "Running the LLDB libc++ data formatter tests"
409 ${NINJA} -vC "${BUILD_DIR}" lldb-api-test-deps
410 ${BUILD_DIR}/bin/llvm-lit -sv --param dotest-args='--category libc++' "${MONOREPO_ROOT}/lldb/test/API"
411
412 ccache -s
413 ;;
414 generic-static)
415 clean
416 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-static.cmake"
417 check-runtimes
418 ;;
419 generic-merged)
420 clean
421 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-merged.cmake" \
422 -DLIBCXX_TEST_CONFIG="llvm-libc++-shared.cfg.in" \
423 -DLIBCXXABI_TEST_CONFIG="llvm-libc++abi-merged.cfg.in" \
424 -DLIBUNWIND_TEST_CONFIG="llvm-libunwind-merged.cfg.in"
425 check-runtimes
426 ;;
427 generic-hardening-mode-fast)
428 clean
429 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-fast.cmake"
430 check-runtimes
431 check-abi-list
432 ;;
433 generic-hardening-mode-fast-with-abi-breaks)
434 clean
435 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-fast-with-abi-breaks.cmake"
436 check-runtimes
437 # Not checking ABI list since we purposefully enable ABI breaking changes
438 ;;
439 generic-hardening-mode-extensive)
440 clean
441 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-extensive.cmake"
442 check-runtimes
443 check-abi-list
444 ;;
445 generic-hardening-mode-extensive-observe-semantic)
446 clean
447 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-extensive-observe-semantic.cmake"
448 check-runtimes
449 check-abi-list
450 ;;
451 generic-hardening-mode-debug)
452 clean
453 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-hardening-mode-debug.cmake"
454 check-runtimes
455 check-abi-list
456 ;;
457 #
458 # Module builds
459 #
460 generic-modules)
461 clean
462 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-modules.cmake"
463 check-runtimes
464 check-abi-list
465 ;;
466 generic-modules-cxx17-lsv)
467 clean
468 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-modules-cxx17-lsv.cmake"
469 check-runtimes
470 check-abi-list
471 ;;
472 #
473 # Parts removed
474 #
475 generic-no-threads)
476 clean
477 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-threads.cmake"
478 check-runtimes
479 ;;
480 generic-no-filesystem)
481 clean
482 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-filesystem.cmake"
483 check-runtimes
484 ;;
485 generic-no-random_device)
486 clean
487 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-random_device.cmake"
488 check-runtimes
489 ;;
490 generic-no-localization)
491 clean
492 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-localization.cmake"
493 check-runtimes
494 ;;
495 generic-no-terminal)
496 clean
497 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-terminal.cmake"
498 check-runtimes
499 ;;
500 generic-no-unicode)
501 clean
502 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-unicode.cmake"
503 check-runtimes
504 ;;
505 generic-no-wide-characters)
506 clean
507 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-wide-characters.cmake"
508 check-runtimes
509 ;;
510 generic-no-tzdb)
511 clean
512 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-tzdb.cmake"
513 check-runtimes
514 ;;
515 generic-no-experimental)
516 clean
517 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-experimental.cmake"
518 check-runtimes
519 check-abi-list
520 ;;
521 generic-no-exceptions)
522 clean
523 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-exceptions.cmake"
524 check-runtimes
525 check-abi-list
526 ;;
527 generic-no-rtti)
528 clean
529 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-rtti.cmake"
530 check-runtimes
531 ;;
532 #
533 # Other miscellaneous jobs
534 #
535 generic-abi-unstable)
536 clean
537 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-abi-unstable.cmake"
538 check-runtimes
539 ;;
540 generic-optimized-speed)
541 clean
542 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-optimized-speed.cmake"
543 check-runtimes
544 ;;
545 apple-configuration)
546 clean
547
548 step "Installing libc++ with the Apple system configuration"
549 arch="$(uname -m)"
550 xcrun --sdk macosx \
551 ${MONOREPO_ROOT}/libcxx/utils/ci/apple-install-libcxx.sh \
552 --llvm-root ${MONOREPO_ROOT} \
553 --build-dir ${BUILD_DIR} \
554 --install-dir ${INSTALL_DIR} \
555 --symbols-dir "${BUILD_DIR}/symbols" \
556 --architectures "${arch}" \
557 --version "999.99"
558
559 step "Running tests against Apple-configured libc++"
560 # TODO: It would be better to run the tests against the fake-installed version of libc++ instead
561 xcrun --sdk macosx ninja -vC "${BUILD_DIR}/${arch}" check-cxx check-cxxabi check-cxx-abilist
562 ;;
563 apple-system|apple-system-hardened)
564 clean
565
566 arch="$(uname -m)"
567 version="$(sw_vers --productVersion)"
568 params="target_triple=${arch}-apple-macosx${version}"
569 if [[ "${BUILDER}" == *-hardened ]]; then
570 params+=";hardening_mode=fast"
571 fi
572
573 # In the Apple system configuration, we build libc++ and libunwind separately.
574 step "Installing libc++ and libc++abi in Apple-system configuration"
575 ${CMAKE} \
576 -S "${MONOREPO_ROOT}/runtimes" \
577 -B "${BUILD_DIR}/cxx" \
578 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
579 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
580 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}/cxx" \
581 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
582 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
583 -DLIBCXX_CXX_ABI=libcxxabi \
584 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \
585 -DLIBCXX_TEST_CONFIG="apple-libc++-system.cfg.in" \
586 -DLIBCXXABI_TEST_CONFIG="apple-libc++abi-system.cfg.in" \
587 -DLIBCXX_TEST_PARAMS="${params}" \
588 -DLIBCXXABI_TEST_PARAMS="${params}"
589
590 step "Installing libunwind in Apple-system configuration"
591 ${CMAKE} \
592 -S "${MONOREPO_ROOT}/runtimes" \
593 -B "${BUILD_DIR}/unwind" \
594 -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
595 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
596 -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}/unwind" \
597 -DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests" \
598 -DLLVM_ENABLE_RUNTIMES="libunwind" \
599 -DLIBUNWIND_TEST_CONFIG="apple-libunwind-system.cfg.in" \
600 -DLIBUNWIND_TEST_PARAMS="${params}" \
601 -DCMAKE_INSTALL_NAME_DIR="/usr/lib/system"
602
603 step "Running the libc++ tests"
604 ${NINJA} -vC "${BUILD_DIR}/cxx" check-cxx
605
606 step "Running the libc++abi tests"
607 ${NINJA} -vC "${BUILD_DIR}/cxx" check-cxxabi
608
609 step "Running the libunwind tests"
610 ${NINJA} -vC "${BUILD_DIR}/unwind" check-unwind
611 ;;
612 aarch64)
613 clean
614 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake"
615 check-runtimes
616 ;;
617 aarch64-no-exceptions)
618 clean
619 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake" \
620 -DLIBCXX_ENABLE_EXCEPTIONS=OFF \
621 -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF
622 check-runtimes
623 ;;
624 # Aka Armv8 32 bit
625 armv8)
626 clean
627 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Arm.cmake"
628 check-runtimes
629 ;;
630 armv8-no-exceptions)
631 clean
632 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv8Thumb-no-exceptions.cmake"
633 check-runtimes
634 ;;
635 # Armv7 32 bit. One building Arm only one Thumb only code.
636 armv7)
637 clean
638 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Arm.cmake"
639 check-runtimes
640 ;;
641 armv7-no-exceptions)
642 clean
643 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7Thumb-no-exceptions.cmake"
644 check-runtimes
645 ;;
646 armv7m-picolibc)
647 test-armv7m-picolibc \
648 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake"
649 ;;
650 armv7m-picolibc-no-exceptions)
651 test-armv7m-picolibc \
652 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Armv7M-picolibc.cmake" \
653 -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF \
654 -DLIBCXXABI_ENABLE_STATIC_UNWINDER=OFF \
655 -DLIBCXX_ENABLE_EXCEPTIONS=OFF \
656 -DLIBCXX_ENABLE_RTTI=OFF
657 ;;
658 clang-cl-dll)
659 clean
660 # TODO: Currently, building with the experimental library breaks running
661 # tests (the test linking look for the c++experimental library with the
662 # wrong name, and the statically linked c++experimental can't be linked
663 # correctly when libc++ visibility attributes indicate dllimport linkage
664 # anyway), thus just disable the experimental library. Remove this
665 # setting when cmake and the test driver does the right thing automatically.
666 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False"
667 step "Running the libc++ tests"
668 ${NINJA} -vC "${BUILD_DIR}" check-cxx
669 ;;
670 clang-cl-static)
671 clean
672 generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF
673 step "Running the libc++ tests"
674 ${NINJA} -vC "${BUILD_DIR}" check-cxx
675 ;;
676 clang-cl-no-vcruntime)
677 clean
678 # Building libc++ in the same way as in clang-cl-dll above, but running
679 # tests with -D_HAS_EXCEPTIONS=0, which users might set in certain
680 # translation units while using libc++, even if libc++ is built with
681 # exceptions enabled.
682 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" \
683 -DLIBCXX_TEST_CONFIG="llvm-libc++-shared-no-vcruntime-clangcl.cfg.in"
684 step "Running the libc++ tests"
685 ${NINJA} -vC "${BUILD_DIR}" check-cxx
686 ;;
687 clang-cl-debug)
688 clean
689 generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" \
690 -DCMAKE_BUILD_TYPE=Debug
691 step "Running the libc++ tests"
692 ${NINJA} -vC "${BUILD_DIR}" check-cxx
693 ;;
694 clang-cl-static-crt)
695 clean
696 # Test linking a static libc++ with the static CRT ("MultiThreaded" denotes
697 # the static CRT, as opposed to "MultiThreadedDLL" which is the default).
698 generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF \
699 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
700 step "Running the libc++ tests"
701 ${NINJA} -vC "${BUILD_DIR}" check-cxx
702 ;;
703 mingw-dll)
704 clean
705 generate-cmake \
706 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"
707 check-runtimes
708 ;;
709 mingw-static)
710 clean
711 generate-cmake \
712 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake" \
713 -DLIBCXX_ENABLE_SHARED=OFF \
714 -DLIBUNWIND_ENABLE_SHARED=OFF
715 check-runtimes
716 ;;
717 mingw-dll-i686)
718 clean
719 generate-cmake \
720 -DCMAKE_C_COMPILER=i686-w64-mingw32-clang \
721 -DCMAKE_CXX_COMPILER=i686-w64-mingw32-clang++ \
722 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"
723 check-runtimes
724 ;;
725 mingw-incomplete-sysroot)
726 # When bringing up a new cross compiler from scratch, we build
727 # libunwind/libcxx in a setup where the toolchain is incomplete and
728 # unable to perform the normal linker checks; this requires a few
729 # special cases in the CMake files.
730 #
731 # Building in an incomplete setup requires setting CMAKE_*_COMPILER_WORKS,
732 # as CMake fails to probe the compiler. This case also requires
733 # setting CMAKE_CXX_COMPILER_TARGET, as LLVM's heuristics for setting
734 # the triple fails when CMake hasn't been able to probe the environment.
735 # (This is what one has to do when building the initial libunwind/libcxx
736 # for a new toolchain.)
737 clean
738 generate-cmake \
739 -DCMAKE_C_COMPILER_WORKS=TRUE \
740 -DCMAKE_CXX_COMPILER_WORKS=TRUE \
741 -DCMAKE_C_COMPILER_TARGET=x86_64-w64-windows-gnu \
742 -DCMAKE_CXX_COMPILER_TARGET=x86_64-w64-windows-gnu \
743 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"
744 # Only test that building succeeds; there's not much extra value in running
745 # the tests here, as it would be equivalent to the mingw-dll config above.
746 step "Building the runtimes"
747 ${NINJA} -vC "${BUILD_DIR}"
748 ;;
749 aix)
750 clean
751 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AIX.cmake" \
752 -DLIBCXX_TEST_CONFIG="ibm-libc++-shared.cfg.in" \
753 -DLIBCXXABI_TEST_CONFIG="ibm-libc++abi-shared.cfg.in" \
754 -DLIBUNWIND_TEST_CONFIG="ibm-libunwind-shared.cfg.in"
755 check-abi-list
756 check-runtimes
757 ;;
758 android-ndk-*)
759 clean
760
761 ANDROID_EMU_IMG="${BUILDER#android-ndk-}"
762 . "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/emulator-functions.sh"
763 if ! validate_emu_img "${ANDROID_EMU_IMG}"; then
764 error "android-ndk suffix must be a valid emulator image (${ANDROID_EMU_IMG})" >&2
765 exit 1
766 fi
767 ARCH=$(arch_of_emu_img ${ANDROID_EMU_IMG})
768
769 # Use the Android compiler by default.
770 export CC=${CC:-/opt/android/clang/clang-current/bin/clang}
771 export CXX=${CXX:-/opt/android/clang/clang-current/bin/clang++}
772
773 # The NDK libc++_shared.so is always built against the oldest supported API
774 # level. When tests are run against a device with a newer API level, test
775 # programs can be built for any supported API level, but building for the
776 # newest API (i.e. the system image's API) is probably the most interesting.
777 PARAMS="executor=${MONOREPO_ROOT}/libcxx/utils/adb_run.py;target_triple=$(triple_of_arch ${ARCH})$(api_of_emu_img ${ANDROID_EMU_IMG})"
778 generate-cmake-android -C "${MONOREPO_ROOT}/runtimes/cmake/android/Arch-${ARCH}.cmake" \
779 -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AndroidNDK.cmake" \
780 -DCMAKE_SYSROOT=/opt/android/ndk/sysroot \
781 -DLIBCXX_TEST_PARAMS="${PARAMS}" \
782 -DLIBCXXABI_TEST_PARAMS="${PARAMS}"
783 check-abi-list
784 ${NINJA} -vC "${BUILD_DIR}" install-cxx install-cxxabi
785
786 # Start the emulator and make sure we can connect to the adb server running
787 # inside of it.
788 "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/start-emulator.sh" ${ANDROID_EMU_IMG}
789 trap "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/stop-emulator.sh" EXIT
790 . "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/setup-env-for-emulator.sh"
791
792 # Create adb_run early to avoid concurrent `mkdir -p` of common parent
793 # directories.
794 adb shell mkdir -p /data/local/tmp/adb_run
795 adb push "${BUILD_DIR}/lib/libc++_shared.so" /data/local/tmp/libc++/libc++_shared.so
796 step "Running the libc++ tests"
797 ${NINJA} -vC "${BUILD_DIR}" check-cxx
798 step "Running the libc++abi tests"
799 ${NINJA} -vC "${BUILD_DIR}" check-cxxabi
800 ;;
801 #################################################################
802 # Insert vendor-specific internal configurations below.
803 #
804 # This allows vendors to extend this file with their own internal
805 # configurations without running into merge conflicts with upstream.
806 #################################################################
807
808 #################################################################
809 *)
810 echo "${BUILDER} is not a known configuration"
811 exit 1
812 ;;
813 esac
814
815 endstep # Make sure we close any still-open output group