summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrettw <brettw@chromium.org>2015-12-17 17:07:39 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-18 01:08:37 +0000
commit89c7be623e3cc5052aaf8c3be3996432a9d4bceb (patch)
tree5d623a131fe355674d6187ff138abc4b42835c01
parent5c5fa5660fb0ebfb3534a4396520c44dc246a6d1 (diff)
downloadchromium_src-89c7be623e3cc5052aaf8c3be3996432a9d4bceb.zip
chromium_src-89c7be623e3cc5052aaf8c3be3996432a9d4bceb.tar.gz
chromium_src-89c7be623e3cc5052aaf8c3be3996432a9d4bceb.tar.bz2
Make base a static ibrary
This saves a nontrivial amount of space for some of the smaller targets in release builds. See the comment added to the base target for more. Remove libmojo_sdk. This is a complete static library that depended on base. Since base is now a static library, this dependency is not allowed. The mojo team says this target is no longer needed, so it was deleted. Review URL: https://codereview.chromium.org/1528233002 Cr-Commit-Position: refs/heads/master@{#365955}
-rw-r--r--base/BUILD.gn72
-rw-r--r--base/debug/BUILD.gn3
-rw-r--r--base/json/BUILD.gn3
-rw-r--r--base/memory/BUILD.gn3
-rw-r--r--base/metrics/BUILD.gn15
-rw-r--r--base/process/BUILD.gn3
-rw-r--r--base/third_party/dynamic_annotations/BUILD.gn3
-rw-r--r--base/trace_event/BUILD.gn3
-rw-r--r--mojo/public/BUILD.gn8
-rw-r--r--sandbox/win/BUILD.gn6
10 files changed, 75 insertions, 44 deletions
diff --git a/base/BUILD.gn b/base/BUILD.gn
index 94c7a86..90716ba 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -48,42 +48,58 @@ if (is_nacl_nonsfi) {
}
}
-source_set("base_paths") {
- sources = [
- "base_paths.cc",
- "base_paths.h",
- "base_paths_android.cc",
- "base_paths_android.h",
- "base_paths_mac.h",
- "base_paths_mac.mm",
- "base_paths_posix.cc",
- "base_paths_posix.h",
- "base_paths_win.cc",
- "base_paths_win.h",
- ]
-
- if (is_android || is_mac || is_ios) {
- sources -= [ "base_paths_posix.cc" ]
+if (is_nacl) {
+ # None of the files apply to nacl, and we can't make an empty static library.
+ group("base_paths") {
}
-
- if (is_nacl) {
- sources -= [
+} else {
+ static_library("base_paths") {
+ sources = [
"base_paths.cc",
+ "base_paths.h",
+ "base_paths_android.cc",
+ "base_paths_android.h",
+ "base_paths_mac.h",
+ "base_paths_mac.mm",
"base_paths_posix.cc",
+ "base_paths_posix.h",
+ "base_paths_win.cc",
+ "base_paths_win.h",
]
- }
- configs += [ ":base_implementation" ]
+ if (is_android || is_mac || is_ios) {
+ sources -= [ "base_paths_posix.cc" ]
+ }
- deps = [
- "//base/memory",
- "//base/process",
- ]
+ configs += [ ":base_implementation" ]
- visibility = [ ":base" ]
+ deps = [
+ "//base/memory",
+ "//base/process",
+ ]
+
+ visibility = [ ":base" ]
+ }
}
-component("base") {
+# Base and everything it depends on should be a static library rather than
+# a source set. Base is more of a "library" in the classic sense in that many
+# small parts of it are used in many different contexts. This combined with a
+# few static initializers floating around means that dead code stripping
+# still leaves a lot of code behind that isn't always used. For example, this
+# saves more than 40K for a smaller target like chrome_elf.
+#
+# Use static libraries for the helper stuff as well like //base/debug since
+# those things refer back to base code, which will force base compilation units
+# to be linked in where they wouldn't have otherwise. This does not include
+# test code (test support and anything in the test directory) which should use
+# source_set as is recommended for GN targets).
+if (is_component_build) {
+ base_target_type = "shared_library"
+} else {
+ base_target_type = "static_library"
+}
+target(base_target_type, "base") {
sources = [
"allocator/allocator_extension.cc",
"allocator/allocator_extension.h",
@@ -985,7 +1001,7 @@ component("base") {
# This is the subset of files from base that should not be used with a dynamic
# library. Note that this library cannot depend on base because base depends on
# base_static.
-source_set("base_static") {
+static_library("base_static") {
sources = [
"base_switches.cc",
"base_switches.h",
diff --git a/base/debug/BUILD.gn b/base/debug/BUILD.gn
index a910d96..eb2a309 100644
--- a/base/debug/BUILD.gn
+++ b/base/debug/BUILD.gn
@@ -5,7 +5,8 @@
import("//build/buildflag_header.gni")
import("//build/config/compiler/compiler.gni")
-source_set("debug") {
+# Should be static library, see documentation on //base:base for discussion.
+static_library("debug") {
sources = [
"alias.cc",
"alias.h",
diff --git a/base/json/BUILD.gn b/base/json/BUILD.gn
index 5cb42a3..206b5b0 100644
--- a/base/json/BUILD.gn
+++ b/base/json/BUILD.gn
@@ -4,7 +4,8 @@
import("//build/config/nacl/config.gni")
-source_set("json") {
+# Should be static library, see documentation on //base:base for discussion.
+static_library("json") {
sources = [
"json_file_value_serializer.cc",
"json_file_value_serializer.h",
diff --git a/base/memory/BUILD.gn b/base/memory/BUILD.gn
index 672330e..f6a2907 100644
--- a/base/memory/BUILD.gn
+++ b/base/memory/BUILD.gn
@@ -2,7 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-source_set("memory") {
+# Should be static library, see documentation on //base:base for discussion.
+static_library("memory") {
sources = [
"aligned_memory.cc",
"aligned_memory.h",
diff --git a/base/metrics/BUILD.gn b/base/metrics/BUILD.gn
index 6dd212f..4c95f5d 100644
--- a/base/metrics/BUILD.gn
+++ b/base/metrics/BUILD.gn
@@ -2,7 +2,20 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-source_set("metrics") {
+# TODO(phosek) bug 570839: If field_trial.cc is in a static library,
+# hacl_helper_nonsfi doesn't link properly on Linux in debug builds. The
+# reasons for this seem to involve obscure toolchain bugs. This should be fixed
+# and this target should be a static_library unconditionally.
+import("//build/config/nacl/config.gni")
+if (is_nacl_nonsfi) {
+ metrics_target_type = "source_set"
+} else {
+ metrics_target_type = "static_library"
+}
+
+# Should be static library, see documentation on //base:base for discussion.
+#static_library("metrics") { # Should be this when above TODO is resolved.
+target(metrics_target_type, "metrics") {
sources = [
"bucket_ranges.cc",
"bucket_ranges.h",
diff --git a/base/process/BUILD.gn b/base/process/BUILD.gn
index 63d65cd..cf3c401 100644
--- a/base/process/BUILD.gn
+++ b/base/process/BUILD.gn
@@ -4,7 +4,8 @@
import("//build/config/nacl/config.gni")
-source_set("process") {
+# Should be static library, see documentation on //base:base for discussion.
+static_library("process") {
sources = [
"internal_linux.cc",
"internal_linux.h",
diff --git a/base/third_party/dynamic_annotations/BUILD.gn b/base/third_party/dynamic_annotations/BUILD.gn
index 86f6558..0fc4bf7 100644
--- a/base/third_party/dynamic_annotations/BUILD.gn
+++ b/base/third_party/dynamic_annotations/BUILD.gn
@@ -12,7 +12,8 @@ if (is_nacl) {
]
}
} else {
- source_set("dynamic_annotations") {
+ # Should be static library, see documentation on //base:base for discussion.
+ static_library("dynamic_annotations") {
sources = [
"../valgrind/valgrind.h",
"dynamic_annotations.c",
diff --git a/base/trace_event/BUILD.gn b/base/trace_event/BUILD.gn
index 9a85be8..475f738 100644
--- a/base/trace_event/BUILD.gn
+++ b/base/trace_event/BUILD.gn
@@ -2,7 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-source_set("trace_event") {
+# Should be static library, see documentation on //base:base for discussion.
+static_library("trace_event") {
sources = [
"common/trace_event_common.h",
"heap_profiler_allocation_context.cc",
diff --git a/mojo/public/BUILD.gn b/mojo/public/BUILD.gn
index b917cf1..f87fb94 100644
--- a/mojo/public/BUILD.gn
+++ b/mojo/public/BUILD.gn
@@ -6,7 +6,6 @@ group("public") {
# Meta-target, don't link into production code.
testonly = true
deps = [
- ":libmojo_sdk",
":sdk",
"cpp/bindings",
"cpp/environment:standalone",
@@ -32,10 +31,3 @@ group("sdk") {
"js",
]
}
-
-static_library("libmojo_sdk") {
- complete_static_lib = true
- deps = [
- ":sdk",
- ]
-}
diff --git a/sandbox/win/BUILD.gn b/sandbox/win/BUILD.gn
index 4d1dd58..327396b 100644
--- a/sandbox/win/BUILD.gn
+++ b/sandbox/win/BUILD.gn
@@ -4,7 +4,11 @@
import("//testing/test.gni")
-source_set("sandbox") {
+# This needs to be a static library rather than a sources set because small
+# portions of this are used in some contexts (like chrome_elf), and it
+# doesnn't seem to dead-code strip very well. This saves 12K on chrome_elf.dll,
+# over a source set, for example.
+static_library("sandbox") {
sources = [
"src/acl.cc",
"src/acl.h",