Reland "Actually build libc++ and libc++abi with -std=c++20"

This is a reland of d95d20a3f7cc630e324e706c0a2bd405792283c4
https://chromium-review.googlesource.com/c/chromium/src/+/3497608
fixed the Mac/debug test failure.

Original change's description:
> Actually build libc++ and libc++abi with -std=c++20
>
> build/config/compiler/BUILD.gn adds the flag to cflags_cc, so this
> config here must do that too. Else the -std=c++20 will show up
> on the commandline _before_ the -std=c++17 added by
> build/config/compiler:compiler, rendering it ineffective.
>
> Bug: 1298070
> Change-Id: I145b04aeef1003620594a0be8f74bb7731797069
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3469402
> Commit-Queue: Nico Weber <thakis@chromium.org>
> Auto-Submit: Nico Weber <thakis@chromium.org>
> Reviewed-by: Arthur Eubanks <aeubanks@google.com>
> Commit-Queue: Arthur Eubanks <aeubanks@google.com>
> Cr-Commit-Position: refs/heads/main@{#972250}

Bug: 1298070
Change-Id: I03e4c4978aceba73868704f6e019702e7772723a
Cq-Include-Trybots: luci.chromium.try:gpu-try-mac-intel-dbg
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3485017
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: Arthur Eubanks <aeubanks@google.com>
Commit-Queue: Arthur Eubanks <aeubanks@google.com>
Cr-Commit-Position: refs/heads/main@{#976946}
NOKEYCHECK=True
GitOrigin-RevId: d478debaaefae8c15ab83e666f4823de164162b8
diff --git a/third_party/libc++/BUILD.gn b/third_party/libc++/BUILD.gn
index 7915346..dec348e 100644
--- a/third_party/libc++/BUILD.gn
+++ b/third_party/libc++/BUILD.gn
@@ -14,17 +14,17 @@
       # libc++ wants to redefine the macros WIN32_LEAN_AND_MEAN and _CRT_RAND_S
       # in its implementation.
       "-Wno-macro-redefined",
+    ]
 
+    cflags_cc = [
       # We want to use a uniform C++ version across all of chromium, but
       # upstream libc++ requires C++20 so we have to make an exception here.
       # No other target should override the default -std= flag.
       "-std:c++20",
     ]
   } else {
-    cflags += [
-      "-fPIC",
-      "-std=c++20",
-    ]
+    cflags += [ "-fPIC" ]
+    cflags_cc = [ "-std=c++20" ]
   }
 
   defines = [ "_LIBCPP_BUILDING_LIBRARY" ]
@@ -130,11 +130,13 @@
     "//build/config/compiler:no_rtti",
     "//build/config/coverage:default_coverage",
   ]
-  if (is_android && libcxx_is_shared) {
+  if ((is_android || is_apple) && libcxx_is_shared) {
     # Use libc++_chrome to avoid conflicting with system libc++
-    # See crbug.com/1076244#c11 for more detail.
     output_name = "libc++_chrome"
-    configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
+    if (is_android) {
+      # See crbug.com/1076244#c11 for more detail.
+      configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
+    }
   }
   configs += [
     ":config",