Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: third_party/protobuf/BUILD.gn

Issue 2756543002: Statically link libprotobuf_lite on Linux component builds (Closed)
Patch Set: Extract all global data to globals.cc Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/BUILD.gn ('k') | third_party/protobuf/README.chromium » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 config("protobuf_config") { 5 config("protobuf_config") {
6 include_dirs = [ "src" ] 6 include_dirs = [ "src" ]
7 defines = [ 7 defines = [
8 "GOOGLE_PROTOBUF_NO_RTTI", 8 "GOOGLE_PROTOBUF_NO_RTTI",
9 "GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER", 9 "GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
10 ] 10 ]
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 "/wd4244", # implicit conversion, possible loss of data 129 "/wd4244", # implicit conversion, possible loss of data
130 "/wd4267", # size_t to int truncation 130 "/wd4267", # size_t to int truncation
131 "/wd4291", # no matching operator delete for a placement new. 131 "/wd4291", # no matching operator delete for a placement new.
132 "/wd4305", # double to float truncation 132 "/wd4305", # double to float truncation
133 "/wd4355", # 'this' used in base member initializer list 133 "/wd4355", # 'this' used in base member initializer list
134 "/wd4506", # no definition for inline function (protobuf issue #240) 134 "/wd4506", # no definition for inline function (protobuf issue #240)
135 "/wd4715", # not all control paths return a value (fixed in trunk) 135 "/wd4715", # not all control paths return a value (fixed in trunk)
136 ] 136 ]
137 } 137 }
138 138
139 component("protobuf_lite") { 139 # Do not allow libprotobuf_lite to be dynamically linked on Linux. Later
140 # versions of Ubuntu like Xenial and Yakkety link in the system
141 # libprotobuf_lite by the following dependency chain: chrome -> gtk ->
142 # libmirclient -> libmirprotobuf -> libprotobuf-lite. Trying to load
143 # the system libprotobuf-lite after already having loaded the libprotobuf_lite
144 # component will result in an immediate crash. (crbug.com/700120)
145 if (is_linux && !is_chromeos) {
146 link_target_type = "static_library"
147 } else {
148 link_target_type = "component"
149 }
150
151 if (is_component_build && is_linux && !is_chromeos) {
152 # Even though protobuf is statically linked on Linux, global data must
153 # be shared across different copies of the library in each component.
154 # protobuf_globals is a shared library that provides this state, but is
155 # careful to prefix all exported symbols with 'cr_' so they don't conflict
156 # with other versions of protobuf.
157 component("protobuf_globals") {
158 configs += [
159 ":protobuf_config",
160 ":protobuf_use_dlls",
161 ]
162 defines = [ "LIBPROTOBUF_EXPORTS" ]
163 sources = [
164 "src/google/protobuf/globals.cc",
165 "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
166 ]
167 }
168 }
169
170 target(link_target_type, "protobuf_lite") {
140 sources = protobuf_lite_sources 171 sources = protobuf_lite_sources
141 172
142 configs -= [ "//build/config/compiler:chromium_code" ] 173 configs -= [ "//build/config/compiler:chromium_code" ]
143 configs += [ 174 configs += [
144 "//build/config/compiler:no_chromium_code", 175 "//build/config/compiler:no_chromium_code",
145 176
146 # Must be after no_chromium_code for warning flags to be ordered 177 # Must be after no_chromium_code for warning flags to be ordered
147 # correctly. 178 # correctly.
148 ":protobuf_warnings", 179 ":protobuf_warnings",
149 ] 180 ]
150 181
151 if (is_win) { 182 if (is_win) {
152 configs -= [ "//build/config/win:lean_and_mean" ] 183 configs -= [ "//build/config/win:lean_and_mean" ]
153 } 184 }
154 185
155 public_configs = [ 186 public_configs = [
156 ":protobuf_config", 187 ":protobuf_config",
157 188
158 # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. 189 # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
159 "//build/config/compiler:no_size_t_to_int_warning", 190 "//build/config/compiler:no_size_t_to_int_warning",
160 ] 191 ]
161 192
162 deps = [ 193 deps = [
163 "//build/config/sanitizers:deps", 194 "//build/config/sanitizers:deps",
164 ] 195 ]
165 196
166 cflags = protobuf_lite_cflags 197 cflags = protobuf_lite_cflags
167 198
199 if (is_component_build && is_linux && !is_chromeos) {
200 deps += [ ":protobuf_globals" ]
201 } else {
202 sources += [ "src/google/protobuf/globals.cc" ]
203 }
204
168 # Required for component builds. See http://crbug.com/172800. 205 # Required for component builds. See http://crbug.com/172800.
169 if (is_component_build) { 206 if (is_component_build && (!is_linux || is_chromeos)) {
170 public_configs += [ ":protobuf_use_dlls" ] 207 public_configs += [ ":protobuf_use_dlls" ]
171 defines = [ "LIBPROTOBUF_EXPORTS" ] 208 defines = [ "LIBPROTOBUF_EXPORTS" ]
172 } 209 }
173 } 210 }
174 211
175 # This is the full, heavy protobuf lib that's needed for c++ .protos that don't 212 # This is the full, heavy protobuf lib that's needed for c++ .protos that don't
176 # specify the LITE_RUNTIME option. The protocol compiler itself (protoc) falls 213 # specify the LITE_RUNTIME option. The protocol compiler itself (protoc) falls
177 # into that category. Do not use in Chrome code. 214 # into that category. Do not use in Chrome code.
178 static_library("protobuf_full") { 215 static_library("protobuf_full") {
179 # Prevent people from depending on this outside our file. 216 # Prevent people from depending on this outside our file.
(...skipping 28 matching lines...) Expand all
208 "src/google/protobuf/dynamic_message.h", 245 "src/google/protobuf/dynamic_message.h",
209 "src/google/protobuf/empty.pb.cc", 246 "src/google/protobuf/empty.pb.cc",
210 "src/google/protobuf/empty.pb.h", 247 "src/google/protobuf/empty.pb.h",
211 "src/google/protobuf/extension_set_heavy.cc", 248 "src/google/protobuf/extension_set_heavy.cc",
212 "src/google/protobuf/field_mask.pb.cc", 249 "src/google/protobuf/field_mask.pb.cc",
213 "src/google/protobuf/field_mask.pb.h", 250 "src/google/protobuf/field_mask.pb.h",
214 "src/google/protobuf/generated_enum_reflection.h", 251 "src/google/protobuf/generated_enum_reflection.h",
215 "src/google/protobuf/generated_enum_util.h", 252 "src/google/protobuf/generated_enum_util.h",
216 "src/google/protobuf/generated_message_reflection.cc", 253 "src/google/protobuf/generated_message_reflection.cc",
217 "src/google/protobuf/generated_message_reflection.h", 254 "src/google/protobuf/generated_message_reflection.h",
255 "src/google/protobuf/globals.cc",
218 256
219 # gzip_stream.cc pulls in zlib, but it's not actually used by protoc, just 257 # gzip_stream.cc pulls in zlib, but it's not actually used by protoc, just
220 # by test code, so instead of compiling zlib for the host, let's just 258 # by test code, so instead of compiling zlib for the host, let's just
221 # exclude this. 259 # exclude this.
222 # "src/google/protobuf/io/gzip_stream.cc", 260 # "src/google/protobuf/io/gzip_stream.cc",
223 # "src/google/protobuf/io/gzip_stream.h", 261 # "src/google/protobuf/io/gzip_stream.h",
224 262
225 "src/google/protobuf/io/printer.cc", 263 "src/google/protobuf/io/printer.cc",
226 "src/google/protobuf/io/printer.h", 264 "src/google/protobuf/io/printer.h",
227 "src/google/protobuf/io/strtod.cc", 265 "src/google/protobuf/io/strtod.cc",
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 ":copy_google_protobuf_internal", 686 ":copy_google_protobuf_internal",
649 ":copy_six", 687 ":copy_six",
650 ] 688 ]
651 689
652 # Targets that depend on this should depend on the copied data files. 690 # Targets that depend on this should depend on the copied data files.
653 data = get_target_outputs(":copy_google") 691 data = get_target_outputs(":copy_google")
654 data += get_target_outputs(":copy_six") 692 data += get_target_outputs(":copy_six")
655 data += get_target_outputs(":copy_google_protobuf") 693 data += get_target_outputs(":copy_google_protobuf")
656 data += get_target_outputs(":copy_google_protobuf_internal") 694 data += get_target_outputs(":copy_google_protobuf_internal")
657 } 695 }
OLDNEW
« no previous file with comments | « net/BUILD.gn ('k') | third_party/protobuf/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698