Reland "Roll src/buildtools/third_party/libc++/trunk/ 79a2e924d..b1269813e (1399 commits)"

This is a reland of 3a28cd7fbcbf1e58c88c3ac756eaef69d0676eda

Changes:
* Add some additional tryjobs
* Disable debug mode when using LTO as it seems to break with
  https://reviews.llvm.org/D103964 (https://crbug.com/1327706)
* Define _LIBCPP_ABI_NAMESPACE for Windows to resolve a PDB size issue
  (http://crbug.com/1327710).

Original change's description:
> Revert "Roll src/buildtools/third_party/libc++/trunk/
> 79a2e924d..b1269813e (1399 commits)"
>
> This reverts commit 3a28cd7fbcbf1e58c88c3ac756eaef69d0676eda.
>
> Reason for revert:
> Findit (https://goo.gl/kROfz5) identified this CL at revision
> 3a28cd7fbcbf1e58c88c3ac756eaef69d0676eda as
> the culprit for failures in the continuous build including:
>
> Sample Failed Build: https://ci.chromium.org/b/8813722331991050449
> Sample Failed Step: compile
>
> If it is a false positive, please report it at
> https://bugs.chromium.org/p/chromium/issues/entry?status=Available&comment=Datastore+key+for+the+culprit+entity%3A+chromium.googlesource.com%2Fchromium%2Fsrc%2Frefs%2Fheads%2Fmain%2F3a28cd7fbcbf1e58c88c3ac756eaef69d0676eda&labels=Test-Findit-Wrong&components=Tools%3ETest%3EFindIt&summary=Wrongly+blame+3a28cd7fbcbf1e58c88c3ac756eaef69d0676eda
>
> Original change's description:
> > Roll src/buildtools/third_party/libc++/trunk/ 79a2e924d..b1269813e
> (1399 commits)
> >
> > Notes:
> >
> > We deliberately roll libc++ to b1269813eaf5 (~1.5 months old at the
> time
> > of this commit) rather than the latest version of libc++ in order to
> > deliberately avoid https://reviews.llvm.org/D122982, which causes a
> > potentially disruptive performance regression in Chrome
> > (https://crbug.com/1322961). https://reviews.llvm.org/D124328 is
> > supposed to fix this issue, so once that lands in libc++, we'll roll
> > past it again.
> >
> > Additional changes made to get this CL to pass presubmits:
> >
> > * Set _LIBCPP_ABI_VERSION=2 and _LIBCPP_ABI_NAMESPACE due to
> >   _LIBCPP_ABI_UNSTABLE being removed in
> >   https://reviews.llvm.org/D119173.
> > * Regenerate gvr-android-sdk prebuilts.
> > * Updates to libc++'s BUILD.gn to handle new files in libc++.
> > * Update check_static_initializers.py test since init_priority was
> >   changed from 101 to 100 in https://reviews.llvm.org/D95972.
> > * Miscellaneous increments to #pragma clang_max_tokens_here.
> >
> >
> https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git/+log/79a2e924d96e..b1269813eaf5
> >
> > $ git log 79a2e924d..b1269813e --date=short --no-merges --format='%ad
> %ae %s'
> > 2022-03-23 ldionne.2 [libc++] Correct outdated documentation about
> __config_site
> > 2022-03-23 ldionne.2 [libc++][NFC] Change availability macro from
> macosx to macos
> > 2022-03-23 ldionne.2 [libc++][NFC] Fix include guards and add a
> missing license header
> > 2022-03-23 danny.moesch Replace links to archived mailing lists by
> links to Discourse forums
> > 2022-03-22 ldionne.2 [libc++][NFC] Slight improvement to
> __availability documentation
> > 2022-03-22 ldionne.2 [libc++][NFC] Use struct instead of class for
> ranges::end
> > 2022-03-21 phosek Revert "[bootstrap] Allow passing options to
> sub-builds for all targets"
> > 2022-03-21 ldionne.2 [libc++] Re-enable workaround for pre-ranges CTAD
> in std::span
> > 2022-03-16 ldionne.2 [bootstrap] Allow passing options to sub-builds
> for all targets
> > 2022-03-21 zarko [libc++][AIX] AIX allows for changing permissions of
> symlinks
> > 2022-03-21 ldionne.2 [libc++] Trigger CI when cmake/ is modified
> > 2022-03-18 ldionne.2 [libunwind] Add libunwind to the bootstrapping
> build CI
> > 2022-03-21 ldionne.2 [libc++] Disable modules with the bootstrapping
> build
> > 2022-03-07 martin [libcxx] [ci] Check that Windows static libraries
> don't contain dllexports
> > 2022-03-20 koraq [libc++][test][NFC] Remove libcpp-no-concepts.
> > 2022-03-10 nikolasklauser [libc++] Prepare string tests for constexpr
> > 2022-03-03 koraq [libc++][test] Improves handle formatter.
> > 2022-03-08 nikolasklauser [libc++] Enable modernize-loop-convert
> > 2022-03-18 ashermancinelli [libc++] Make shared_ptr move unique_ptr's
> deleter
> > 2022-03-18 nikolasklauser [libc++][ranges] Implement ranges::min
> > 2022-03-17 varconst [libc++][ranges] Implement changes to
> reverse_iterator from One Ranges Proposal.
> > 2022-03-17 nikolasklauser [libc++] [test] Add
> ranges_robust_against_copying_*.pass.cpp
> > 2022-03-17 ldionne.2 [libc++] Install psutil on CI builders
> > 2022-03-17 ldionne.2 [libc++] Add missing <cstddef> include
> > 2022-03-14 ldionne.2 [libc++] Switch to the new testing configurations
> by default
> > 2022-03-17 david.spickett Revert "[libcxx][CI] Use temporary clang-13
> bots for Arm/AArch64"
> > 2022-03-07 nikolasklauser [libc++] Remove <utility> includes
> > 2022-03-14 nikolasklauser [libc++] Add warning pragma macros in the
> test suite
> > 2022-03-16 ldionne.2 [libc++][NFC] Reindent release notes bullet
> points
> > 2022-03-16 ldionne.2 [libc++][NFC] Rename member variables to avoid
> shadowing conflict in future patch
> > 2022-03-12 koraq [libc++][NFC] Add TEST_HAS_NO_INCOMPLETE_RANGES.
> > 2022-03-15 ldionne.2 [libc++][tests] Use CMake provided paths for
> includes and libdir instead of hardcoding them
> > 2022-03-15 ldionne.2 [libc++] Fix incorrect availability markup for
> bad_optional_access & friends
> > 2022-03-15 ldionne.2 [libc++] Do not install the C++ ABI library's
> headers as part of libc++'s build
> > 2022-03-03 ldionne.2 [libc++] Define
> _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER whenever we enable warnings in the
> test suite
> > 2022-03-14 ldionne.2 [libc++] Add workaround to avoid breaking users
> of <span> when <ranges> are disabled
> > 2022-03-15 ldionne.2 [libc++] Update URL to old libc++ dylibs
> > 2022-03-14 dimitry [libc++] Make __dir_stream visibility declaration
> consistent
> > 2022-03-07 ldionne.2 [libc++] Overhaul all tests for assertions and
> debug mode
> > 2022-03-14 ldionne.2 [libc++][NFC] Remove several redundant #if
> _LIBCPP_STD_VER > 17 in <span>
> > 2022-03-12 joeloser93 [libc++] Replace _LIBCPP_HAS_NO_CONCEPTS with
> _LIBCPP_STD_VER > 17. NFCI.
> > 2022-03-12 koraq [libc++] Remove unneeded tests.
> > 2022-03-12 koraq [libc++][NFC] Use TEST_HAS_NO_EXCEPTIONS.
> > 2022-03-12 koraq [libc++] Add a missing test case.
> > 2022-03-12 nikolasklauser [libc++][ranges] Implement ranges::find{,
> _if, _if_not}
> > 2021-08-24 ldionne.2 [libc++] Remove workaround for missing
> declarations on Windows store apps
> > 2021-08-18 ldionne.2 [libc++] Remove workaround for C11 features on
> compilers that don't support using_if_exists
> > 2022-03-08 ldionne.2 [libc++] Remove raw call to debug handler from
> __char_traits_length_checked
> > 2022-03-07 ldionne.2 [libc++] Add tests for the content of <cstddef>
> > 2022-01-27 ldionne.2 [libc++] Remove operator-> from iterator
> archetypes that don't need it
> > (...)
> > 2021-06-02 cjdb [libcxx][module-map] creates submodules for private
> headers
> > 2021-06-02 koraq [libc++][nfc] Add more nasty macros.
> > 2021-06-02 ldionne.2 [libc++] Remove unused variable warnings
> > 2021-05-08 ldionne.2 [libc++] Enable tests for the experimental
> library by default
> > 2021-06-02 ldionne.2 Revert "[libc++] NFC: Move unwrap_iter to its own
> header"
> > 2021-06-02 Daniel.McIntosh [libcxx][NFC] Tidy up calculation of __nbuf
> in num_put::do_put, and add comments
> > 2020-12-02 ldionne.2 [libc++] Add a CI job to test libc++ when
> building for 32 bit
> > 2021-05-31 ldionne.2 [libc++] NFC: Move unwrap_iter to its own header
> > 2021-06-01 z.zoelec2 [libcxx][ranges] Add `default_sentinel` and
> `default_sentinel_t`.
> > 2021-06-01 ldionne.2 [libc++] Fix the std_include.sh.cpp test that has
> been failing since c9385297ce
> > 2021-04-30 z.zoelec2 [libcxx] Implement view.interface.
> > 2021-06-01 ldionne.2 [libc++] Temporary hack to unbreak CI
> > 2021-05-28 martin [libcxx] [test] Fix the _supportsVerify check on
> Windows by fixing quoting
> > 2021-05-31 martin [libcxx] [test] Fix the include_as_c.sh.cpp test in
> MSVC configurations
> > 2021-05-31 martin [libcxx] [test] Remove an incorrect
> TEST_HAS_ALIGNED_ALLOC define from test_macros.h
> > 2021-05-31 martin [libcxx] Define LIBCPP_HAS_TIMESPEC_GET for MSVC
> configurations
> > 2021-05-28 martin [libcxx] [test] Don't look for the literal spelling
> __mbstate_t in warnings
> > 2021-05-28 cjdb [libcxx][nfc] moves std `advance`, `next`, and `prev`
> into their headers
> > 2021-05-31 harald [libc++] [test] Fix a few tests for 32-bit x86
> > 2021-05-27 ldionne.2 [libc++] Update all the pre-defined iterator
> types for C++20
> > 2021-05-29 arthur.j.odwyer [libc++] Avoid `result_type` and
> `unary/binary_function` in <valarray>.
> > 2021-05-28 martin [libcxx] [test] Add UNSUPPORTED: msvc in a couple
> verify.cpp tests
> > 2021-05-19 arthur.j.odwyer [libc++] Alphabetize and
> include-what-you-use. NFCI.
> > 2021-05-29 arthur.j.odwyer [libc++] [modules] Add __threading_support
> to the modulemap.
> > 2021-05-29 arthur.j.odwyer [libc++] [test] Update "test_compare.h"
> users to avoid removed-in-C++20 members. NFCI.
> > 2021-05-29 koraq Revert "[libc++] NFC: Move unwrap_iter to its own
> header"
> > 2021-05-28 arthur.j.odwyer [libc++] [test] Constexpr-ify a couple of
> insert-iterator tests.
> > 2021-05-28 ldionne.2 [libc++] NFC: Move unwrap_iter to its own header
> > 2021-04-28 ldionne.2 [libc++] Add all indirect callable concepts and
> projected
> > 2021-05-26 martin [libcxx] [test] Convert an XFAIL
> LIBCXX-WINDOWS-FIXME into UNSUPPORTED with explanation
> > 2021-05-27 ldionne.2 [libc++] NFC: Make it easier for vendors to
> extend the run-buildbot script
> > 2021-05-27 ldionne.2 [libc++] NFC: Refactor raw_storage_iterator test
> to use UNSUPPORTED markup
> > 2021-05-27 ldionne.2 Revert "[libc++] NFC: Parenthesize expression to
> satisfy GCC 11"
> > 2021-05-27 ldionne.2 [libc++] NFC: Parenthesize expression to satisfy
> GCC 11
> > 2021-05-25 ldionne.2 [libc++] Deprecate std::iterator and remove it as
> a base class
> > 2021-05-16 cjdb [libcxx][iterator] adds `std::ranges::prev`
> > 2021-05-08 cjdb [libcxx][iterator] adds `std::ranges::next`
> > 2021-05-26 z.zoelec2 [libcxx][nfc] Fix the ASAN bots: update
> expected.pass.cpp.
> > 2021-05-26 z.zoelec2 [libcxx][docs] Take mutex for common_iterator,
> common_view, and empty_view.
> > 2021-05-25 ldionne.2 [libc++] Add a job testing on GCC 11
> > 2021-05-18 koraq [libc++][format] Adds availability macros for
> std::format.
> > 2021-04-25 koraq [libc++][NFC] Move basic_format_parse_context to its
> own header.
> > 2021-04-25 koraq [libc++][NFC] Move format_error to its own header.
> > 2021-05-26 ldionne.2 [libc++] Fix concepts tests with GCC
> > 2021-05-05 cjdb [libcxx][iterator] adds `std::ranges::advance`
> > 2021-05-25 ldionne.2 [libc++] Install GCC 11 on CI builders
> > 2021-05-24 arthur.j.odwyer [libc++] [P0619] Hide not1 and not2 under
> _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS.
> > 2020-11-09 martin [libcxx] Fix the function name in exceptions from
> create_directories
> > 2021-05-12 martin [libcxx] [test] Explain an XFAIL
> LIBCXX-WINDOWS-FIXME and convert into UNSUPPORTED
> > 2021-05-18 martin [libcxx] Make the visibility attributes consistent
> for __narrow_to_utf8/__widen_from_utf8
> >
> > Created with:
> >   roll-dep src/buildtools/third_party/libc++/trunk
> >
> > Binary-Size: The increase is caused by
> https://reviews.llvm.org/D113413, which changed the implementation of
> std::sort(...) in libc++. This is a necessary change to keep libc++
> up-to-date.
> > Bug: 1273285
> > Change-Id: I58ced6f881493f055e9a777577cfa2eef9be38da
> > Reviewed-on:
> https://chromium-review.googlesource.com/c/chromium/src/+/3653488
> > Owners-Override: Nico Weber <thakis@chromium.org>
> > Reviewed-by: Nico Weber <thakis@chromium.org>
> > Reviewed-by: Hans Wennborg <hans@chromium.org>
> > Commit-Queue: Nico Weber <thakis@chromium.org>
> > Cr-Commit-Position: refs/heads/main@{#1005258}
>
>
> Change-Id: I2154b5453f72bc9a9a209fc789750a642996ecdd
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: 1273285
> Reviewed-on:
> https://chromium-review.googlesource.com/c/chromium/src/+/3655381
> Owners-Override: Ella Ge <eirage@google.com>
> Reviewed-by: Ella Ge <eirage@chromium.org>
> Commit-Queue: Ella Ge <eirage@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1005272}

Binary-Size: The increase is caused by https://reviews.llvm.org/D113413, which changed the implementation of std::sort(...) in libc++. This is a necessary change to keep libc++ up-to-date.
Cq-Include-Trybots: chromium/try:android-asan
Cq-Include-Trybots: chromium/try:chromeos-amd64-generic-cfi-thin-lto-rel
Cq-Include-Trybots: chromium/try:dawn-win10-x86-deps-rel
Cq-Include-Trybots: chromium/try:linux-chromeos-dbg
Cq-Include-Trybots: chromium/try:linux_chromium_cfi_rel_ng
Cq-Include-Trybots: chromium/try:linux_chromium_chromeos_msan_rel_ng
Cq-Include-Trybots: chromium/try:linux_chromium_msan_rel_ng
Cq-Include-Trybots: chromium/try:mac11-arm64-rel,mac_chromium_asan_rel_ng
Cq-Include-Trybots: chromium/try:win-asan,win7-rel
Cq-Include-Trybots: chromium/try:android-official,fuchsia-official
Cq-Include-Trybots: chromium/try:mac-official,linux-official
Cq-Include-Trybots: chromium/try:win-official,win32-official
Cq-Include-Trybots: chromium/try:linux-swangle-try-x64,win-swangle-try-x86
Cq-Include-Trybots: chrome/try:linux-chromeos-chrome
Cq-Include-Trybots: chrome/try:win-chrome,win64-chrome,linux-chrome,mac-chrome
Cq-Include-Trybots: chrome/try:linux-pgo,mac-pgo,win32-pgo,win64-pgo
Bug: 1273285
Change-Id: I9b371d51c0a7baf0107d13cf21fb5cfbe4fb1b0d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3655638
Owners-Override: Nico Weber <thakis@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Alan Zhao <ayzhao@google.com>
Cr-Commit-Position: refs/heads/main@{#1007702}
NOKEYCHECK=True
GitOrigin-RevId: 1558f8d76b6874f2c5159293923b519d8a58d885
diff --git a/c++/BUILD.gn b/c++/BUILD.gn
index 046792a..2e5843b 100644
--- a/c++/BUILD.gn
+++ b/c++/BUILD.gn
@@ -1,6 +1,7 @@
 import("//build/config/c++/c++.gni")
 import("//build/config/chrome_build.gni")
 import("//build/config/chromeos/ui_mode.gni")
+import("//build/config/compiler/compiler.gni")
 import("//build/config/dcheck_always_on.gni")
 import("//buildtools/deps_revisions.gni")
 
@@ -26,23 +27,23 @@
   ldflags = []
   libs = []
 
+  # We set a custom _LIBCPP_ABI_NAMESPACE for the following reasons:
+  #
+  # 1. When libcxx_is_shared is true, symbols from libc++.so are exported for
+  #    all DSOs to use.  If the system libc++ gets loaded (indirectly through
+  #    a system library), then it will conflict with our libc++.so.
+  # 2. The default value of _LIBCPP_ABI_NAMESPACE is the string
+  #    "_LIBCPP_ABI_NAMESPACE". This contributes to an increase in binary size;
+  #    on Windows, the increase is great enough that we go above the 4GB size
+  #    limit for PDBs (https://crbug.com/1327710#c5). To fix this, we set
+  #    _LIBCPP_ABI_NAMESPACE to a shorter value.
+  defines += [ "_LIBCPP_ABI_NAMESPACE=Cr" ]
+
   if (libcxx_abi_unstable) {
-    defines += [ "_LIBCPP_ABI_UNSTABLE" ]
+    defines += [ "_LIBCPP_ABI_VERSION=2" ]
   }
 
-  if (libcxx_is_shared) {
-    # When libcxx_is_shared is true, symbols from libc++.so are exported for
-    # all DSOs to use.  If the system libc++ gets loaded (indirectly through
-    # a system library), then it will conflict with our libc++.so.  Add a
-    # custom ABI version if we're building with _LIBCPP_ABI_UNSTABLE to avoid
-    # conflicts.
-    #
-    # Windows doesn't need to set _LIBCPP_ABI_VERSION since there's no system
-    # C++ library we could conflict with.
-    if (libcxx_abi_unstable && !is_win) {
-      defines += [ "_LIBCPP_ABI_VERSION=Cr" ]
-    }
-  } else {
+  if (!libcxx_is_shared) {
     # Don't leak any symbols on a static build.
     defines += [ "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS" ]
     if (!export_libcxxabi_from_executables && !is_win) {
@@ -63,7 +64,11 @@
   # The Windows component build fails to link with libc++'s debug mode. See
   # https://crbug.com/923166#c33, https://crbug.com/923166#c44, and
   # https://llvm.org/PR41018.
-  if (!(is_win && is_component_build)) {
+  #
+  # TODO(https://crbug.com/1327706): Figure out why thinlto builds fail to link
+  # with libc++'s debug mode after https://reviews.llvm.org/D103964, and then
+  # remove the !use_thin_lto`)
+  if (!(is_win && is_component_build) && !use_thin_lto) {
     # libc++ has two levels of debug mode. Setting _LIBCPP_DEBUG to zero
     # enables most assertions. Setting it to one additionally enables iterator
     # debugging. See https://libcxx.llvm.org/docs/DesignDocs/DebugMode.html