2019-01-10 03:40:20 +08:00
#!/usr/bin/env bash
set -ue
function usage( ) {
cat <<EOM
2020-05-22 02:33:32 +08:00
$( basename ${ 0 } ) [ -h| --help] --monorepo-root <MONOREPO-ROOT> --std <STD> --deployment-target <TARGET> [ --libcxx-roots <DIR>] [ --lit-args <ARGS...>] [ --no-cleanup]
2019-01-10 03:40:20 +08:00
This script is used to continually test the back-deployment use case of libc++ and libc++abi on MacOS.
2020-05-22 02:33:32 +08:00
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.
2019-08-07 04:01:28 +08:00
--monorepo-root Full path to the root of the LLVM monorepo. Both libc++ and libc++abi headers from the monorepo are used.
2019-01-10 03:40:20 +08:00
--std Version of the C++ Standard to run the tests under ( c++03, c++11, etc..) .
2019-02-28 07:36:22 +08:00
--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.
2020-04-15 03:07:38 +08:00
[ --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.
2019-01-10 03:40:20 +08:00
[ --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.
[ --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.
[ -h, --help] Print this help.
EOM
}
while [ [ $# -gt 0 ] ] ; do
case " $1 " in
2019-08-07 04:01:28 +08:00
--monorepo-root)
MONOREPO_ROOT = " ${ 2 } "
if [ [ ! -d " ${ MONOREPO_ROOT } " ] ] ; then
echo " --monorepo-root ' ${ MONOREPO_ROOT } ' is not a valid directory "
2019-01-10 03:40:20 +08:00
usage
exit 1
fi
shift; shift
; ;
--std)
STD = " ${ 2 } "
shift; shift
; ;
--deployment-target)
DEPLOYMENT_TARGET = " ${ 2 } "
shift; shift
; ;
--lit-args)
ADDITIONAL_LIT_ARGS = " ${ 2 } "
shift; shift
; ;
2020-04-15 03:07:38 +08:00
--libcxx-roots)
PREVIOUS_DYLIBS_DIR = " ${ 2 } "
shift; shift
; ;
2019-01-10 03:40:20 +08:00
--no-cleanup)
NO_CLEANUP = ""
shift
; ;
-h| --help)
usage
exit 0
; ;
*)
echo " ${ 1 } is not a supported argument "
usage
exit 1
; ;
esac
done
2019-08-07 04:01:28 +08:00
if [ [ -z ${ MONOREPO_ROOT +x } ] ] ; then echo "--monorepo-root is a required parameter" ; usage; exit 1; fi
2019-01-10 03:40:20 +08:00
if [ [ -z ${ STD +x } ] ] ; then echo "--std is a required parameter" ; usage; exit 1; fi
if [ [ -z ${ DEPLOYMENT_TARGET +x } ] ] ; then echo "--deployment-target is a required parameter" ; usage; exit 1; fi
if [ [ -z ${ ADDITIONAL_LIT_ARGS +x } ] ] ; then ADDITIONAL_LIT_ARGS = "" ; fi
2020-04-15 03:07:38 +08:00
if [ [ -z ${ PREVIOUS_DYLIBS_DIR +x } ] ] ; then PREVIOUS_DYLIBS_DIR = "" ; fi
2019-01-10 03:40:20 +08:00
TEMP_DIR = " $( mktemp -d) "
echo " Created temporary directory ${ TEMP_DIR } "
function cleanup {
if [ [ -z ${ NO_CLEANUP +x } ] ] ; then
echo " Removing temporary directory ${ TEMP_DIR } "
rm -rf " ${ TEMP_DIR } "
else
echo " Temporary directory is at ' ${ TEMP_DIR } ', make sure to clean it up yourself "
fi
}
trap cleanup EXIT
2019-08-07 04:01:28 +08:00
LLVM_BUILD_DIR = " ${ TEMP_DIR } /llvm-build "
LLVM_INSTALL_DIR = " ${ TEMP_DIR } /llvm-install "
2019-01-10 03:40:20 +08:00
PREVIOUS_DYLIBS_URL = "http://lab.llvm.org:8080/roots/libcxx-roots.tar.gz"
LLVM_TARBALL_URL = "https://github.com/llvm-mirror/llvm/archive/master.tar.gz"
2019-08-07 04:01:28 +08:00
echo "@@@ Configuring CMake @@@"
mkdir -p " ${ LLVM_BUILD_DIR } "
( cd " ${ LLVM_BUILD_DIR } " &&
2019-09-12 00:57:19 +08:00
xcrun cmake \
-C " ${ MONOREPO_ROOT } /libcxx/cmake/caches/Apple.cmake " \
-GNinja \
2020-08-13 23:10:13 +08:00
-DCMAKE_MAKE_PROGRAM= " $( xcrun --find ninja) " \
2019-08-07 04:01:28 +08:00
-DCMAKE_INSTALL_PREFIX= " ${ LLVM_INSTALL_DIR } " \
-DLLVM_ENABLE_PROJECTS= "libcxx;libcxxabi" \
2020-05-01 00:55:01 +08:00
-DCMAKE_OSX_ARCHITECTURES= "x86_64" \
2019-09-12 00:57:19 +08:00
" ${ MONOREPO_ROOT } /llvm "
2019-01-10 03:40:20 +08:00
)
echo "@@@@@@"
2020-05-22 02:33:32 +08:00
echo "@@@ Building and installing libc++ and libc++abi @@@"
2020-08-26 23:32:40 +08:00
xcrun ninja -C " ${ LLVM_BUILD_DIR } " install-cxx install-cxxabi
2019-01-10 03:40:20 +08:00
echo "@@@@@@"
2020-04-15 03:07:38 +08:00
if [ [ ${ PREVIOUS_DYLIBS_DIR } = = "" ] ] ; then
echo "@@@ Downloading dylibs for older deployment targets @@@"
PREVIOUS_DYLIBS_DIR = " ${ TEMP_DIR } /libcxx-dylibs "
mkdir " ${ PREVIOUS_DYLIBS_DIR } "
curl " ${ PREVIOUS_DYLIBS_URL } " | tar -xz --strip-components= 1 -C " ${ PREVIOUS_DYLIBS_DIR } "
echo "@@@@@@"
fi
2020-05-16 00:13:48 +08:00
LIBCXX_ROOT_ON_DEPLOYMENT_TARGET = " ${ PREVIOUS_DYLIBS_DIR } /macOS/libc++/ ${ DEPLOYMENT_TARGET } "
LIBCXXABI_ROOT_ON_DEPLOYMENT_TARGET = " ${ PREVIOUS_DYLIBS_DIR } /macOS/libc++abi/ ${ DEPLOYMENT_TARGET } "
2019-01-10 03:40:20 +08:00
2020-06-10 20:46:49 +08:00
# Filesystem is supported on Apple platforms starting with macosx10.15.
2020-07-09 04:27:33 +08:00
if [ [ ${ DEPLOYMENT_TARGET } = ~ ^10.9| 10.10| 10.11| 10.12| 10.13| 10.14$ ] ] ; then
ENABLE_FILESYSTEM = "--param enable_filesystem=false"
else
ENABLE_FILESYSTEM = "--param enable_filesystem=true"
2020-06-10 20:46:49 +08:00
fi
2019-01-10 03:40:20 +08:00
# TODO: We need to also run the tests for libc++abi.
echo "@@@ Running tests for libc++ @@@"
2019-08-07 04:01:28 +08:00
" ${ LLVM_BUILD_DIR } /bin/llvm-lit " -sv " ${ MONOREPO_ROOT } /libcxx/test " \
--param= enable_experimental = false \
2020-10-07 04:46:58 +08:00
--param= enable_debug_tests = false \
2020-06-10 20:46:49 +08:00
${ ENABLE_FILESYSTEM } \
2019-08-07 04:01:28 +08:00
--param= cxx_headers = " ${ LLVM_INSTALL_DIR } /include/c++/v1 " \
--param= std = " ${ STD } " \
[libcxx] Simplify back-deployment testing
The needs of back-deployment testing currently require two different
ways of running the test suite: one based on the deployment target,
and one based on the target triple. Since the triple includes all the
information we need, it's better to have just one way of doing things.
Furthermore, `--param platform=XXX` is also supersedded by using the
target triple. Previously, this parameter would serve the purpose of
controling XFAILs for availability markup errors, however it is possible
to achieve the same thing by using with_system_cxx_lib only and using
.verify.cpp tests instead, as explained in the documentation changes.
The motivation for this change is twofold:
1. This part of the Lit config has always been really confusing and
complicated, and it has been a source of bugs in the past. I have
simplified it iteratively in the past, but the complexity is still
there.
2. The deployment-target detection started failing in weird ways in
recent Clangs, breaking our CI. Instead of band-aid patching the
issue, I decided to remove the complexity altogether by using target
triples even on Apple platforms.
A follow-up to this commit will bring the test suite in line with
the recommended way of handling availability markup tests.
2020-09-10 04:14:56 +08:00
--param= target_triple = " x86_64-apple-macosx ${ DEPLOYMENT_TARGET } " \
2020-05-22 02:33:32 +08:00
--param= cxx_library_root = " ${ LLVM_INSTALL_DIR } /lib " \
2020-05-16 00:13:48 +08:00
--param= cxx_runtime_root = " ${ LIBCXX_ROOT_ON_DEPLOYMENT_TARGET } " \
--param= abi_library_path = " ${ LIBCXXABI_ROOT_ON_DEPLOYMENT_TARGET } " \
2020-05-15 23:33:59 +08:00
--param= use_system_cxx_lib = "True" \
2019-08-07 04:01:28 +08:00
${ ADDITIONAL_LIT_ARGS }
2019-01-10 03:40:20 +08:00
echo "@@@@@@"