[gn build] Make libcxx_enable_debug_mode work better, maybe
authorNico Weber <thakis@chromium.org>
Tue, 15 Nov 2022 15:40:34 +0000 (10:40 -0500)
committerNico Weber <thakis@chromium.org>
Tue, 15 Nov 2022 15:45:41 +0000 (10:45 -0500)
Refer to _LIBCPP_ENABLE_DEBUG_MODE instead of the old _LIBCPP_DEBUG
in a comment, and write that to __config_site correctly too.

See 13ea1343231fa4 and the comments in https://crbug.com/1358646.

Also change the default of libcxx_enable_debug_mode to false for now.
Since we used to not write _LIBCPP_ENABLE_DEBUG_MODE, the previous
default of true had no effect (except for compiling debug.cpp and
legacy_debug_handler.cpp, which we now no longer build by default).
So this (mostly) preserves previous behavior.

llvm/utils/gn/secondary/libcxx/config.gni
llvm/utils/gn/secondary/libcxx/include/BUILD.gn
llvm/utils/gn/secondary/libcxx/src/BUILD.gn

index 9e49db1..dddff29 100644 (file)
@@ -4,4 +4,8 @@ declare_args() {
 
   # libc++ inline ABI namespace. Defaults to __n, where n is the ABI version.
   libcxx_abi_namespace = ""
+
+  # Whether to support libc++ opt-in debug mode via _LIBCPP_ENABLE_DEBUG_MODE.
+  libcxx_enable_debug_mode = false
+
 }
index e7976a0..e085c4c 100644 (file)
@@ -37,7 +37,6 @@ if (current_toolchain == default_toolchain) {
       "_LIBCPP_HAS_NO_WIDE_CHARACTERS=",
       "_LIBCPP_ABI_DEFINES=",
       "_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=",
-      "_LIBCPP_ENABLE_DEBUG_MODE=",
     ]
     if (libcxx_abi_version != 1) {
       values += [ "_LIBCPP_ABI_VERSION=$libcxx_abi_version" ]
@@ -49,6 +48,11 @@ if (current_toolchain == default_toolchain) {
     } else {
       values += [ "_LIBCPP_ABI_NAMESPACE=__" + libcxx_abi_version ]
     }
+    if (libcxx_enable_debug_mode) {
+      values += [ "_LIBCPP_ENABLE_DEBUG_MODE=1" ]
+    } else {
+      values += [ "_LIBCPP_ENABLE_DEBUG_MODE=" ]
+    }
   }
 
   write_cmake_config("write_modulemap") {
index 5dd6aaa..cdad986 100644 (file)
@@ -3,9 +3,6 @@ import("//libcxx/config.gni")
 import("//llvm/utils/gn/build/symlink_or_copy.gni")
 
 declare_args() {
-  # Whether to support libc++ opt-in debug mode via _LIBCPP_DEBUG.
-  libcxx_enable_debug_mode = true
-
   # Build libc++ with definitions for operator new/delete.
   libcxx_enable_new_delete_definitions = true