chromium/chrome/android/static_initializers.gni

# Copyright 2017 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/features.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//components/optimization_guide/features.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//ui/gl/features.gni")

# The check_chrome_static_initializers target will cause release bots to fail if
# the count of static initializers change in either direction. Please try not to
# increase the numbers. If they come from third-party code, please try to update
# the code, or apply a local modification to remove them.
#
# Some helpful hints at //docs/static_initializers.md
if (proprietary_codecs && !is_debug && !is_component_build) {
  # Comments show static_initializers according to
  # tools/linux/dump-static-initializers.py.
  _chrome_common_count = 0
  _chrome_64only_count = 0

  # 64bit only:
  # Caused by "outline atomics". https://crbug.com/1272795
  # cpu_model.c: init_have_lse_atomics, init_cpu_features
  _chrome_64only_count += 2

  # iostream.cpp: _GLOBAL__I_000101
  _chrome_common_count += 1

  # v8/src/parsing/token.cc: _GLOBAL__sub_I_token.cc
  _chrome_common_count += 1

  if (use_clang_coverage) {
    # InstrProfilingRuntime.cpp, Only in coverage builds, not production.
    _chrome_common_count += 1
  }

  # Define expectations only for GN args covered by android-binary-size trybot.
  if ((target_cpu == "arm" && !is_high_end_android) ||
      (target_cpu == "arm64" && !is_high_end_android_secondary_toolchain)) {
    expected_static_initializer_32bit_count = _chrome_common_count
  }
  if (target_cpu == "arm64" && is_high_end_android) {
    expected_static_initializer_64bit_count =
        _chrome_common_count + _chrome_64only_count
  }
}