sys_prop: add a flag to enable large sys prop node only for internal
builds

Use a soong config var to control if we should use a large sys prop node
size. Node in prop_area.cpp, the PA_SIZE is controlled by a macro flag.
This macro flag is passed in as a compiler flag which is then added when
the soong configure variable (large_system_property_node) is true.

The sooong configure variable is then backed by a build system flag
defined in build/release/build_flags.scl. The value of this flag is then
determined by different release configurations. Only internal build
release configuration would set this flag to true.

Bug: b/316932568
Change-Id: Ibe2ffda9155246f2217aaa0e7d589ed7effec311
diff --git a/libc/system_properties/Android.bp b/libc/system_properties/Android.bp
index a9bdeb5..8a8d23c 100644
--- a/libc/system_properties/Android.bp
+++ b/libc/system_properties/Android.bp
@@ -10,7 +10,10 @@
 
 cc_library_static {
     name: "libsystemproperties",
-    defaults: ["libc_defaults"],
+    defaults: [
+        "libc_defaults",
+        "large_system_property_node_defaults",
+    ],
     native_bridge_supported: true,
     srcs: [
         "context_node.cpp",
@@ -53,3 +56,28 @@
         "libasync_safe",
     ],
 }
+
+soong_config_module_type {
+    name: "large_system_property_node_cc_defaults",
+    module_type: "cc_defaults",
+    config_namespace: "bionic",
+    bool_variables: [
+        "large_system_property_node",
+    ],
+    properties: [
+        "cflags",
+    ],
+}
+
+soong_config_bool_variable {
+    name: "large_system_property_node",
+}
+
+large_system_property_node_cc_defaults {
+    name: "large_system_property_node_defaults",
+    soong_config_variables: {
+        large_system_property_node: {
+            cflags: ["-DLARGE_SYSTEM_PROPERTY_NODE=1"]
+        }
+    }
+}
diff --git a/libc/system_properties/prop_area.cpp b/libc/system_properties/prop_area.cpp
index 4668eed..a816a38 100644
--- a/libc/system_properties/prop_area.cpp
+++ b/libc/system_properties/prop_area.cpp
@@ -41,7 +41,11 @@
 
 #include <async_safe/log.h>
 
+#ifdef LARGE_SYSTEM_PROPERTY_NODE
+constexpr size_t PA_SIZE = 1024 * 1024;
+#else
 constexpr size_t PA_SIZE = 128 * 1024;
+#endif
 constexpr uint32_t PROP_AREA_MAGIC = 0x504f5250;
 constexpr uint32_t PROP_AREA_VERSION = 0xfc6ed0ab;
 
diff --git a/tests/Android.bp b/tests/Android.bp
index a53418a..1a0dec3 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -371,7 +371,10 @@
 
 cc_test_library {
     name: "libBionicStandardTests",
-    defaults: ["bionic_tests_defaults"],
+    defaults: [
+        "bionic_tests_defaults",
+        "large_system_property_node_defaults",
+    ],
     tidy_disabled_srcs: [
         "malloc_test.cpp", // timed out with clang-tidy, and too many warnings
     ],
diff --git a/tests/system_properties_test.cpp b/tests/system_properties_test.cpp
index 0b7f5ae..f11f509 100644
--- a/tests/system_properties_test.cpp
+++ b/tests/system_properties_test.cpp
@@ -593,7 +593,13 @@
   ASSERT_TRUE(system_properties.valid());
 
   auto name = "ro.super_long_property"s;
+
+#ifdef LARGE_SYSTEM_PROPERTY_NODE
+  auto value = std::string(1024 * 1024 + 1, 'x');
+#else
   auto value = std::string(128 * 1024 + 1, 'x');
+#endif
+
   ASSERT_NE(0, system_properties.Add(name.c_str(), name.size(), value.c_str(), value.size()));
 
 #else   // __BIONIC__