0

Disable the -Wmax-tokens experiment

It appears to be doing more harm than good at this point, and in the
meantime we've gained better tools to analyze and track the include
graph. Let's see how things develop with this turned off.

Bug: 1348349, 1049569
Change-Id: Ifa633c27b71db905ff95727f9010725313b2b4f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3804719
Owners-Override: Nico Weber <thakis@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Hans Wennborg <hans@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1030542}
This commit is contained in:
Hans Wennborg
2022-08-02 14:44:58 +00:00
committed by Chromium LUCI CQ
parent 562879787a
commit ed2126e643
28 changed files with 27 additions and 215 deletions

@ -4,15 +4,6 @@
#include "base/allocator/partition_allocator/partition_alloc_base/check.h"
#include "build/build_config.h"
// check.h is a widely included header and its size has significant impact on
// build time. Try not to raise this limit unless absolutely necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 17000
#endif
#include "base/allocator/partition_allocator/partition_alloc_base/logging.h"
#include "build/build_config.h"

@ -4,15 +4,6 @@
#include "base/allocator/partition_allocator/partition_alloc_base/files/file_path.h"
#include "build/build_config.h"
// file_path.h is a widely included header and its size has significant impact
// on build time. Try not to raise this limit unless necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 380000
#endif
#include <string.h>
#include <algorithm>

@ -4,15 +4,6 @@
#include "base/allocator/partition_allocator/partition_alloc_base/time/time.h"
#include "build/build_config.h"
#if BUILDFLAG(IS_LINUX)
// time.h is a widely included header and its size impacts build time.
// Try not to raise this limit unless necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#pragma clang max_tokens_here 490000
#endif // BUILDFLAG(IS_LINUX)
#include <atomic>
#include <cmath>
#include <limits>

