diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 164b97d26260f3..584f72be2e30c6 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -881,6 +881,20 @@ config("wexit_time_destructors") { } } +# On Windows compiling on x64, VC will issue a warning when converting +# size_t to int because it will truncate the value. Our code should not have +# these warnings and one should use a static_cast or a checked_cast for the +# conversion depending on the case. However, a lot of code still needs to be +# fixed. Apply this config to such targets to disable the warning. +# +# Note that this can be applied regardless of platform and architecture to +# clean up the call sites. This will only apply the flag when necessary. +config("no_size_t_to_int_warning") { + if (is_win && cpu_arch == "x64") { + cflags = [ "/wd4267" ] + } +} + # Optimization ----------------------------------------------------------------- # # Note that BUILDCONFIG.gn sets up a variable "default_optimization_config" diff --git a/cc/BUILD.gn b/cc/BUILD.gn index 01a3a6c7d00662..cac0942b6a9806 100644 --- a/cc/BUILD.gn +++ b/cc/BUILD.gn @@ -697,6 +697,8 @@ source_set("test_support") { "test/tiled_layer_test_common.h", ] + configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] + include_dirs = [ ".", "test", diff --git a/chrome/service/BUILD.gn b/chrome/service/BUILD.gn index 8ad6a1336f5b84..fe26068d3f3a2d 100644 --- a/chrome/service/BUILD.gn +++ b/chrome/service/BUILD.gn @@ -46,6 +46,8 @@ static_library("service") { "service_process_prefs.h", ] + configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] + deps = [ "//chrome:strings", "//chrome/common", diff --git a/components/content_settings/core/browser/BUILD.gn b/components/content_settings/core/browser/BUILD.gn index 89f3ec8834b0c3..a321cbb68d095c 100644 --- a/components/content_settings/core/browser/BUILD.gn +++ b/components/content_settings/core/browser/BUILD.gn @@ -40,6 +40,8 @@ static_library("browser") { "//net", "//url", ] + + configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] } source_set("unit_tests") { diff --git a/components/history/core/browser/BUILD.gn b/components/history/core/browser/BUILD.gn index c2e1bde87f419d..5e8b4f49ef98ee 100644 --- a/components/history/core/browser/BUILD.gn +++ b/components/history/core/browser/BUILD.gn @@ -111,6 +111,8 @@ static_library("browser") { "android/visit_sql_handler.h", ] } + + configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] } proto_library("proto") { diff --git a/components/url_matcher/BUILD.gn b/components/url_matcher/BUILD.gn index 83f95d31f04782..7df189b501f1eb 100644 --- a/components/url_matcher/BUILD.gn +++ b/components/url_matcher/BUILD.gn @@ -29,4 +29,6 @@ component("url_matcher") { "//third_party/re2", "//url", ] + + configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] } diff --git a/components/web_cache/browser/BUILD.gn b/components/web_cache/browser/BUILD.gn index d001973974e26c..b9ba85bd634c82 100644 --- a/components/web_cache/browser/BUILD.gn +++ b/components/web_cache/browser/BUILD.gn @@ -9,6 +9,8 @@ static_library("browser") { "web_cache_manager.h", ] + configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] + deps = [ "//base", "//components/web_cache/common", diff --git a/content/child/BUILD.gn b/content/child/BUILD.gn index 935db3f86c9ccd..1380fe11869fba 100644 --- a/content/child/BUILD.gn +++ b/content/child/BUILD.gn @@ -97,7 +97,10 @@ source_set("child") { } } - configs += [ "//content:content_implementation" ] + configs += [ + "//content:content_implementation", + "//build/config/compiler:no_size_t_to_int_warning", + ] if (is_ios) { # iOS only needs a small portion of content; exclude all the diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn index 6bf0f6417f5645..9ca66d2428bf3a 100644 --- a/content/common/BUILD.gn +++ b/content/common/BUILD.gn @@ -130,7 +130,10 @@ source_set("common") { ".", "//content") - configs += [ "//content:content_implementation" ] + configs += [ + "//content:content_implementation", + "//build/config/compiler:no_size_t_to_int_warning", + ] public_deps = [ "//gpu/command_buffer/common", @@ -453,6 +456,11 @@ source_set("common") { ] } } + + if (is_win && cpu_arch == "x64") { + # TODO(jschuh): Remove this after crbug.com/173851 gets fixed. + cflags = [ "/bigobj" ] + } } mojom("mojo_bindings") { diff --git a/content/ppapi_plugin/broker_process_dispatcher.cc b/content/ppapi_plugin/broker_process_dispatcher.cc index 35d5b9d48e639e..97d425043c8824 100644 --- a/content/ppapi_plugin/broker_process_dispatcher.cc +++ b/content/ppapi_plugin/broker_process_dispatcher.cc @@ -309,14 +309,16 @@ bool BrokerProcessDispatcher::SetSitePermission( if (flash_browser_operations_1_3_) { PP_Bool result = flash_browser_operations_1_3_->SetSitePermission( - data_str.c_str(), setting_type, sites.size(), site_array.get()); + data_str.c_str(), setting_type, + static_cast(sites.size()), site_array.get()); return PP_ToBool(result); } if (flash_browser_operations_1_2_) { PP_Bool result = flash_browser_operations_1_2_->SetSitePermission( - data_str.c_str(), setting_type, sites.size(), site_array.get()); + data_str.c_str(), setting_type, + static_cast(sites.size()), site_array.get()); return PP_ToBool(result); } diff --git a/content/renderer/BUILD.gn b/content/renderer/BUILD.gn index 1d6430547ad1a5..73445e17a07da6 100644 --- a/content/renderer/BUILD.gn +++ b/content/renderer/BUILD.gn @@ -16,7 +16,10 @@ source_set("renderer") { ".", "//content") - configs += [ "//content:content_implementation" ] + configs += [ + "//content:content_implementation", + "//build/config/compiler:no_size_t_to_int_warning", + ] deps = [ # TODO(GYP) bug 376846 remove this. This should be inherited from //net but diff --git a/jingle/BUILD.gn b/jingle/BUILD.gn index 1940dfc9352808..ce66666ca37097 100644 --- a/jingle/BUILD.gn +++ b/jingle/BUILD.gn @@ -21,6 +21,8 @@ if (enable_webrtc || !is_android) { "//base/third_party/dynamic_annotations", "//net", ] + + configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] } # A library for sending and receiving peer-issued notifications. diff --git a/media/audio/BUILD.gn b/media/audio/BUILD.gn index fa9a65781e8ffb..028fd45d027f3c 100644 --- a/media/audio/BUILD.gn +++ b/media/audio/BUILD.gn @@ -243,6 +243,8 @@ source_set("audio") { sources += get_target_outputs(":pulse_generate_stubs") } } + + configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] } source_set("test_support") { diff --git a/media/base/BUILD.gn b/media/base/BUILD.gn index 138d1f5d661290..0fb3b1ceca8794 100644 --- a/media/base/BUILD.gn +++ b/media/base/BUILD.gn @@ -250,6 +250,8 @@ source_set("base") { ] } + configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] + if (is_linux || is_win) { sources += [ "keyboard_event_counter.cc", diff --git a/remoting/protocol/BUILD.gn b/remoting/protocol/BUILD.gn index 3ffcb08d02d5b8..34b38af0224fae 100644 --- a/remoting/protocol/BUILD.gn +++ b/remoting/protocol/BUILD.gn @@ -11,7 +11,10 @@ static_library("protocol") { sources = rebase_path(gypi_values.remoting_protocol_sources, ".", "//remoting") - configs += [ "//build/config/compiler:wexit_time_destructors" ] + configs += [ + "//build/config/compiler:no_size_t_to_int_warning", + "//build/config/compiler:wexit_time_destructors", + ] public_deps = [ "//third_party/libjingle",