summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorbrettw <brettw@chromium.org>2015-12-22 10:33:47 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-22 18:34:50 +0000
commitb3c2f366fdcdbe3388b3fda45ae475d4e66dfa88 (patch)
tree333cea16f917ec745ca95c86ea4ba7e27ec2e769 /base
parent5cb796c15bbcf7f1358b8e69449082352954a170 (diff)
downloadchromium_src-b3c2f366fdcdbe3388b3fda45ae475d4e66dfa88.zip
chromium_src-b3c2f366fdcdbe3388b3fda45ae475d4e66dfa88.tar.gz
chromium_src-b3c2f366fdcdbe3388b3fda45ae475d4e66dfa88.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. Reland of https://codereview.chromium.org/1528233002/ The difference is that this now depends on https://codereview.chromium.org/1540953003/ which merges base into one library. This prevents the component build issues that were causing problems. TBR=dpranke@chromium.org Review URL: https://codereview.chromium.org/1545493002 Cr-Commit-Position: refs/heads/master@{#366621}
Diffstat (limited to 'base')
-rw-r--r--base/BUILD.gn73
-rw-r--r--base/third_party/dynamic_annotations/BUILD.gn3
2 files changed, 51 insertions, 25 deletions
diff --git a/base/BUILD.gn b/base/BUILD.gn
index e5b306c..b9463e0 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -64,41 +64,66 @@ 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" ]
+ }
+
+ configs += [ ":base_implementation" ]
- visibility = [ ":base" ]
+ visibility = [ ":base" ]
+ }
}
config("android_system_libs") {
libs = [ "log" ] # Used by logging.cc.
}
-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 {
+ # 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 always be a static_library in the
+ # non-component case.
+ if (is_nacl_nonsfi) {
+ base_target_type = "source_set"
+ } else {
+ base_target_type = "static_library"
+ }
+}
+target(base_target_type, "base") {
sources = [
"allocator/allocator_extension.cc",
"allocator/allocator_extension.h",
@@ -1312,7 +1337,7 @@ buildflag_header("debugging_flags") {
# 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/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",