Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -ue |
| 4 | |
| 5 | function usage() { |
| 6 | cat <<EOM |
Louis Dionne | 2fff24e | 2020-05-21 14:33:32 -0400 | [diff] [blame] | 7 | $(basename ${0}) [-h|--help] --monorepo-root <MONOREPO-ROOT> --std <STD> --deployment-target <TARGET> [--libcxx-roots <DIR>] [--lit-args <ARGS...>] [--no-cleanup] |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 8 | |
| 9 | This script is used to continually test the back-deployment use case of libc++ and libc++abi on MacOS. |
| 10 | |
Louis Dionne | 2fff24e | 2020-05-21 14:33:32 -0400 | [diff] [blame] | 11 | Specifically, this script runs the libc++ test suite against the just-built headers and linking against the just-built dylib, but it runs the tests against the dylibs for the given deployment target. |
| 12 | |
Louis Dionne | 293573d | 2019-08-06 20:01:28 +0000 | [diff] [blame] | 13 | --monorepo-root Full path to the root of the LLVM monorepo. Both libc++ and libc++abi headers from the monorepo are used. |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 14 | --std Version of the C++ Standard to run the tests under (c++03, c++11, etc..). |
Louis Dionne | 9b55784 | 2019-02-27 23:36:22 +0000 | [diff] [blame] | 15 | --deployment-target The deployment target to run the tests for. This should be a version number of MacOS (e.g. 10.12). All MacOS versions until and including 10.9 are supported. |
Louis Dionne | 3e2f88d | 2020-04-14 15:07:38 -0400 | [diff] [blame] | 16 | [--libcxx-roots] The path to previous libc++/libc++abi dylibs to use for back-deployment testing. Those are normally downloaded automatically, but if specified, this option will override the directory used. The directory should have the same layout as the roots downloaded automatically. |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 17 | [--lit-args] Additional arguments to pass to lit (optional). If there are multiple arguments, quote them to pass them as a single argument to this script. |
| 18 | [--no-cleanup] Do not cleanup the temporary directory that was used for testing at the end. This can be useful to debug failures. Make sure to clean up manually after. |
| 19 | [-h, --help] Print this help. |
| 20 | EOM |
| 21 | } |
| 22 | |
| 23 | while [[ $# -gt 0 ]]; do |
| 24 | case "$1" in |
Louis Dionne | 293573d | 2019-08-06 20:01:28 +0000 | [diff] [blame] | 25 | --monorepo-root) |
| 26 | MONOREPO_ROOT="${2}" |
| 27 | if [[ ! -d "${MONOREPO_ROOT}" ]]; then |
| 28 | echo "--monorepo-root '${MONOREPO_ROOT}' is not a valid directory" |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 29 | usage |
| 30 | exit 1 |
| 31 | fi |
| 32 | shift; shift |
| 33 | ;; |
| 34 | --std) |
| 35 | STD="${2}" |
| 36 | shift; shift |
| 37 | ;; |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 38 | --deployment-target) |
| 39 | DEPLOYMENT_TARGET="${2}" |
| 40 | shift; shift |
| 41 | ;; |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 42 | --lit-args) |
| 43 | ADDITIONAL_LIT_ARGS="${2}" |
| 44 | shift; shift |
| 45 | ;; |
Louis Dionne | 3e2f88d | 2020-04-14 15:07:38 -0400 | [diff] [blame] | 46 | --libcxx-roots) |
| 47 | PREVIOUS_DYLIBS_DIR="${2}" |
| 48 | shift; shift |
| 49 | ;; |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 50 | --no-cleanup) |
| 51 | NO_CLEANUP="" |
| 52 | shift |
| 53 | ;; |
| 54 | -h|--help) |
| 55 | usage |
| 56 | exit 0 |
| 57 | ;; |
| 58 | *) |
| 59 | echo "${1} is not a supported argument" |
| 60 | usage |
| 61 | exit 1 |
| 62 | ;; |
| 63 | esac |
| 64 | done |
| 65 | |
Louis Dionne | 293573d | 2019-08-06 20:01:28 +0000 | [diff] [blame] | 66 | if [[ -z ${MONOREPO_ROOT+x} ]]; then echo "--monorepo-root is a required parameter"; usage; exit 1; fi |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 67 | if [[ -z ${STD+x} ]]; then echo "--std is a required parameter"; usage; exit 1; fi |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 68 | if [[ -z ${DEPLOYMENT_TARGET+x} ]]; then echo "--deployment-target is a required parameter"; usage; exit 1; fi |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 69 | if [[ -z ${ADDITIONAL_LIT_ARGS+x} ]]; then ADDITIONAL_LIT_ARGS=""; fi |
Louis Dionne | 3e2f88d | 2020-04-14 15:07:38 -0400 | [diff] [blame] | 70 | if [[ -z ${PREVIOUS_DYLIBS_DIR+x} ]]; then PREVIOUS_DYLIBS_DIR=""; fi |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 71 | |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 72 | TEMP_DIR="$(mktemp -d)" |
| 73 | echo "Created temporary directory ${TEMP_DIR}" |
| 74 | function cleanup { |
| 75 | if [[ -z ${NO_CLEANUP+x} ]]; then |
| 76 | echo "Removing temporary directory ${TEMP_DIR}" |
| 77 | rm -rf "${TEMP_DIR}" |
| 78 | else |
| 79 | echo "Temporary directory is at '${TEMP_DIR}', make sure to clean it up yourself" |
| 80 | fi |
| 81 | } |
| 82 | trap cleanup EXIT |
| 83 | |
| 84 | |
Louis Dionne | 293573d | 2019-08-06 20:01:28 +0000 | [diff] [blame] | 85 | LLVM_BUILD_DIR="${TEMP_DIR}/llvm-build" |
| 86 | LLVM_INSTALL_DIR="${TEMP_DIR}/llvm-install" |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 87 | |
| 88 | PREVIOUS_DYLIBS_URL="http://lab.llvm.org:8080/roots/libcxx-roots.tar.gz" |
| 89 | LLVM_TARBALL_URL="https://github.com/llvm-mirror/llvm/archive/master.tar.gz" |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 90 | |
| 91 | |
Louis Dionne | 293573d | 2019-08-06 20:01:28 +0000 | [diff] [blame] | 92 | echo "@@@ Configuring CMake @@@" |
| 93 | mkdir -p "${LLVM_BUILD_DIR}" |
| 94 | (cd "${LLVM_BUILD_DIR}" && |
Louis Dionne | 747d311 | 2019-09-11 16:57:19 +0000 | [diff] [blame] | 95 | xcrun cmake \ |
| 96 | -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Apple.cmake" \ |
| 97 | -GNinja \ |
Louis Dionne | 293573d | 2019-08-06 20:01:28 +0000 | [diff] [blame] | 98 | -DCMAKE_INSTALL_PREFIX="${LLVM_INSTALL_DIR}" \ |
| 99 | -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \ |
Louis Dionne | 74953e1 | 2020-04-30 12:55:01 -0400 | [diff] [blame] | 100 | -DCMAKE_OSX_ARCHITECTURES="x86_64" \ |
Louis Dionne | 747d311 | 2019-09-11 16:57:19 +0000 | [diff] [blame] | 101 | "${MONOREPO_ROOT}/llvm" |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 102 | ) |
| 103 | echo "@@@@@@" |
| 104 | |
| 105 | |
Louis Dionne | 2fff24e | 2020-05-21 14:33:32 -0400 | [diff] [blame] | 106 | echo "@@@ Building and installing libc++ and libc++abi @@@" |
| 107 | ninja -C "${LLVM_BUILD_DIR}" install-cxx install-cxxabi |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 108 | echo "@@@@@@" |
| 109 | |
| 110 | |
Louis Dionne | 3e2f88d | 2020-04-14 15:07:38 -0400 | [diff] [blame] | 111 | if [[ ${PREVIOUS_DYLIBS_DIR} == "" ]]; then |
| 112 | echo "@@@ Downloading dylibs for older deployment targets @@@" |
| 113 | PREVIOUS_DYLIBS_DIR="${TEMP_DIR}/libcxx-dylibs" |
| 114 | mkdir "${PREVIOUS_DYLIBS_DIR}" |
| 115 | curl "${PREVIOUS_DYLIBS_URL}" | tar -xz --strip-components=1 -C "${PREVIOUS_DYLIBS_DIR}" |
| 116 | echo "@@@@@@" |
| 117 | fi |
| 118 | |
Louis Dionne | 83c20b3 | 2020-05-15 12:13:48 -0400 | [diff] [blame] | 119 | LIBCXX_ROOT_ON_DEPLOYMENT_TARGET="${PREVIOUS_DYLIBS_DIR}/macOS/libc++/${DEPLOYMENT_TARGET}" |
| 120 | LIBCXXABI_ROOT_ON_DEPLOYMENT_TARGET="${PREVIOUS_DYLIBS_DIR}/macOS/libc++abi/${DEPLOYMENT_TARGET}" |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 121 | |
| 122 | # TODO: We need to also run the tests for libc++abi. |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 123 | echo "@@@ Running tests for libc++ @@@" |
Louis Dionne | 293573d | 2019-08-06 20:01:28 +0000 | [diff] [blame] | 124 | "${LLVM_BUILD_DIR}/bin/llvm-lit" -sv "${MONOREPO_ROOT}/libcxx/test" \ |
| 125 | --param=enable_experimental=false \ |
Louis Dionne | 293573d | 2019-08-06 20:01:28 +0000 | [diff] [blame] | 126 | --param=cxx_headers="${LLVM_INSTALL_DIR}/include/c++/v1" \ |
| 127 | --param=std="${STD}" \ |
| 128 | --param=platform="macosx${DEPLOYMENT_TARGET}" \ |
Louis Dionne | 2fff24e | 2020-05-21 14:33:32 -0400 | [diff] [blame] | 129 | --param=cxx_library_root="${LLVM_INSTALL_DIR}/lib" \ |
Louis Dionne | 83c20b3 | 2020-05-15 12:13:48 -0400 | [diff] [blame] | 130 | --param=cxx_runtime_root="${LIBCXX_ROOT_ON_DEPLOYMENT_TARGET}" \ |
| 131 | --param=abi_library_path="${LIBCXXABI_ROOT_ON_DEPLOYMENT_TARGET}" \ |
Louis Dionne | 4cc5e0d | 2020-05-15 11:33:59 -0400 | [diff] [blame] | 132 | --param=use_system_cxx_lib="True" \ |
Louis Dionne | 293573d | 2019-08-06 20:01:28 +0000 | [diff] [blame] | 133 | ${ADDITIONAL_LIT_ARGS} |
Louis Dionne | cbc6667 | 2019-01-09 19:40:20 +0000 | [diff] [blame] | 134 | echo "@@@@@@" |