From 820e1f31efc1d6ed04795ba2e79f3044e1907492 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 11 Sep 2018 18:18:58 +0000 Subject: [PATCH] import of libc++ 6.0.0 --- lib/libcxx/CMakeLists.txt | 379 ++- lib/libcxx/CREDITS.TXT | 10 +- lib/libcxx/LICENSE.TXT | 2 +- lib/libcxx/NOTES.TXT | 28 + lib/libcxx/TODO.TXT | 80 +- lib/libcxx/benchmarks/CMakeLists.txt | 156 + lib/libcxx/benchmarks/ContainerBenchmarks.hpp | 113 + lib/libcxx/benchmarks/GenerateInput.hpp | 142 + lib/libcxx/benchmarks/algorithms.bench.cpp | 62 + lib/libcxx/benchmarks/filesystem.bench.cpp | 138 + lib/libcxx/benchmarks/string.bench.cpp | 49 + lib/libcxx/benchmarks/stringstream.bench.cpp | 38 + .../unordered_set_operations.bench.cpp | 316 +- lib/libcxx/benchmarks/util_smartptr.bench.cpp | 42 + .../benchmarks/vector_operations.bench.cpp | 32 + .../cmake/Modules/CheckLibcxxAtomic.cmake | 8 +- lib/libcxx/cmake/Modules/CodeCoverage.cmake | 18 +- .../cmake/Modules/HandleCompilerRT.cmake | 58 + .../cmake/Modules/HandleLibCXXABI.cmake | 51 +- .../cmake/Modules/HandleLibcxxFlags.cmake | 12 + .../cmake/Modules/HandleOutOfTreeLLVM.cmake | 128 +- lib/libcxx/cmake/config-ix.cmake | 79 +- lib/libcxx/docs/BuildingLibcxx.rst | 113 +- lib/libcxx/docs/CMakeLists.txt | 4 +- .../docs/DesignDocs/AvailabilityMarkup.rst | 114 + lib/libcxx/docs/DesignDocs/DebugMode.rst | 100 + .../docs/DesignDocs/ThreadingSupportAPI.rst | 79 + .../docs/DesignDocs/VisibilityMacros.rst | 163 + lib/libcxx/docs/Makefile.sphinx | 2 +- lib/libcxx/docs/TestingLibcxx.rst | 104 +- lib/libcxx/docs/UsingLibcxx.rst | 94 + lib/libcxx/docs/conf.py | 6 +- lib/libcxx/docs/index.rst | 15 +- lib/libcxx/include/CMakeLists.txt | 44 +- lib/libcxx/include/__bit_reference | 50 +- lib/libcxx/include/__bsd_locale_defaults.h | 4 + lib/libcxx/include/__bsd_locale_fallbacks.h | 36 +- lib/libcxx/include/__config_site.in | 8 + lib/libcxx/include/__debug | 108 +- lib/libcxx/include/__functional_03 | 40 +- lib/libcxx/include/__functional_base | 89 +- lib/libcxx/include/__hash_table | 626 ++-- lib/libcxx/include/__libcpp_version | 1 + lib/libcxx/include/__mutex_base | 56 +- lib/libcxx/include/__nullptr | 6 +- lib/libcxx/include/__split_buffer | 37 +- lib/libcxx/include/__sso_allocator | 4 +- lib/libcxx/include/__std_stream | 10 +- lib/libcxx/include/__string | 877 +++++ lib/libcxx/include/__threading_support | 626 +++- lib/libcxx/include/__tree | 121 +- lib/libcxx/include/__tuple | 164 +- lib/libcxx/include/__undef_macros | 34 + lib/libcxx/include/algorithm | 434 ++- lib/libcxx/include/any | 667 ++++ lib/libcxx/include/array | 73 +- lib/libcxx/include/atomic | 90 +- lib/libcxx/include/bitset | 121 +- lib/libcxx/include/chrono | 124 +- lib/libcxx/include/cmath | 108 +- lib/libcxx/include/codecvt | 6 +- lib/libcxx/include/complex | 381 +-- lib/libcxx/include/condition_variable | 2 + lib/libcxx/include/cstddef | 55 +- lib/libcxx/include/cstdlib | 10 +- lib/libcxx/include/ctype.h | 9 - lib/libcxx/include/cwchar | 6 - lib/libcxx/include/deque | 261 +- lib/libcxx/include/exception | 180 +- lib/libcxx/include/experimental/__config | 7 + lib/libcxx/include/experimental/algorithm | 69 +- lib/libcxx/include/experimental/any | 20 +- lib/libcxx/include/experimental/coroutine | 296 ++ lib/libcxx/include/experimental/dynarray | 53 +- lib/libcxx/include/experimental/filesystem | 214 +- lib/libcxx/include/experimental/functional | 9 +- lib/libcxx/include/experimental/iterator | 10 +- .../include/experimental/memory_resource | 31 +- lib/libcxx/include/experimental/numeric | 119 + lib/libcxx/include/experimental/optional | 102 +- .../include/experimental/propagate_const | 12 +- lib/libcxx/include/experimental/string_view | 17 +- lib/libcxx/include/experimental/type_traits | 111 +- lib/libcxx/include/experimental/utility | 2 +- lib/libcxx/include/ext/__hash | 24 +- lib/libcxx/include/ext/hash_map | 34 +- lib/libcxx/include/ext/hash_set | 6 +- lib/libcxx/include/forward_list | 183 +- lib/libcxx/include/fstream | 89 +- lib/libcxx/include/functional | 622 +--- lib/libcxx/include/future | 108 +- lib/libcxx/include/initializer_list | 6 +- lib/libcxx/include/inttypes.h | 7 + lib/libcxx/include/iomanip | 23 +- lib/libcxx/include/ios | 29 +- lib/libcxx/include/iosfwd | 40 +- lib/libcxx/include/istream | 236 +- lib/libcxx/include/iterator | 686 ++-- lib/libcxx/include/limits | 43 +- lib/libcxx/include/limits.h | 65 + lib/libcxx/include/list | 349 +- lib/libcxx/include/locale | 266 +- lib/libcxx/include/locale.h | 45 + lib/libcxx/include/map | 212 +- lib/libcxx/include/math.h | 516 +-- lib/libcxx/include/memory | 2939 ++++++++--------- lib/libcxx/include/module.modulemap | 572 ++-- lib/libcxx/include/mutex | 211 +- lib/libcxx/include/new | 192 +- lib/libcxx/include/numeric | 329 ++ lib/libcxx/include/optional | 1399 ++++++++ lib/libcxx/include/ostream | 125 +- lib/libcxx/include/queue | 104 +- lib/libcxx/include/random | 404 +-- lib/libcxx/include/ratio | 84 +- lib/libcxx/include/regex | 288 +- lib/libcxx/include/scoped_allocator | 101 +- lib/libcxx/include/set | 101 +- lib/libcxx/include/shared_mutex | 22 +- lib/libcxx/include/sstream | 131 +- lib/libcxx/include/stack | 52 +- lib/libcxx/include/stddef.h | 3 +- lib/libcxx/include/stdexcept | 120 +- lib/libcxx/include/stdint.h | 121 + lib/libcxx/include/stdlib.h | 4 - lib/libcxx/include/streambuf | 317 +- lib/libcxx/include/string | 1502 ++++----- lib/libcxx/include/string_view | 825 +++++ lib/libcxx/include/strstream | 20 +- .../include/support/android/locale_bionic.h | 4 +- lib/libcxx/include/support/fuchsia/xlocale.h | 23 + .../include/support/win32/limits_msvc_win32.h | 72 + .../include/support/win32/locale_win32.h | 134 +- .../support/xlocale/__posix_l_fallback.h | 4 +- lib/libcxx/include/system_error | 45 +- lib/libcxx/include/thread | 112 +- lib/libcxx/include/tuple | 277 +- lib/libcxx/include/type_traits | 1343 +++++--- lib/libcxx/include/typeindex | 6 +- lib/libcxx/include/typeinfo | 150 +- lib/libcxx/include/unordered_map | 200 +- lib/libcxx/include/unordered_set | 138 +- lib/libcxx/include/utility | 1069 +++++- lib/libcxx/include/valarray | 121 +- lib/libcxx/include/variant | 1594 +++++++++ lib/libcxx/include/vector | 333 +- lib/libcxx/include/wchar.h | 13 +- lib/libcxx/lib/CMakeLists.txt | 278 +- .../lib/abi/3.9/x86_64-apple-darwin16.abilist | 2448 ++++++++++++++ .../lib/abi/3.9/x86_64-linux-gnu.abilist | 2010 +++++++++++ .../lib/abi/4.0/x86_64-apple-darwin16.abilist | 2376 +++++++++++++ .../abi/4.0/x86_64-unknown-linux-gnu.abilist | 1905 +++++++++++ lib/libcxx/lib/abi/CHANGELOG.TXT | 196 ++ lib/libcxx/lib/abi/CMakeLists.txt | 36 + lib/libcxx/lib/abi/README.TXT | 8 + .../lib/abi/x86_64-apple-darwin16.abilist | 2378 +++++++++++++ .../lib/abi/x86_64-unknown-linux-gnu.abilist | 1883 +++++++++++ lib/libcxx/lib/libc++abi-new-delete.exp | 8 + lib/libcxx/lib/libc++abi.exp | 1 + lib/libcxx/lib/libc++abi2.exp | 9 +- lib/libcxx/lib/libc++sjlj-abi.exp | 1 + lib/libcxx/src/algorithm.cpp | 2 +- lib/libcxx/src/any.cpp | 9 +- lib/libcxx/src/chrono.cpp | 120 +- lib/libcxx/src/condition_variable.cpp | 8 +- lib/libcxx/src/debug.cpp | 100 +- lib/libcxx/src/exception.cpp | 306 +- .../filesystem/directory_iterator.cpp | 148 +- .../filesystem/filesystem_time_helper.h | 173 + .../experimental/filesystem/operations.cpp | 184 +- .../src/experimental/filesystem/path.cpp | 557 ++-- .../src/experimental/memory_resource.cpp | 25 +- lib/libcxx/src/functional.cpp | 26 + lib/libcxx/src/include/atomic_support.h | 23 +- lib/libcxx/src/include/config_elast.h | 12 +- lib/libcxx/src/include/refstring.h | 128 + lib/libcxx/src/ios.cpp | 19 +- lib/libcxx/src/iostream.cpp | 56 +- lib/libcxx/src/locale.cpp | 386 ++- lib/libcxx/src/memory.cpp | 94 +- lib/libcxx/src/mutex.cpp | 27 +- lib/libcxx/src/new.cpp | 243 +- lib/libcxx/src/optional.cpp | 16 +- lib/libcxx/src/random.cpp | 31 +- lib/libcxx/src/stdexcept.cpp | 6 +- lib/libcxx/src/string.cpp | 13 +- lib/libcxx/src/strstream.cpp | 10 +- .../support/runtime/exception_fallback.ipp | 181 + .../src/support/runtime/exception_glibcxx.ipp | 38 + .../support/runtime/exception_libcxxabi.ipp | 28 + .../support/runtime/exception_libcxxrt.ipp | 41 + .../src/support/runtime/exception_msvc.ipp | 190 ++ .../runtime/exception_pointer_cxxabi.ipp | 74 + .../runtime/exception_pointer_glibcxx.ipp | 78 + .../runtime/exception_pointer_msvc.ipp | 101 + .../exception_pointer_unimplemented.ipp | 80 + .../support/runtime/new_handler_fallback.ipp | 27 + lib/libcxx/src/support/solaris/xlocale.cpp | 69 + lib/libcxx/src/support/win32/locale_win32.cpp | 60 +- lib/libcxx/src/support/win32/support.cpp | 11 - lib/libcxx/src/system_error.cpp | 83 +- lib/libcxx/src/typeinfo.cpp | 79 +- lib/libcxx/src/variant.cpp | 18 + lib/libcxx/src/vector.cpp | 16 + lib/libcxx/utils/cat_files.py | 46 + lib/libcxx/utils/gen_link_script.py | 84 + lib/libcxx/utils/google-benchmark/.gitignore | 46 + lib/libcxx/utils/google-benchmark/AUTHORS | 38 + .../utils/google-benchmark/CMakeLists.txt | 201 ++ .../utils/google-benchmark/CONTRIBUTING.md | 58 + .../utils/google-benchmark/CONTRIBUTORS | 56 + lib/libcxx/utils/google-benchmark/LICENSE | 202 ++ lib/libcxx/utils/google-benchmark/README.LLVM | 6 + lib/libcxx/utils/google-benchmark/README.md | 659 ++++ .../cmake/AddCXXCompilerFlag.cmake | 64 + .../cmake/CXXFeatureCheck.cmake | 44 + .../google-benchmark/cmake/Config.cmake.in | 1 + .../cmake/GetGitVersion.cmake | 51 + .../cmake/gnu_posix_regex.cpp | 12 + .../google-benchmark/cmake/posix_regex.cpp | 14 + .../google-benchmark/cmake/std_regex.cpp | 10 + .../google-benchmark/cmake/steady_clock.cpp | 7 + .../cmake/thread_safety_attributes.cpp | 4 + .../utils/google-benchmark/docs/tools.md | 59 + .../include/benchmark/benchmark.h | 21 + .../include/benchmark/benchmark_api.h | 915 +++++ .../include/benchmark/macros.h | 66 + .../include/benchmark/reporter.h | 230 ++ lib/libcxx/utils/google-benchmark/mingw.py | 320 ++ .../utils/google-benchmark/src/CMakeLists.txt | 75 + .../utils/google-benchmark/src/arraysize.h | 33 + .../utils/google-benchmark/src/benchmark.cc | 690 ++++ .../src/benchmark_api_internal.h | 49 + .../src/benchmark_register.cc | 452 +++ lib/libcxx/utils/google-benchmark/src/check.h | 71 + .../utils/google-benchmark/src/colorprint.cc | 188 ++ .../utils/google-benchmark/src/colorprint.h | 33 + .../google-benchmark/src/commandlineflags.cc | 218 ++ .../google-benchmark/src/commandlineflags.h | 79 + .../utils/google-benchmark/src/complexity.cc | 324 ++ .../utils/google-benchmark/src/complexity.h | 61 + .../google-benchmark/src/console_reporter.cc | 155 + .../utils/google-benchmark/src/counter.cc | 68 + .../utils/google-benchmark/src/counter.h | 26 + .../google-benchmark/src/csv_reporter.cc | 146 + .../utils/google-benchmark/src/cycleclock.h | 172 + .../google-benchmark/src/internal_macros.h | 55 + .../google-benchmark/src/json_reporter.cc | 168 + lib/libcxx/utils/google-benchmark/src/log.h | 73 + lib/libcxx/utils/google-benchmark/src/mutex.h | 155 + lib/libcxx/utils/google-benchmark/src/re.h | 140 + .../utils/google-benchmark/src/reporter.cc | 68 + .../utils/google-benchmark/src/sleep.cc | 51 + lib/libcxx/utils/google-benchmark/src/sleep.h | 15 + lib/libcxx/utils/google-benchmark/src/stat.h | 306 ++ .../utils/google-benchmark/src/string_util.cc | 172 + .../utils/google-benchmark/src/string_util.h | 40 + .../utils/google-benchmark/src/sysinfo.cc | 355 ++ .../utils/google-benchmark/src/sysinfo.h | 10 + .../utils/google-benchmark/src/timers.cc | 208 ++ .../utils/google-benchmark/src/timers.h | 48 + .../google-benchmark/test/CMakeLists.txt | 158 + .../utils/google-benchmark/test/basic_test.cc | 99 + .../google-benchmark/test/benchmark_test.cc | 257 ++ .../google-benchmark/test/complexity_test.cc | 167 + .../utils/google-benchmark/test/cxx03_test.cc | 48 + .../google-benchmark/test/diagnostics_test.cc | 64 + .../test/donotoptimize_test.cc | 33 + .../google-benchmark/test/filter_test.cc | 104 + .../google-benchmark/test/fixture_test.cc | 49 + .../utils/google-benchmark/test/map_test.cc | 56 + .../test/multiple_ranges_test.cc | 74 + .../google-benchmark/test/options_test.cc | 65 + .../utils/google-benchmark/test/output_test.h | 71 + .../test/output_test_helper.cc | 234 ++ .../test/register_benchmark_test.cc | 148 + .../test/reporter_output_test.cc | 258 ++ .../test/skip_with_error_test.cc | 150 + .../google-benchmark/tools/compare_bench.py | 68 + .../tools/gbench/Inputs/test1_run1.json | 60 + .../tools/gbench/Inputs/test1_run2.json | 60 + .../google-benchmark/tools/gbench/__init__.py | 8 + .../google-benchmark/tools/gbench/report.py | 144 + .../google-benchmark/tools/gbench/util.py | 159 + lib/libcxx/utils/libcxx/__init__.py | 17 + lib/libcxx/utils/libcxx/compiler.py | 291 ++ lib/libcxx/utils/libcxx/sym_check/__init__.py | 17 + lib/libcxx/utils/libcxx/sym_check/diff.py | 103 + lib/libcxx/utils/libcxx/sym_check/extract.py | 194 ++ lib/libcxx/utils/libcxx/sym_check/match.py | 40 + lib/libcxx/utils/libcxx/sym_check/util.py | 268 ++ lib/libcxx/utils/libcxx/test/__init__.py | 0 lib/libcxx/utils/libcxx/test/config.py | 1170 +++++++ lib/libcxx/utils/libcxx/test/executor.py | 198 ++ lib/libcxx/utils/libcxx/test/format.py | 254 ++ lib/libcxx/utils/libcxx/test/target_info.py | 277 ++ lib/libcxx/utils/libcxx/test/tracing.py | 43 + lib/libcxx/utils/libcxx/util.py | 286 ++ lib/libcxx/utils/merge_archives.py | 136 + lib/libcxx/utils/not.py | 44 + lib/libcxx/utils/sym_diff.py | 73 + lib/libcxx/utils/sym_extract.py | 42 + lib/libcxx/utils/sym_match.py | 51 + .../symcheck-blacklists/linux_blacklist.txt | 19 + .../symcheck-blacklists/osx_blacklist.txt | 19 + 305 files changed, 49963 insertions(+), 9932 deletions(-) create mode 100644 lib/libcxx/NOTES.TXT create mode 100644 lib/libcxx/benchmarks/CMakeLists.txt create mode 100644 lib/libcxx/benchmarks/ContainerBenchmarks.hpp create mode 100644 lib/libcxx/benchmarks/GenerateInput.hpp create mode 100644 lib/libcxx/benchmarks/algorithms.bench.cpp create mode 100644 lib/libcxx/benchmarks/filesystem.bench.cpp create mode 100644 lib/libcxx/benchmarks/string.bench.cpp create mode 100644 lib/libcxx/benchmarks/stringstream.bench.cpp create mode 100644 lib/libcxx/benchmarks/util_smartptr.bench.cpp create mode 100644 lib/libcxx/benchmarks/vector_operations.bench.cpp create mode 100644 lib/libcxx/cmake/Modules/HandleCompilerRT.cmake create mode 100644 lib/libcxx/docs/DesignDocs/AvailabilityMarkup.rst create mode 100644 lib/libcxx/docs/DesignDocs/DebugMode.rst create mode 100644 lib/libcxx/docs/DesignDocs/ThreadingSupportAPI.rst create mode 100644 lib/libcxx/docs/DesignDocs/VisibilityMacros.rst create mode 100644 lib/libcxx/include/__libcpp_version create mode 100644 lib/libcxx/include/__string create mode 100644 lib/libcxx/include/__undef_macros create mode 100644 lib/libcxx/include/any create mode 100644 lib/libcxx/include/experimental/coroutine create mode 100644 lib/libcxx/include/experimental/numeric create mode 100644 lib/libcxx/include/limits.h create mode 100644 lib/libcxx/include/locale.h create mode 100644 lib/libcxx/include/optional create mode 100644 lib/libcxx/include/stdint.h create mode 100644 lib/libcxx/include/string_view create mode 100644 lib/libcxx/include/support/fuchsia/xlocale.h create mode 100644 lib/libcxx/include/support/win32/limits_msvc_win32.h create mode 100644 lib/libcxx/include/variant create mode 100644 lib/libcxx/lib/abi/3.9/x86_64-apple-darwin16.abilist create mode 100644 lib/libcxx/lib/abi/3.9/x86_64-linux-gnu.abilist create mode 100644 lib/libcxx/lib/abi/4.0/x86_64-apple-darwin16.abilist create mode 100644 lib/libcxx/lib/abi/4.0/x86_64-unknown-linux-gnu.abilist create mode 100644 lib/libcxx/lib/abi/CHANGELOG.TXT create mode 100644 lib/libcxx/lib/abi/CMakeLists.txt create mode 100644 lib/libcxx/lib/abi/README.TXT create mode 100644 lib/libcxx/lib/abi/x86_64-apple-darwin16.abilist create mode 100644 lib/libcxx/lib/abi/x86_64-unknown-linux-gnu.abilist create mode 100644 lib/libcxx/lib/libc++abi-new-delete.exp create mode 100644 lib/libcxx/src/experimental/filesystem/filesystem_time_helper.h create mode 100644 lib/libcxx/src/functional.cpp create mode 100644 lib/libcxx/src/include/refstring.h create mode 100644 lib/libcxx/src/support/runtime/exception_fallback.ipp create mode 100644 lib/libcxx/src/support/runtime/exception_glibcxx.ipp create mode 100644 lib/libcxx/src/support/runtime/exception_libcxxabi.ipp create mode 100644 lib/libcxx/src/support/runtime/exception_libcxxrt.ipp create mode 100644 lib/libcxx/src/support/runtime/exception_msvc.ipp create mode 100644 lib/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp create mode 100644 lib/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp create mode 100644 lib/libcxx/src/support/runtime/exception_pointer_msvc.ipp create mode 100644 lib/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp create mode 100644 lib/libcxx/src/support/runtime/new_handler_fallback.ipp create mode 100644 lib/libcxx/src/support/solaris/xlocale.cpp create mode 100644 lib/libcxx/src/variant.cpp create mode 100644 lib/libcxx/src/vector.cpp create mode 100755 lib/libcxx/utils/cat_files.py create mode 100755 lib/libcxx/utils/gen_link_script.py create mode 100644 lib/libcxx/utils/google-benchmark/.gitignore create mode 100644 lib/libcxx/utils/google-benchmark/AUTHORS create mode 100644 lib/libcxx/utils/google-benchmark/CMakeLists.txt create mode 100644 lib/libcxx/utils/google-benchmark/CONTRIBUTING.md create mode 100644 lib/libcxx/utils/google-benchmark/CONTRIBUTORS create mode 100644 lib/libcxx/utils/google-benchmark/LICENSE create mode 100644 lib/libcxx/utils/google-benchmark/README.LLVM create mode 100644 lib/libcxx/utils/google-benchmark/README.md create mode 100644 lib/libcxx/utils/google-benchmark/cmake/AddCXXCompilerFlag.cmake create mode 100644 lib/libcxx/utils/google-benchmark/cmake/CXXFeatureCheck.cmake create mode 100644 lib/libcxx/utils/google-benchmark/cmake/Config.cmake.in create mode 100644 lib/libcxx/utils/google-benchmark/cmake/GetGitVersion.cmake create mode 100644 lib/libcxx/utils/google-benchmark/cmake/gnu_posix_regex.cpp create mode 100644 lib/libcxx/utils/google-benchmark/cmake/posix_regex.cpp create mode 100644 lib/libcxx/utils/google-benchmark/cmake/std_regex.cpp create mode 100644 lib/libcxx/utils/google-benchmark/cmake/steady_clock.cpp create mode 100644 lib/libcxx/utils/google-benchmark/cmake/thread_safety_attributes.cpp create mode 100644 lib/libcxx/utils/google-benchmark/docs/tools.md create mode 100644 lib/libcxx/utils/google-benchmark/include/benchmark/benchmark.h create mode 100644 lib/libcxx/utils/google-benchmark/include/benchmark/benchmark_api.h create mode 100644 lib/libcxx/utils/google-benchmark/include/benchmark/macros.h create mode 100644 lib/libcxx/utils/google-benchmark/include/benchmark/reporter.h create mode 100644 lib/libcxx/utils/google-benchmark/mingw.py create mode 100644 lib/libcxx/utils/google-benchmark/src/CMakeLists.txt create mode 100644 lib/libcxx/utils/google-benchmark/src/arraysize.h create mode 100644 lib/libcxx/utils/google-benchmark/src/benchmark.cc create mode 100644 lib/libcxx/utils/google-benchmark/src/benchmark_api_internal.h create mode 100644 lib/libcxx/utils/google-benchmark/src/benchmark_register.cc create mode 100644 lib/libcxx/utils/google-benchmark/src/check.h create mode 100644 lib/libcxx/utils/google-benchmark/src/colorprint.cc create mode 100644 lib/libcxx/utils/google-benchmark/src/colorprint.h create mode 100644 lib/libcxx/utils/google-benchmark/src/commandlineflags.cc create mode 100644 lib/libcxx/utils/google-benchmark/src/commandlineflags.h create mode 100644 lib/libcxx/utils/google-benchmark/src/complexity.cc create mode 100644 lib/libcxx/utils/google-benchmark/src/complexity.h create mode 100644 lib/libcxx/utils/google-benchmark/src/console_reporter.cc create mode 100644 lib/libcxx/utils/google-benchmark/src/counter.cc create mode 100644 lib/libcxx/utils/google-benchmark/src/counter.h create mode 100644 lib/libcxx/utils/google-benchmark/src/csv_reporter.cc create mode 100644 lib/libcxx/utils/google-benchmark/src/cycleclock.h create mode 100644 lib/libcxx/utils/google-benchmark/src/internal_macros.h create mode 100644 lib/libcxx/utils/google-benchmark/src/json_reporter.cc create mode 100644 lib/libcxx/utils/google-benchmark/src/log.h create mode 100644 lib/libcxx/utils/google-benchmark/src/mutex.h create mode 100644 lib/libcxx/utils/google-benchmark/src/re.h create mode 100644 lib/libcxx/utils/google-benchmark/src/reporter.cc create mode 100644 lib/libcxx/utils/google-benchmark/src/sleep.cc create mode 100644 lib/libcxx/utils/google-benchmark/src/sleep.h create mode 100644 lib/libcxx/utils/google-benchmark/src/stat.h create mode 100644 lib/libcxx/utils/google-benchmark/src/string_util.cc create mode 100644 lib/libcxx/utils/google-benchmark/src/string_util.h create mode 100644 lib/libcxx/utils/google-benchmark/src/sysinfo.cc create mode 100644 lib/libcxx/utils/google-benchmark/src/sysinfo.h create mode 100644 lib/libcxx/utils/google-benchmark/src/timers.cc create mode 100644 lib/libcxx/utils/google-benchmark/src/timers.h create mode 100644 lib/libcxx/utils/google-benchmark/test/CMakeLists.txt create mode 100644 lib/libcxx/utils/google-benchmark/test/basic_test.cc create mode 100644 lib/libcxx/utils/google-benchmark/test/benchmark_test.cc create mode 100644 lib/libcxx/utils/google-benchmark/test/complexity_test.cc create mode 100644 lib/libcxx/utils/google-benchmark/test/cxx03_test.cc create mode 100644 lib/libcxx/utils/google-benchmark/test/diagnostics_test.cc create mode 100644 lib/libcxx/utils/google-benchmark/test/donotoptimize_test.cc create mode 100644 lib/libcxx/utils/google-benchmark/test/filter_test.cc create mode 100644 lib/libcxx/utils/google-benchmark/test/fixture_test.cc create mode 100644 lib/libcxx/utils/google-benchmark/test/map_test.cc create mode 100644 lib/libcxx/utils/google-benchmark/test/multiple_ranges_test.cc create mode 100644 lib/libcxx/utils/google-benchmark/test/options_test.cc create mode 100644 lib/libcxx/utils/google-benchmark/test/output_test.h create mode 100644 lib/libcxx/utils/google-benchmark/test/output_test_helper.cc create mode 100644 lib/libcxx/utils/google-benchmark/test/register_benchmark_test.cc create mode 100644 lib/libcxx/utils/google-benchmark/test/reporter_output_test.cc create mode 100644 lib/libcxx/utils/google-benchmark/test/skip_with_error_test.cc create mode 100644 lib/libcxx/utils/google-benchmark/tools/compare_bench.py create mode 100644 lib/libcxx/utils/google-benchmark/tools/gbench/Inputs/test1_run1.json create mode 100644 lib/libcxx/utils/google-benchmark/tools/gbench/Inputs/test1_run2.json create mode 100644 lib/libcxx/utils/google-benchmark/tools/gbench/__init__.py create mode 100644 lib/libcxx/utils/google-benchmark/tools/gbench/report.py create mode 100644 lib/libcxx/utils/google-benchmark/tools/gbench/util.py create mode 100644 lib/libcxx/utils/libcxx/__init__.py create mode 100644 lib/libcxx/utils/libcxx/compiler.py create mode 100644 lib/libcxx/utils/libcxx/sym_check/__init__.py create mode 100644 lib/libcxx/utils/libcxx/sym_check/diff.py create mode 100644 lib/libcxx/utils/libcxx/sym_check/extract.py create mode 100644 lib/libcxx/utils/libcxx/sym_check/match.py create mode 100644 lib/libcxx/utils/libcxx/sym_check/util.py create mode 100644 lib/libcxx/utils/libcxx/test/__init__.py create mode 100644 lib/libcxx/utils/libcxx/test/config.py create mode 100644 lib/libcxx/utils/libcxx/test/executor.py create mode 100644 lib/libcxx/utils/libcxx/test/format.py create mode 100644 lib/libcxx/utils/libcxx/test/target_info.py create mode 100644 lib/libcxx/utils/libcxx/test/tracing.py create mode 100644 lib/libcxx/utils/libcxx/util.py create mode 100755 lib/libcxx/utils/merge_archives.py create mode 100644 lib/libcxx/utils/not.py create mode 100755 lib/libcxx/utils/sym_diff.py create mode 100755 lib/libcxx/utils/sym_extract.py create mode 100755 lib/libcxx/utils/sym_match.py create mode 100644 lib/libcxx/utils/symcheck-blacklists/linux_blacklist.txt create mode 100644 lib/libcxx/utils/symcheck-blacklists/osx_blacklist.txt diff --git a/lib/libcxx/CMakeLists.txt b/lib/libcxx/CMakeLists.txt index d618e8358ca..9e8e9d5e3d9 100644 --- a/lib/libcxx/CMakeLists.txt +++ b/lib/libcxx/CMakeLists.txt @@ -19,23 +19,25 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ) -# Find the LLVM sources and simulate LLVM CMake options. -include(HandleOutOfTreeLLVM) - -if (LIBCXX_BUILT_STANDALONE) +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(libcxx CXX C) set(PACKAGE_NAME libcxx) - set(PACKAGE_VERSION trunk-svn) + set(PACKAGE_VERSION 6.0.0) set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org") -endif () -if (LIBCXX_BUILT_STANDALONE AND NOT LLVM_FOUND) - message(WARNING "UNSUPPORTED LIBCXX CONFIGURATION DETECTED: " - "llvm-config not found and LLVM_PATH not defined.\n" - "Reconfigure with -DLLVM_CONFIG=path/to/llvm-config " - "or -DLLVM_PATH=path/to/llvm-source-root.") + # Find the LLVM sources and simulate LLVM CMake options. + include(HandleOutOfTreeLLVM) +endif() + +if (LIBCXX_STANDALONE_BUILD) + include(FindPythonInterp) + if( NOT PYTHONINTERP_FOUND ) + message(WARNING "Failed to find python interpreter. " + "The libc++ test suite will be disabled.") + set(LLVM_INCLUDE_TESTS OFF) + endif() endif() # Require out of source build. @@ -45,46 +47,103 @@ MACRO_ENSURE_OUT_OF_SOURCE_BUILD( build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." ) +if (MSVC) + set(LIBCXX_TARGETING_MSVC ON) +else() + set(LIBCXX_TARGETING_MSVC OFF) +endif() + #=============================================================================== # Setup CMake Options #=============================================================================== +include(CMakeDependentOption) +include(HandleCompilerRT) # Basic options --------------------------------------------------------------- -option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON) +option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." OFF) option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON) +option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON) option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON) -option(LIBCXX_ENABLE_FILESYSTEM - "Build filesystem as part of libc++experimental.a" ${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY}) +set(ENABLE_FILESYSTEM_DEFAULT ${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY}) +if (WIN32) + set(ENABLE_FILESYSTEM_DEFAULT OFF) +endif() +option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of libc++experimental.a" + ${ENABLE_FILESYSTEM_DEFAULT}) option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS}) + +# Benchmark options ----------------------------------------------------------- +option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependancies" ON) +set(LIBCXX_BENCHMARK_NATIVE_STDLIB "" CACHE STRING + "Build the benchmarks against the specified native STL. + The value must be one of libc++/libstdc++") +set(LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN "" CACHE STRING + "Use alternate GCC toolchain when building the native benchmarks") + +if (LIBCXX_BENCHMARK_NATIVE_STDLIB) + if (NOT (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libc++" + OR LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++")) + message(FATAL_ERROR "Invalid value for LIBCXX_BENCHMARK_NATIVE_STDLIB: " + "'${LIBCXX_BENCHMARK_NATIVE_STDLIB}'") + endif() +endif() + option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS}) set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING "Define suffix of library directory name (32/64)") option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON) option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON) option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON) -option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY "Install libc++experimental.a" OFF) +cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY + "Install libc++experimental.a" ON + "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF) set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.") option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF) +option(LIBCXX_ABI_FORCE_ITANIUM "Ignore auto-detection and force use of the Itanium ABI.") +option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.") +set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros to define in the site config header.") +option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) + +if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC) + message(FATAL_ERROR "libc++ must be built as either a shared or static library.") +endif() # ABI Library options --------------------------------------------------------- -set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING - "Specify C++ ABI library to use." FORCE) -set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++) +set(LIBCXX_CXX_ABI "default" CACHE STRING + "Specify C++ ABI library to use.") +set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++ vcruntime) set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS}) # Setup the default options if LIBCXX_CXX_ABI is not specified. -if (NOT LIBCXX_CXX_ABI) - if (NOT DEFINED LIBCXX_BUILT_STANDALONE AND - IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi") +if (LIBCXX_CXX_ABI STREQUAL "default") + find_path( + LIBCXX_LIBCXXABI_INCLUDES_INTERNAL + cxxabi.h + PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxxabi/include + ${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include + ${LLVM_MAIN_SRC_DIR}/../libcxxabi/include + NO_DEFAULT_PATH + ) + if (LIBCXX_TARGETING_MSVC) + # FIXME: Figure out how to configure the ABI library on Windows. + set(LIBCXX_CXX_ABI_LIBNAME "vcruntime") + elseif ((NOT LIBCXX_STANDALONE_BUILD OR HAVE_LIBCXXABI) AND + IS_DIRECTORY "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}") set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi") - set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${CMAKE_SOURCE_DIR}/projects/libcxxabi/include") + set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}") set(LIBCXX_CXX_ABI_INTREE 1) - else () - set(LIBCXX_CXX_ABI_LIBNAME "none") - endif () -else () + elseif (APPLE) + set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi") + set(LIBCXX_CXX_ABI_SYSTEM 1) + elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + set(LIBCXX_CXX_ABI_LIBNAME "libcxxrt") + set(LIBCXX_CXX_ABI_INCLUDE_PATHS "/usr/include/c++/v1") + else() + set(LIBCXX_CXX_ABI_LIBNAME "default") + endif() +else() set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}") -endif () +endif() # Use a static copy of the ABI library when linking libc++. This option # cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT. @@ -92,12 +151,13 @@ option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF) # Generate and install a linker script inplace of libc++.so. The linker script # will link libc++ to the correct ABI library. This option is on by default -# On UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY' +# on UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY' # is on. This option is also disabled when the ABI library is not specified # or is specified to be "none". set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF) if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none" + AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "default" AND PYTHONINTERP_FOUND AND LIBCXX_ENABLE_SHARED) set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON) @@ -107,9 +167,25 @@ option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT "Use and install a linker script for the given ABI library" ${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE}) +set(ENABLE_NEW_DELETE_DEFAULT ON) +if (LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS) +# FIXME: This option should default to off. Unfortunatly GCC 4.9 fails to link +# programs due to undefined references to new/delete in libc++abi so to work +# around this libc++abi currently defaults LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS +# to ON. Once the GCC bug has been worked around this option should be changed +# back to OFF. + set(ENABLE_NEW_DELETE_DEFAULT ON) +endif() + +option(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS + "Build libc++ with definitions for operator new/delete. This option can + be used to disable the definitions when libc++abi is expected to provide + them" ${ENABLE_NEW_DELETE_DEFAULT}) + # Build libc++abi with libunwind. We need this option to determine whether to # link with libunwind or libgcc_s while running the test cases. option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) +option(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM unwinder." OFF) # Target options -------------------------------------------------------------- option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS}) @@ -129,6 +205,12 @@ option(LIBCXX_ENABLE_MONOTONIC_CLOCK This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON) option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF) option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF) +option(LIBCXX_HAS_EXTERNAL_THREAD_API + "Build libc++ with an externalized threading API. + This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF) +option(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY + "Build libc++ with an externalized threading library. + This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON" OFF) # Misc options ---------------------------------------------------------------- # FIXME: Turn -pedantic back ON. It is currently off because it warns @@ -181,9 +263,33 @@ if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK) " when LIBCXX_ENABLE_THREADS is also set to OFF.") endif() -if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS) - message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" - " when LIBCXX_ENABLE_THREADS is also set to ON.") +if(NOT LIBCXX_ENABLE_THREADS) + if(LIBCXX_HAS_PTHREAD_API) + message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" + " when LIBCXX_ENABLE_THREADS is also set to ON.") + endif() + if(LIBCXX_HAS_EXTERNAL_THREAD_API) + message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON" + " when LIBCXX_ENABLE_THREADS is also set to ON.") + endif() + if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) + message(FATAL_ERROR "LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY can only be set " + "to ON when LIBCXX_ENABLE_THREADS is also set to ON.") + endif() + +endif() + +if (LIBCXX_HAS_EXTERNAL_THREAD_API) + if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) + message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY and " + "LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be ON at " + "the same time") + endif() + if (LIBCXX_HAS_PTHREAD_API) + message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" + "and LIBCXX_HAS_PTHREAD_API cannot be both" + "set to ON at the same time.") + endif() endif() # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE @@ -209,6 +315,9 @@ if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) else() message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option") endif() + if (LIBCXX_ENABLE_STATIC AND NOT PYTHONINTERP_FOUND) + message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY requires python but it was not found.") + endif() endif() if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) @@ -234,6 +343,10 @@ if (LIBCXX_HAS_MUSL_LIBC AND NOT LIBCXX_INSTALL_SUPPORT_HEADERS) "when building for Musl with LIBCXX_HAS_MUSL_LIBC.") endif() +if (LIBCXX_ABI_FORCE_ITANIUM AND LIBCXX_ABI_FORCE_MICROSOFT) + message(FATAL_ERROR "Only one of LIBCXX_ABI_FORCE_ITANIUM and LIBCXX_ABI_FORCE_MICROSOFT can be specified.") +endif () + #=============================================================================== # Configure System #=============================================================================== @@ -241,19 +354,37 @@ endif() set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER}) set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) -set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) +set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build") +if (LLVM_LIBRARY_OUTPUT_INTDIR) + set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) +else() + set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) +endif() +file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}") + +set(LIBCXX_INSTALL_PREFIX "" CACHE STRING + "Define libc++ destination prefix.") + +if (NOT LIBCXX_INSTALL_PREFIX MATCHES "^$|.*/") + message(FATAL_ERROR "LIBCXX_INSTALL_PREFIX has to end with \"/\".") +endif() set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) # Declare libc++ configuration variables. # They are intended for use as follows: # LIBCXX_CXX_FLAGS: General flags for both the compiler and linker. # LIBCXX_COMPILE_FLAGS: Compile only flags. # LIBCXX_LINK_FLAGS: Linker only flags. +# LIBCXX_LIBRARIES: libraries libc++ is linked to. +# LIBCXX_INTERFACE_LIBRARIES: Libraries that must be linked when using libc++ +# These libraries are exposed in the linker script. set(LIBCXX_COMPILE_FLAGS "") set(LIBCXX_LINK_FLAGS "") set(LIBCXX_LIBRARIES "") +set(LIBCXX_INTERFACE_LIBRARIES "") # Include macros for adding and removing libc++ flags. include(HandleLibcxxFlags) @@ -263,13 +394,20 @@ include(HandleLibcxxFlags) # 'config-ix' use them during feature checks. It also adds them to both # 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS' add_target_flags_if(LIBCXX_BUILD_32_BITS "-m32") -add_target_flags_if(LIBCXX_TARGET_TRIPLE "-target ${LIBCXX_TARGET_TRIPLE}") +add_target_flags_if(LIBCXX_TARGET_TRIPLE "--target=${LIBCXX_TARGET_TRIPLE}") add_target_flags_if(LIBCXX_SYSROOT "--sysroot=${LIBCXX_SYSROOT}") -add_target_flags_if(LIBCXX_GCC_TOOLCHAIN "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}") +add_target_flags_if(LIBCXX_GCC_TOOLCHAIN "--gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}") +if (LIBCXX_TARGET_TRIPLE) + set(TARGET_TRIPLE "${LIBCXX_TARGET_TRIPLE}") +endif() # Configure compiler. include(config-ix) +if (LIBCXX_USE_COMPILER_RT) + list(APPEND LIBCXX_LINK_FLAGS "-rtlib=compiler-rt") +endif() + # Configure coverage options. if (LIBCXX_GENERATE_COVERAGE) include(CodeCoverage) @@ -277,6 +415,11 @@ if (LIBCXX_GENERATE_COVERAGE) endif() string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) +if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") + set(LIBCXX_DEBUG_BUILD ON) +else() + set(LIBCXX_DEBUG_BUILD OFF) +endif() #=============================================================================== # Setup Compiler Flags @@ -284,19 +427,36 @@ string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) include(HandleLibCXXABI) # Setup the ABI library flags -# Remove flags that may have snuck in. -remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG - -stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32) +if (NOT LIBCXX_STANDALONE_BUILD) + # Remove flags that may have snuck in. + remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG + -lc++abi) +endif() +remove_flags(-stdlib=libc++ -stdlib=libstdc++) + +# FIXME: Remove all debug flags and flags that change which Windows +# default libraries are linked. Currently we only support linking the +# non-debug DLLs +remove_flags("/D_DEBUG" "/MTd" "/MDd" "/MT" "/Md") # FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC. # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors -# so they don't get transformed into -Wno and -errors respectivly. +# so they don't get transformed into -Wno and -errors respectively. remove_flags(-Wno-pedantic -pedantic-errors -pedantic) # Required flags ============================================================== -add_compile_flags_if_supported(-std=c++11) -if (NOT MSVC AND NOT LIBCXX_SUPPORTS_STD_EQ_CXX11_FLAG) - message(FATAL_ERROR "C++11 is required but the compiler does not support -std=c++11") +set(LIBCXX_STANDARD_VER c++11 CACHE INTERNAL "internal option to change build dialect") +if (LIBCXX_HAS_MUSL_LIBC) + # musl's pthread implementations uses volatile types in their structs which is + # not a constexpr in C++11 but is in C++14, so we use C++14 with musl. + set(LIBCXX_STANDARD_VER c++14 CACHE INTERNAL "internal option to change build dialect") +endif() +add_compile_flags_if_supported(-std=${LIBCXX_STANDARD_VER}) +mangle_name("LIBCXX_SUPPORTS_STD_EQ_${LIBCXX_STANDARD_VER}_FLAG" SUPPORTS_DIALECT_NAME) +if(NOT ${SUPPORTS_DIALECT_NAME}) + if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND NOT "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") + message(FATAL_ERROR "C++11 or greater is required but the compiler does not support ${LIBCXX_STANDARD_VER}") + endif() endif() # On all systems the system c++ standard library headers need to be excluded. @@ -305,14 +465,40 @@ endif() # headers add_compile_flags_if_supported(-nostdinc++) +# Hide all inline function definitions which have not explicitly been marked +# visible. This prevents new definitions for inline functions from appearing in +# the dylib when get ODR used by another function. +add_compile_flags_if_supported(-fvisibility-inlines-hidden) + +if (LIBCXX_CONFIGURE_IDE) + # This simply allows IDE to process + add_compile_flags_if_supported(-fcoroutines-ts) +endif() + +# Let the library headers know they are currently being used to build the +# library. +add_definitions(-D_LIBCPP_BUILDING_LIBRARY) + +if (NOT LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS) + add_definitions(-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS) +endif() # Warning flags =============================================================== add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) add_compile_flags_if_supported( - -Wall -W -Wwrite-strings - -Wno-unused-parameter -Wno-long-long -Wno-user-defined-literals - -Wno-covered-switch-default + -Wall -Wextra -W -Wwrite-strings + -Wno-unused-parameter -Wno-long-long -Werror=return-type) +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + add_compile_flags_if_supported( + -Wno-user-defined-literals + -Wno-covered-switch-default) +elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + add_compile_flags_if_supported( + -Wno-literal-suffix + -Wno-c++14-compat + -Wno-noexcept-type) +endif() if (LIBCXX_ENABLE_WERROR) add_compile_flags_if_supported(-Werror) add_compile_flags_if_supported(-WX) @@ -346,22 +532,42 @@ if (NOT LIBCXX_ENABLE_RTTI) add_compile_flags_if_supported(-fno-rtti) endif() +# Threading flags ============================================================= +if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXX_ENABLE_SHARED) + # Need to allow unresolved symbols if this is to work with shared library builds + if (APPLE) + add_link_flags("-undefined dynamic_lookup") + else() + # Relax this restriction from HandleLLVMOptions + string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") + endif() +endif() + # Assertion flags ============================================================= define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG) define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG) -if (LIBCXX_ENABLE_ASSERTIONS) +define_if(LIBCXX_ENABLE_ASSERTIONS -D_LIBCPP_DEBUG=0) +define_if(LIBCXX_DEBUG_BUILD -D_DEBUG) +if (LIBCXX_ENABLE_ASSERTIONS AND NOT LIBCXX_DEBUG_BUILD) # MSVC doesn't like _DEBUG on release builds. See PR 4379. - define_if_not(MSVC -D_DEBUG) + define_if_not(LIBCXX_TARGETING_MSVC -D_DEBUG) endif() -# Feature flags =============================================================== -define_if(MSVC -D_CRT_SECURE_NO_WARNINGS) +# Modules flags =============================================================== +# FIXME The libc++ sources are fundamentally non-modular. They need special +# versions of the headers in order to provide C++03 and legacy ABI definitions. +# NOTE: The public headers can be used with modules in all other contexts. +if (LLVM_ENABLE_MODULES) + # Ignore that the rest of the modules flags are now unused. + add_compile_flags_if_supported(-Wno-unused-command-line-argument) + add_compile_flags(-fno-modules) +endif() # Sanitizer flags ============================================================= -# Configure for sanitizers. If LIBCXX_BUILT_STANDALONE then we have to do +# Configure for sanitizers. If LIBCXX_STANDALONE_BUILD then we have to do # the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it. -if (LIBCXX_BUILT_STANDALONE) +if (LIBCXX_STANDALONE_BUILD) set(LLVM_USE_SANITIZER "" CACHE STRING "Define the sanitizer used to build the library and tests") # NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC. @@ -398,6 +604,8 @@ if (NOT LIBCXX_ABI_VERSION EQUAL "1") config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION) endif() config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE) +config_define_if(LIBCXX_ABI_FORCE_ITANIUM _LIBCPP_ABI_FORCE_ITANIUM) +config_define_if(LIBCXX_ABI_FORCE_MICROSOFT _LIBCPP_ABI_FORCE_MICROSOFT) config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE) config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN) @@ -407,16 +615,49 @@ config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOC config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD) +config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL) +config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC) +config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME) +if (LIBCXX_ABI_DEFINES) + set(abi_defines) + foreach (abi_define ${LIBCXX_ABI_DEFINES}) + if (NOT abi_define MATCHES "^_LIBCPP_ABI_") + message(SEND_ERROR "Invalid ABI macro ${abi_define} in LIBCXX_ABI_DEFINES") + endif() + list(APPEND abi_defines "#define ${abi_define}") + endforeach() + string(REPLACE ";" "\n" abi_defines "${abi_defines}") + config_define(${abi_defines} _LIBCPP_ABI_DEFINES) +endif() + +# By default libc++ on Windows expects to use a shared library, which requires +# the headers to use DLL import/export semantics. However when building a +# static library only we modify the headers to disable DLL import/export. +if (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED) + message(STATUS "Generating custom __config for non-DLL Windows build") + config_define(ON _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) +endif() + +set(site_config_path "${LIBCXX_BINARY_DIR}/__config_site") if (LIBCXX_NEEDS_SITE_CONFIG) - configure_file( - include/__config_site.in - ${LIBCXX_BINARY_DIR}/__config_site - @ONLY) + configure_file("include/__config_site.in" + "${site_config_path}" + @ONLY) + # Provide the config definitions by included the generated __config_site # file at compile time. - add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site") + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") + add_compile_flags("/FI\"${LIBCXX_BINARY_DIR}/__config_site\"") + else() + add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site") + endif() +else() + if (EXISTS "${site_config_path}") + message(STATUS "Removing stale site configuration ${site_config_path}") + file(REMOVE "${site_config_path}") + endif() endif() #=============================================================================== @@ -426,9 +667,35 @@ include_directories(include) add_subdirectory(include) add_subdirectory(lib) -if (LIBCXX_INCLUDE_TESTS) + +if (LIBCXX_INCLUDE_BENCHMARKS) + add_subdirectory(benchmarks) +endif() + +# Create the lit.site.cfg file even when LIBCXX_INCLUDE_TESTS is OFF or +# LLVM_FOUND is OFF. This allows users to run the tests manually using +# LIT without requiring a full LLVM checkout. +# +# However, since some submission systems strip test/ subdirectories, check for +# it before adding it. + +if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test") add_subdirectory(test) endif() +if (LIBCXX_INCLUDE_TESTS) + add_subdirectory(lib/abi) +endif() + +if (LIBCXX_STANDALONE_BUILD AND EXISTS "${LLVM_MAIN_SRC_DIR}/utils/llvm-lit") + include(AddLLVM) # for get_llvm_lit_path + # Make sure the llvm-lit script is generated into the bin directory, and do + # it after adding all tests, since the generated script will only work + # correctly discovered tests against test locations from the source tree that + # have already been discovered. + add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit + ${CMAKE_CURRENT_BINARY_DIR}/llvm-lit) +endif() + if (LIBCXX_INCLUDE_DOCS) add_subdirectory(docs) endif() diff --git a/lib/libcxx/CREDITS.TXT b/lib/libcxx/CREDITS.TXT index ceb12c42b96..46a06c6eab0 100644 --- a/lib/libcxx/CREDITS.TXT +++ b/lib/libcxx/CREDITS.TXT @@ -41,6 +41,10 @@ N: Jonathan B Coe E: jbcoe@me.com D: Implementation of propagate_const. +N: Glen Joseph Fernandes +E: glenjofe@gmail.com +D: Implementation of to_address. + N: Eric Fiselier E: eric@efcs.ca D: LFTS support, patches and bug fixes. @@ -80,6 +84,10 @@ N: Andrew Morrow E: andrew.c.morrow@gmail.com D: Minor patches and Linux fixes. +N: Michael Park +E: mcypark@gmail.com +D: Implementation of . + N: Arvid Picciani E: aep at exys dot org D: Minor patches and musl port. @@ -93,7 +101,7 @@ E: nico.rieck@gmail.com D: Windows fixes N: Jon Roelofs -E: jonathan@codesourcery.com +E: jroelofS@jroelofs.com D: Remote testing, Newlib port, baremetal/single-threaded support. N: Jonathan Sauer diff --git a/lib/libcxx/LICENSE.TXT b/lib/libcxx/LICENSE.TXT index 339e232c68f..c278f2c9283 100644 --- a/lib/libcxx/LICENSE.TXT +++ b/lib/libcxx/LICENSE.TXT @@ -14,7 +14,7 @@ Full text of the relevant licenses is included below. University of Illinois/NCSA Open Source License -Copyright (c) 2009-2016 by the contributors listed in CREDITS.TXT +Copyright (c) 2009-2017 by the contributors listed in CREDITS.TXT All rights reserved. diff --git a/lib/libcxx/NOTES.TXT b/lib/libcxx/NOTES.TXT new file mode 100644 index 00000000000..f0597de64ae --- /dev/null +++ b/lib/libcxx/NOTES.TXT @@ -0,0 +1,28 @@ +//===---------------------------------------------------------------------===// +// Notes relating to various libc++ tasks +//===---------------------------------------------------------------------===// + +This file contains notes about various libc++ tasks and processes. + +//===---------------------------------------------------------------------===// +// Post-Release TODO +//===---------------------------------------------------------------------===// + +These notes contain a list of things that must be done after branching for +an LLVM release. + +1. Update _LIBCPP_VERSION in `__config` +2. Update the __libcpp_version file. +3. Update the version number in `docs/conf.py` +4. Create ABI lists for the previous release under `lib/abi` + +//===---------------------------------------------------------------------===// +// Adding a new header TODO +//===---------------------------------------------------------------------===// + +These notes contain a list of things that must be done upon adding a new header +to libc++. + +1. Add a test under `test/libcxx` that the header defines `_LIBCPP_VERSION`. +2. Update `test/libcxx/double_include.sh.cpp` to include the new header. +3. Create a submodule in `include/module.modulemap` for the new header. diff --git a/lib/libcxx/TODO.TXT b/lib/libcxx/TODO.TXT index bdb94de343d..652a38de75a 100644 --- a/lib/libcxx/TODO.TXT +++ b/lib/libcxx/TODO.TXT @@ -1,56 +1,76 @@ This is meant to be a general place to list things that should be done "someday" -3.8 Release Goals -================= -* LFTS v1 (EricWF, MClow) -* Filesystem TS (EricWF) -* ASIO TS (MClow) -* Improvements (MClow) -* Setup ABI Versioning policy (EricWF) -* Fix PR19302 - Fix UB in list and __tree. - - -ABI Related Tasks -================= -* Explicitly manage and verify symbols exported from the dylib. -* Explore using namespaces for managing symbol visibility. -* Introduce and document ABI versioning/evolution policy. - CXX Runtime Library Tasks ========================= -* Cleanup #ifdef hell in sources files that supports the different ABI libraries. * Fix that CMake always link to /usr/lib/libc++abi.dylib on OS X. -* Fix selection of ABI symbol list on OS X. -* Have CMake generate linker scripts for libc++.so that it properly links the - runtime library. * Look into mirroring libsupc++'s typeinfo vtable layout when libsupc++/libstdc++ is used as the runtime library. -* Audit libraries that CMake links into libc++. Are they all required? * Investigate and document interoperability between libc++ and libstdc++ on linux. Do this for every supported c++ runtime library. Atomic Related Tasks ==================== -* Enable mixing of clang and GCC atomics internally. Currently some - parts of libc++ use atomics only when clang provides them. - (see memory@5380 for an example) -* Audit use of libatomic builtins in with GCC. * future should use for synchronization. Test Suite Tasks ================ -* Move all libc++ specific tests from test/std into test/libcxx. -* Improve how LIT handles compiler warnings. * Improve the quality and portability of the locale test data. * Convert failure tests to use Clang Verify. +Filesystem Tasks +================ +* P0492r2 - Implement National body comments for Filesystem + * INCOMPLETE - US 25: has_filename() is equivalent to just !empty() + * INCOMPLETE - US 31: Everything is defined in terms of one implicit host system + * INCOMPLETE - US 32: Meaning of 27.10.2.1 unclear + * INCOMPLETE - US 33: Definition of canonical path problematic + * INCOMPLETE - US 34: Are there attributes of a file that are not an aspect of the file system? + * INCOMPLETE - US 35: What synchronization is required to avoid a file system race? + * INCOMPLETE - US 36: Symbolic links themselves are attached to a directory via (hard) links + * INCOMPLETE - US 37: The term “redundant current directory (dot) elements” is not defined + * INCOMPLETE - US 38: Duplicates §17.3.16 + * INCOMPLETE - US 39: Remove note: Dot and dot-dot are not directories + * INCOMPLETE - US 40: Not all directories have a parent. + * INCOMPLETE - US 41: The term “parent directory” for a (non-directory) file is unusual + * INCOMPLETE - US 42: Pathname resolution does not always resolve a symlink + * INCOMPLETE - US 43: Concerns about encoded character types + * INCOMPLETE - US 44: Definition of path in terms of a string requires leaky abstraction + * INCOMPLETE - US 45: Generic format portability compromised by unspecified root-name + * INCOMPLETE - US 46: filename can be empty so productions for relative-path are redundant + * INCOMPLETE - US 47: “.” and “..” already match the name production + * INCOMPLETE - US 48: Multiple separators are often meaningful in a root-name + * INCOMPLETE - US 49: What does “method of conversion method” mean? + * INCOMPLETE - US 50: 27.10.8.1 ¶ 1.4 largely redundant with ¶ 1.3 + * INCOMPLETE - US 51: Failing to add / when appending empty string prevents useful apps + * INCOMPLETE - US 52: remove_filename() postcondition is not by itself a definition + * INCOMPLETE - US 53: remove_filename()'s name does not correspond to its behavior + * INCOMPLETE - US 54: remove_filename() is broken + * INCOMPLETE - US 55: replace_extension()'s use of path as parameter is inappropriate + * INCOMPLETE - US 56: Remove replace_extension()'s conditional addition of period + * INCOMPLETE - US 57: On Windows, absolute paths will sort in among relative paths + * INCOMPLETE - US 58: parent_path() behavior for root paths is useless + * INCOMPLETE - US 59: filename() returning path for single path components is bizarre + * INCOMPLETE - US 60: path("/foo/").filename()==path(".") is surprising + * INCOMPLETE - US 61: Leading dots in filename() should not begin an extension + * INCOMPLETE - US 62: It is important that stem()+extension()==filename() + * INCOMPLETE - US 63: lexically_normal() inconsistently treats trailing "/" but not "/.." as directory + * INCOMPLETE - US 73, CA 2: root-name is effectively implementation defined + * INCOMPLETE - US 74, CA 3: The term “pathname” is ambiguous in some contexts + * INCOMPLETE - US 75, CA 4: Extra flag in path constructors is needed + * INCOMPLETE - US 76, CA 5: root-name definition is over-specified. + * INCOMPLETE - US 77, CA 6: operator/ and other appends not useful if arg has root-name + * INCOMPLETE - US 78, CA 7: Member absolute() in 27.10.4.1 is overspecified for non-POSIX-like O/S + * INCOMPLETE - US 79, CA 8: Some operation functions are overspecified for implementation-defined file types + * INCOMPLETE - US 185: Fold error_code and non-error_code signatures into one signature + * INCOMPLETE - FI 14: directory_entry comparisons are members + * INCOMPLETE - Late 36: permissions() error_code overload should be noexcept + * INCOMPLETE - Late 37: permissions() actions should be separate parameter + * INCOMPLETE - Late 42: resize_file() Postcondition missing argument + Misc Tasks ========== * Find all sequences of >2 underscores and eradicate them. * run clang-tidy on libc++ * Document the "conditionally-supported" bits of libc++ * Look at basic_string's move assignment operator, re LWG 2063 and POCMA -* libc++ is missing try_emplace * Put a static_assert in std::allocator to deny const/volatile types (LWG 2447) -* Document support (or lack of) for C++11 libraries in C++03. -* Document supported compilers. diff --git a/lib/libcxx/benchmarks/CMakeLists.txt b/lib/libcxx/benchmarks/CMakeLists.txt new file mode 100644 index 00000000000..8211ebd009a --- /dev/null +++ b/lib/libcxx/benchmarks/CMakeLists.txt @@ -0,0 +1,156 @@ +include(ExternalProject) +include(CheckCXXCompilerFlag) + +#============================================================================== +# Build Google Benchmark for libc++ +#============================================================================== + +set(BENCHMARK_LIBCXX_COMPILE_FLAGS + -Wno-unused-command-line-argument + -nostdinc++ + -isystem ${LIBCXX_SOURCE_DIR}/include + -L${LIBCXX_LIBRARY_DIR} + -Wl,-rpath,${LIBCXX_LIBRARY_DIR} + ) +if (DEFINED LIBCXX_CXX_ABI_LIBRARY_PATH) + list(APPEND BENCHMARK_LIBCXX_COMPILE_FLAGS + -L${LIBCXX_CXX_ABI_LIBRARY_PATH} + -Wl,-rpath,${LIBCXX_CXX_ABI_LIBRARY_PATH}) +endif() +split_list(BENCHMARK_LIBCXX_COMPILE_FLAGS) + +ExternalProject_Add(google-benchmark-libcxx + EXCLUDE_FROM_ALL ON + DEPENDS cxx + PREFIX benchmark-libcxx + SOURCE_DIR ${LIBCXX_SOURCE_DIR}/utils/google-benchmark + INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx + CMAKE_CACHE_ARGS + -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER} + -DCMAKE_BUILD_TYPE:STRING=RELEASE + -DCMAKE_INSTALL_PREFIX:PATH= + -DCMAKE_CXX_FLAGS:STRING=${BENCHMARK_LIBCXX_COMPILE_FLAGS} + -DBENCHMARK_USE_LIBCXX:BOOL=ON + -DBENCHMARK_ENABLE_TESTING:BOOL=OFF) + +#============================================================================== +# Build Google Benchmark for the native stdlib +#============================================================================== +set(BENCHMARK_NATIVE_TARGET_FLAGS) +if (LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN) + set(BENCHMARK_NATIVE_TARGET_FLAGS + -gcc-toolchain ${LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN}) +endif() +split_list(BENCHMARK_NATIVE_TARGET_FLAGS) + +if (LIBCXX_BENCHMARK_NATIVE_STDLIB) + ExternalProject_Add(google-benchmark-native + EXCLUDE_FROM_ALL ON + PREFIX benchmark-native + SOURCE_DIR ${LIBCXX_SOURCE_DIR}/utils/google-benchmark + INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native + CMAKE_CACHE_ARGS + -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS:STRING=${BENCHMARK_NATIVE_TARGET_FLAGS} + -DCMAKE_BUILD_TYPE:STRING=RELEASE + -DCMAKE_INSTALL_PREFIX:PATH= + -DBENCHMARK_ENABLE_TESTING:BOOL=OFF) +endif() + +#============================================================================== +# Benchmark tests configuration +#============================================================================== +add_custom_target(cxx-benchmarks) +set(BENCHMARK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set(BENCHMARK_LIBCXX_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx) +set(BENCHMARK_NATIVE_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native) +set(BENCHMARK_TEST_COMPILE_FLAGS + -std=c++14 -O2 + -I${BENCHMARK_LIBCXX_INSTALL}/include + -I${LIBCXX_SOURCE_DIR}/test/support +) +set(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS + -nostdinc++ + -isystem ${LIBCXX_SOURCE_DIR}/include + ${BENCHMARK_TEST_COMPILE_FLAGS} + -Wno-user-defined-literals +) +set(BENCHMARK_TEST_LIBCXX_LINK_FLAGS + -nodefaultlibs + -L${BENCHMARK_LIBCXX_INSTALL}/lib/ +) +set(BENCHMARK_TEST_NATIVE_COMPILE_FLAGS + ${BENCHMARK_NATIVE_TARGET_FLAGS} + ${BENCHMARK_TEST_COMPILE_FLAGS} +) +set(BENCHMARK_TEST_NATIVE_LINK_FLAGS + ${BENCHMARK_NATIVE_TARGET_FLAGS} + -L${BENCHMARK_NATIVE_INSTALL}/lib +) +split_list(BENCHMARK_TEST_COMPILE_FLAGS) +split_list(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS) +split_list(BENCHMARK_TEST_LIBCXX_LINK_FLAGS) +split_list(BENCHMARK_TEST_NATIVE_COMPILE_FLAGS) +split_list(BENCHMARK_TEST_NATIVE_LINK_FLAGS) +macro(add_benchmark_test name source_file) + set(libcxx_target ${name}_libcxx) + add_executable(${libcxx_target} EXCLUDE_FROM_ALL ${source_file}) + add_dependencies(${libcxx_target} cxx google-benchmark-libcxx) + add_dependencies(cxx-benchmarks ${libcxx_target}) + if (LIBCXX_ENABLE_SHARED) + target_link_libraries(${libcxx_target} cxx_shared) + else() + target_link_libraries(${libcxx_target} cxx_static) + endif() + if (TARGET cxx_experimental) + target_link_libraries(${libcxx_target} cxx_experimental) + endif() + target_link_libraries(${libcxx_target} -lbenchmark) + set_target_properties(${libcxx_target} + PROPERTIES + OUTPUT_NAME "${name}.libcxx.out" + RUNTIME_OUTPUT_DIRECTORY "${BENCHMARK_OUTPUT_DIR}" + COMPILE_FLAGS "${BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS}" + LINK_FLAGS "${BENCHMARK_TEST_LIBCXX_LINK_FLAGS}") + if (LIBCXX_BENCHMARK_NATIVE_STDLIB) + set(native_target ${name}_native) + add_executable(${native_target} EXCLUDE_FROM_ALL ${source_file}) + add_dependencies(${native_target} google-benchmark-native + google-benchmark-libcxx) + target_link_libraries(${native_target} -lbenchmark) + if (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++") + target_link_libraries(${native_target} -lstdc++fs) + elseif (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libc++") + target_link_libraries(${native_target} -lc++experimental) + endif() + if (LIBCXX_HAS_PTHREAD_LIB) + target_link_libraries(${native_target} -pthread) + endif() + add_dependencies(cxx-benchmarks ${native_target}) + set_target_properties(${native_target} + PROPERTIES + OUTPUT_NAME "${name}.native.out" + RUNTIME_OUTPUT_DIRECTORY "${BENCHMARK_OUTPUT_DIR}" + INCLUDE_DIRECTORIES "" + COMPILE_FLAGS "${BENCHMARK_TEST_NATIVE_COMPILE_FLAGS}" + LINK_FLAGS "${BENCHMARK_TEST_NATIVE_LINK_FLAGS}") + endif() +endmacro() + + +#============================================================================== +# Register Benchmark tests +#============================================================================== +file(GLOB BENCHMARK_TESTS "*.bench.cpp") +foreach(test_path ${BENCHMARK_TESTS}) + get_filename_component(test_file "${test_path}" NAME) + string(REPLACE ".bench.cpp" "" test_name "${test_file}") + if (NOT DEFINED ${test_name}_REPORTED) + message(STATUS "Adding Benchmark: ${test_file}") + # Only report the adding of the benchmark once. + set(${test_name}_REPORTED ON CACHE INTERNAL "") + endif() + add_benchmark_test(${test_name} ${test_file}) +endforeach() diff --git a/lib/libcxx/benchmarks/ContainerBenchmarks.hpp b/lib/libcxx/benchmarks/ContainerBenchmarks.hpp new file mode 100644 index 00000000000..dc268e7ebca --- /dev/null +++ b/lib/libcxx/benchmarks/ContainerBenchmarks.hpp @@ -0,0 +1,113 @@ +#ifndef BENCHMARK_CONTAINER_BENCHMARKS_HPP +#define BENCHMARK_CONTAINER_BENCHMARKS_HPP + +#include + +#include "benchmark/benchmark_api.h" + +namespace ContainerBenchmarks { + + +template +void BM_ConstructIterIter(benchmark::State& st, Container, GenInputs gen) { + auto in = gen(st.range(0)); + const auto begin = in.begin(); + const auto end = in.end(); + benchmark::DoNotOptimize(&in); + while (st.KeepRunning()) { + Container c(begin, end); + benchmark::DoNotOptimize(c.data()); + } +} + +template +void BM_InsertValue(benchmark::State& st, Container c, GenInputs gen) { + auto in = gen(st.range(0)); + const auto end = in.end(); + while (st.KeepRunning()) { + c.clear(); + for (auto it = in.begin(); it != end; ++it) { + benchmark::DoNotOptimize(&(*c.insert(*it).first)); + } + benchmark::ClobberMemory(); + } +} + +template +void BM_InsertValueRehash(benchmark::State& st, Container c, GenInputs gen) { + auto in = gen(st.range(0)); + const auto end = in.end(); + while (st.KeepRunning()) { + c.clear(); + c.rehash(16); + for (auto it = in.begin(); it != end; ++it) { + benchmark::DoNotOptimize(&(*c.insert(*it).first)); + } + benchmark::ClobberMemory(); + } +} + + +template +void BM_InsertDuplicate(benchmark::State& st, Container c, GenInputs gen) { + auto in = gen(st.range(0)); + const auto end = in.end(); + c.insert(in.begin(), in.end()); + benchmark::DoNotOptimize(&c); + benchmark::DoNotOptimize(&in); + while (st.KeepRunning()) { + for (auto it = in.begin(); it != end; ++it) { + benchmark::DoNotOptimize(&(*c.insert(*it).first)); + } + benchmark::ClobberMemory(); + } +} + + +template +void BM_EmplaceDuplicate(benchmark::State& st, Container c, GenInputs gen) { + auto in = gen(st.range(0)); + const auto end = in.end(); + c.insert(in.begin(), in.end()); + benchmark::DoNotOptimize(&c); + benchmark::DoNotOptimize(&in); + while (st.KeepRunning()) { + for (auto it = in.begin(); it != end; ++it) { + benchmark::DoNotOptimize(&(*c.emplace(*it).first)); + } + benchmark::ClobberMemory(); + } +} + +template +static void BM_Find(benchmark::State& st, Container c, GenInputs gen) { + auto in = gen(st.range(0)); + c.insert(in.begin(), in.end()); + benchmark::DoNotOptimize(&(*c.begin())); + const auto end = in.data() + in.size(); + while (st.KeepRunning()) { + for (auto it = in.data(); it != end; ++it) { + benchmark::DoNotOptimize(&(*c.find(*it))); + } + benchmark::ClobberMemory(); + } +} + +template +static void BM_FindRehash(benchmark::State& st, Container c, GenInputs gen) { + c.rehash(8); + auto in = gen(st.range(0)); + c.insert(in.begin(), in.end()); + benchmark::DoNotOptimize(&(*c.begin())); + const auto end = in.data() + in.size(); + while (st.KeepRunning()) { + for (auto it = in.data(); it != end; ++it) { + benchmark::DoNotOptimize(&(*c.find(*it))); + } + benchmark::ClobberMemory(); + } +} + +} // end namespace ContainerBenchmarks + +#endif // BENCHMARK_CONTAINER_BENCHMARKS_HPP diff --git a/lib/libcxx/benchmarks/GenerateInput.hpp b/lib/libcxx/benchmarks/GenerateInput.hpp new file mode 100644 index 00000000000..9d5adac4af4 --- /dev/null +++ b/lib/libcxx/benchmarks/GenerateInput.hpp @@ -0,0 +1,142 @@ +#ifndef BENCHMARK_GENERATE_INPUT_HPP +#define BENCHMARK_GENERATE_INPUT_HPP + +#include +#include +#include +#include +#include +#include + +static const char Letters[] = { + '0','1','2','3','4', + '5','6','7','8','9', + 'A','B','C','D','E','F', + 'G','H','I','J','K', + 'L','M','N','O','P', + 'Q','R','S','T','U', + 'V','W','X','Y','Z', + 'a','b','c','d','e','f', + 'g','h','i','j','k', + 'l','m','n','o','p', + 'q','r','s','t','u', + 'v','w','x','y','z' +}; +static const std::size_t LettersSize = sizeof(Letters); + +inline std::default_random_engine& getRandomEngine() { + static std::default_random_engine RandEngine(std::random_device{}()); + return RandEngine; +} + +inline char getRandomChar() { + std::uniform_int_distribution<> LettersDist(0, LettersSize-1); + return Letters[LettersDist(getRandomEngine())]; +} + +template +inline IntT getRandomInteger() { + std::uniform_int_distribution dist; + return dist(getRandomEngine()); +} + +inline std::string getRandomString(std::size_t Len) { + std::string str(Len, 0); + std::generate_n(str.begin(), Len, &getRandomChar); + return str; +} + +template +inline std::vector getDuplicateIntegerInputs(size_t N) { + std::vector inputs(N, static_cast(-1)); + return inputs; +} + +template +inline std::vector getSortedIntegerInputs(size_t N) { + std::vector inputs; + for (size_t i=0; i < N; i += 1) + inputs.push_back(i); + return inputs; +} + +template +std::vector getSortedLargeIntegerInputs(size_t N) { + std::vector inputs; + for (size_t i=0; i < N; ++i) { + inputs.push_back(i + N); + } + return inputs; +} + +template +std::vector getSortedTopBitsIntegerInputs(size_t N) { + std::vector inputs = getSortedIntegerInputs(N); + for (auto& E : inputs) E <<= ((sizeof(IntT) / 2) * CHAR_BIT); + return inputs; +} + +template +inline std::vector getReverseSortedIntegerInputs(size_t N) { + std::vector inputs; + std::size_t i = N; + while (i > 0) { + --i; + inputs.push_back(i); + } + return inputs; +} + +template +std::vector getPipeOrganIntegerInputs(size_t N) { + std::vector v; v.reserve(N); + for (size_t i = 0; i < N/2; ++i) v.push_back(i); + for (size_t i = N/2; i < N; ++i) v.push_back(N - i); + return v; +} + + +template +std::vector getRandomIntegerInputs(size_t N) { + std::vector inputs; + for (size_t i=0; i < N; ++i) { + inputs.push_back(getRandomInteger()); + } + return inputs; +} + +inline std::vector getDuplicateStringInputs(size_t N) { + std::vector inputs(N, getRandomString(1024)); + return inputs; +} + +inline std::vector getRandomStringInputs(size_t N) { + std::vector inputs; + for (size_t i=0; i < N; ++i) { + inputs.push_back(getRandomString(1024)); + } + return inputs; +} + +inline std::vector getSortedStringInputs(size_t N) { + std::vector inputs = getRandomStringInputs(N); + std::sort(inputs.begin(), inputs.end()); + return inputs; +} + +inline std::vector getReverseSortedStringInputs(size_t N) { + std::vector inputs = getSortedStringInputs(N); + std::reverse(inputs.begin(), inputs.end()); + return inputs; +} + +inline std::vector getRandomCStringInputs(size_t N) { + static std::vector inputs = getRandomStringInputs(N); + std::vector cinputs; + for (auto const& str : inputs) + cinputs.push_back(str.c_str()); + return cinputs; +} + + +#endif // BENCHMARK_GENERATE_INPUT_HPP diff --git a/lib/libcxx/benchmarks/algorithms.bench.cpp b/lib/libcxx/benchmarks/algorithms.bench.cpp new file mode 100644 index 00000000000..745cc172718 --- /dev/null +++ b/lib/libcxx/benchmarks/algorithms.bench.cpp @@ -0,0 +1,62 @@ +#include +#include +#include + +#include "benchmark/benchmark_api.h" +#include "GenerateInput.hpp" + +constexpr std::size_t TestNumInputs = 1024; + +template +void BM_Sort(benchmark::State& st, GenInputs gen) { + using ValueType = typename decltype(gen(0))::value_type; + const auto in = gen(st.range(0)); + std::vector inputs[5]; + auto reset_inputs = [&]() { + for (auto& C : inputs) { + C = in; + benchmark::DoNotOptimize(C.data()); + } + }; + reset_inputs(); + while (st.KeepRunning()) { + for (auto& I : inputs) { + std::sort(I.data(), I.data() + I.size()); + benchmark::DoNotOptimize(I.data()); + } + st.PauseTiming(); + reset_inputs(); + benchmark::ClobberMemory(); + st.ResumeTiming(); + } +} + +BENCHMARK_CAPTURE(BM_Sort, random_uint32, + getRandomIntegerInputs)->Arg(TestNumInputs); + +BENCHMARK_CAPTURE(BM_Sort, sorted_ascending_uint32, + getSortedIntegerInputs)->Arg(TestNumInputs); + +BENCHMARK_CAPTURE(BM_Sort, sorted_descending_uint32, + getReverseSortedIntegerInputs)->Arg(TestNumInputs); + +BENCHMARK_CAPTURE(BM_Sort, single_element_uint32, + getDuplicateIntegerInputs)->Arg(TestNumInputs); + +BENCHMARK_CAPTURE(BM_Sort, pipe_organ_uint32, + getPipeOrganIntegerInputs)->Arg(TestNumInputs); + +BENCHMARK_CAPTURE(BM_Sort, random_strings, + getRandomStringInputs)->Arg(TestNumInputs); + +BENCHMARK_CAPTURE(BM_Sort, sorted_ascending_strings, + getSortedStringInputs)->Arg(TestNumInputs); + +BENCHMARK_CAPTURE(BM_Sort, sorted_descending_strings, + getReverseSortedStringInputs)->Arg(TestNumInputs); + +BENCHMARK_CAPTURE(BM_Sort, single_element_strings, + getDuplicateStringInputs)->Arg(TestNumInputs); + + +BENCHMARK_MAIN() diff --git a/lib/libcxx/benchmarks/filesystem.bench.cpp b/lib/libcxx/benchmarks/filesystem.bench.cpp new file mode 100644 index 00000000000..f7949a163a7 --- /dev/null +++ b/lib/libcxx/benchmarks/filesystem.bench.cpp @@ -0,0 +1,138 @@ +#include + +#include "benchmark/benchmark_api.h" +#include "GenerateInput.hpp" +#include "test_iterators.h" + +namespace fs = std::experimental::filesystem; + +static const size_t TestNumInputs = 1024; + + +template +void BM_PathConstructString(benchmark::State &st, GenInputs gen) { + using namespace fs; + const auto in = gen(st.range(0)); + path PP; + for (auto& Part : in) + PP /= Part; + benchmark::DoNotOptimize(PP.native().data()); + while (st.KeepRunning()) { + const path P(PP.native()); + benchmark::DoNotOptimize(P.native().data()); + } +} +BENCHMARK_CAPTURE(BM_PathConstructString, large_string, + getRandomStringInputs)->Arg(TestNumInputs); + + +template +void BM_PathConstructCStr(benchmark::State &st, GenInputs gen) { + using namespace fs; + const auto in = gen(st.range(0)); + path PP; + for (auto& Part : in) + PP /= Part; + benchmark::DoNotOptimize(PP.native().data()); + while (st.KeepRunning()) { + const path P(PP.native().c_str()); + benchmark::DoNotOptimize(P.native().data()); + } +} +BENCHMARK_CAPTURE(BM_PathConstructCStr, large_string, + getRandomStringInputs)->Arg(TestNumInputs); + + +template