@ -4,27 +4,19 @@
#include "base/check.h"
#include "base/debug/debugging_buildflags.h"
#include "build/build_config.h"
// check.h is a widely included header and its size has significant impact on
// build time. Try not to raise this limit unless absolutely necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 17000
#endif
#include "base/check_op.h"
#include "base/debug/alias.h"
#if !BUILDFLAG(IS_NACL)
#include "base/debug/crash_logging.h"
#endif // !BUILDFLAG(IS_NACL)
#include "base/debug/debugging_buildflags.h"
#include "base/debug/dump_without_crashing.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "base/thread_annotations.h"
#include "build/build_config.h"
#if !BUILDFLAG(IS_NACL)
#include "base/debug/crash_logging.h"
#endif // !BUILDFLAG(IS_NACL)
#include <atomic>
namespace logging {

@ -4,13 +4,6 @@
#include "base/check_op.h"
// check_op.h is a widely included header and its size has significant impact on
// build time. Try not to raise this limit unless absolutely necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 400000
#endif
#include <string.h>
#include <cstdio>

@ -4,13 +4,6 @@
#include "base/containers/circular_deque.h"
// circular_deque.h is a widely included header and its size has significant
// impact on build time. Try not to raise this limit unless necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 510000
#endif
#include "base/test/copy_only_int.h"
#include "base/test/move_only_int.h"
#include "testing/gtest/include/gtest/gtest.h"

@ -4,13 +4,6 @@
#include "base/containers/flat_tree.h"
// flat_tree.h is a widely included header and its size has significant impact
// on build time. Try not to raise this limit unless absolutely necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 370000
#endif
namespace base {
sorted_unique_t sorted_unique;

@ -4,13 +4,6 @@
#include "base/containers/span.h"
// span.h is a widely included header and its size has significant impact on
// build time. Try not to raise this limit unless absolutely necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 400000
#endif
#include <stdint.h>
#include <iterator>

@ -4,13 +4,6 @@
#include "base/debug/alias.h"
// This is a widely included header and its size has significant impact on
// build time. Try not to raise this limit unless absolutely necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 250
#endif
#include "base/compiler_specific.h"
namespace base {

@ -4,13 +4,6 @@
#include "base/feature_list.h"
// feature_list.h is a widely included header and its size impacts build
// time. Try not to raise this limit unless necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 610000
#endif
#include <string>
#include <tuple>

@ -4,15 +4,6 @@
#include "base/files/file_path.h"
#include "build/build_config.h"
// file_path.h is a widely included header and its size has significant impact
// on build time. Try not to raise this limit unless necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 400000
#endif
#include <string.h>
#include <algorithm>

@ -4,25 +4,16 @@
#include "base/location.h"
#include "build/build_config.h"
// location.h is a widely included header and its size can significantly impact
// build time. Try not to raise this limit unless absolutely necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 392000
#endif
#if defined(COMPILER_MSVC)
#include <intrin.h>
#endif
#include "base/compiler_specific.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/base_tracing.h"
#include "build/build_config.h"
#if defined(COMPILER_MSVC)
#include <intrin.h>
#endif
namespace base {
namespace {

@ -3,15 +3,6 @@
// found in the LICENSE file.
#include "base/logging.h"
#include <atomic>
#include <memory>
// logging.h is a widely included header and its size has significant impact on
// build time. Try not to raise this limit unless absolutely necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 480000
#endif // NACL_TC_REV
#ifdef BASE_CHECK_H_
#error "logging.h should not include check.h"
@ -20,14 +11,13 @@
#include <limits.h>
#include <stdint.h>
#include <atomic>
#include <memory>
#include <tuple>
#include <vector>
#include "base/base_export.h"
#include "base/debug/crash_logging.h"
#if defined(LEAK_SANITIZER) && !BUILDFLAG(IS_NACL)
#include "base/debug/leak_annotations.h"
#endif // defined(LEAK_SANITIZER) && !BUILDFLAG(IS_NACL)
#include "base/immediate_crash.h"
#include "base/pending_task.h"
#include "base/strings/string_piece.h"
@ -35,6 +25,10 @@
#include "base/trace_event/base_tracing.h"
#include "build/build_config.h"
#if defined(LEAK_SANITIZER) && !BUILDFLAG(IS_NACL)
#include "base/debug/leak_annotations.h"
#endif // defined(LEAK_SANITIZER) && !BUILDFLAG(IS_NACL)
#if BUILDFLAG(IS_WIN)
#include <io.h>
#include <windows.h>

@ -4,17 +4,9 @@
#include "base/observer_list.h"
#include "base/memory/raw_ptr.h"
// observer_list.h is a widely included header and its size has significant
// impact on build time. Try not to raise this limit unless necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 550000
#endif
#include <memory>
#include "base/memory/raw_ptr.h"
#include "base/strings/string_piece.h"
#include "base/test/gtest_util.h"
#include "base/threading/simple_thread.h"

@ -4,15 +4,6 @@
#include "base/time/time.h"
#include "build/build_config.h"
#if BUILDFLAG(IS_LINUX)
// time.h is a widely included header and its size impacts build time.
// Try not to raise this limit unless necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#pragma clang max_tokens_here 492000
#endif // BUILDFLAG(IS_LINUX)
#include <atomic>
#include <cmath>
#include <limits>

@ -4,13 +4,6 @@
#include "base/values.h"
// values.h is a widely included header and its size has significant impact on
// build time. Try not to raise this limit unless absolutely necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 600000
#endif
#include <algorithm>
#include <cmath>
#include <ostream>

@ -148,16 +148,6 @@ declare_args() {
# The gold linker by default has text section splitting enabled.
use_text_section_splitting = false
# Token limits may not be accurate for build configs not covered by the CQ,
# so only enable them by default for mainstream build configs.
enable_wmax_tokens =
!is_official_build && !(is_component_build && !is_debug) &&
!using_sanitizer &&
((is_mac && target_cpu == "x64" && !use_system_xcode) ||
(is_linux && target_cpu == "x64") || (is_win && target_cpu == "x86") ||
(is_win && target_cpu == "x64") || (is_android && target_cpu == "arm") ||
(is_android && target_cpu == "arm64"))
# Turn off the --call-graph-profile-sort flag for lld by default. Enable
# selectively for targets where it's beneficial.
enable_call_graph_profile_sort = chrome_pgo_phase == 2
@ -1552,10 +1542,6 @@ config("default_warnings") {
# TODO(https://bugs.chromium.org/p/fuchsia/issues/detail?id=77383)
cflags += [ "-Wno-deprecated-copy" ]
}
if (enable_wmax_tokens) {
cflags += [ "-Wmax-tokens" ]
}
}
}
}

@ -4,11 +4,6 @@
#include "components/sync_device_info/device_info.h"
// device_info.h's size can impact build time. Try not to raise this limit
// unless absolutely necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#pragma clang max_tokens_here 611000
#include <utility>
#include "base/values.h"

@ -1754,7 +1754,6 @@ source_set("browser") {
"renderer_host/private_network_access_util.h",
"renderer_host/recently_destroyed_hosts.cc",
"renderer_host/recently_destroyed_hosts.h",
"renderer_host/render_frame_host.cc",
"renderer_host/render_frame_host_csp_context.cc",
"renderer_host/render_frame_host_csp_context.h",
"renderer_host/render_frame_host_delegate.cc",

@ -1,12 +0,0 @@
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/browser/render_frame_host.h"
// render_frame_host.h is a widely included header and its size has significant
// impact on build time. Try not to raise this limit unless necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 770000
#endif

@ -4,13 +4,6 @@
#include "content/public/browser/content_browser_client.h"
// content_browser_client.h is a widely included header and its size impacts
// build time significantly. If you run into this limit, try using forward
// declarations instead of including more headers. If that is infeasible, adjust
// the limit. For more info, see
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#pragma clang max_tokens_here 1120000
#include <utility>
#include "base/callback_helpers.h"

@ -4,11 +4,6 @@
#include "content/public/browser/page_navigator.h"
// page_navigator.h is a widely included header. Try not to raise this limit
// unless necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#pragma clang max_tokens_here 1150000
#include "content/public/browser/navigation_handle.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "third_party/blink/public/mojom/frame/frame.mojom.h"

@ -1,5 +1,16 @@
# -Wmax-tokens
**Update 2022-08-02** The -Wmax-tokens experiment was [retired](https://chromium-review.googlesource.com/c/chromium/src/+/3804719)
as the downsides (annoyance to developers) were determined to outweigh the
benefits (preventing include bloat), especially in the face of
[libc++ rolls](https://crbug.com/1348349). We now have better
[include graph analysis](https://commondatastorage.googleapis.com/chromium-browser-clang/chrome_includes-index.html)
and [tracking of total build size over time](https://commondatastorage.googleapis.com/chromium-browser-clang/chrome_includes-index.html).
The goal is to have a [Gerrit warning for flagging include bloat
growth](https://crbug.com/1229609) in the future.
---
This is an experiment that uses the compiler to limit the size of certain header
files as a way of tackling #include bloat.

@ -4,15 +4,6 @@
#include "ipc/ipc_message.h"
#include "build/build_config.h"
// ipc_message.h is a widely included header and its size can impact build time.
// Try not to raise this limit unless necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#ifndef NACL_TC_REV
#pragma clang max_tokens_here 600000
#endif
#include <limits.h>
#include <stddef.h>
#include <stdint.h>

@ -28,12 +28,6 @@
*/
#include "third_party/blink/renderer/core/dom/document.h"
// document.h is a widely included header and its size impacts build time
// significantly. If you run into this limit, try using forward declarations
// instead of including more headers. If that is infeasible, adjust the limit.
// For more info, see
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#pragma clang max_tokens_here 980000
#include <memory>
#include <utility>

@ -4,11 +4,6 @@
#include "third_party/blink/renderer/core/events/input_event.h"
// input_event.h is a widely included header and its size impacts build
// time. Try not to raise this limit unless necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#pragma clang max_tokens_here 1250000
#include "base/cxx17_backports.h"
#include "third_party/blink/renderer/core/clipboard/data_transfer.h"
#include "third_party/blink/renderer/core/dom/events/event_dispatcher.h"

@ -4,11 +4,6 @@
#include "third_party/blink/renderer/platform/bindings/parkable_string.h"
// parkable_string.h is a widely included header and its size impacts build
// time. Try not to raise this limit unless necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#pragma clang max_tokens_here 760000
#include "base/allocator/partition_allocator/oom.h"
#include "base/allocator/partition_allocator/partition_alloc.h"
#include "base/bind.h"

@ -4,11 +4,6 @@
#include "ui/compositor/layer_owner.h"
// layer_owner.h is a widely included header and its size impacts build
// time. Try not to raise this limit unless necessary. See
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md
#pragma clang max_tokens_here 551000
#include <utility>
#include "base/observer_list.h"