Skip to content

Commit

Permalink
Work on GN Win64 build.
Browse files Browse the repository at this point in the history
Adds a new config to disable size_t -> int truncations and use it in various places where the x64 Windows build currently gives warnings.

This covers Chrome (except for Blink which has a separate patch) and the tests.

We should do a second pass to replace the existing instances of /wd4267 with this config.

Review URL: https://codereview.chromium.org/927363005

Cr-Commit-Position: refs/heads/master@{#316874}
  • Loading branch information
brettw authored and Commit bot committed Feb 18, 2015
1 parent 17beef6 commit 1deb76b
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 6 deletions.
14 changes: 14 additions & 0 deletions build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions cc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions chrome/service/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions components/content_settings/core/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ static_library("browser") {
"//net",
"//url",
]

configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
}

source_set("unit_tests") {
Expand Down
2 changes: 2 additions & 0 deletions components/history/core/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
2 changes: 2 additions & 0 deletions components/url_matcher/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ component("url_matcher") {
"//third_party/re2",
"//url",
]

configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
}
2 changes: 2 additions & 0 deletions components/web_cache/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion content/child/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion content/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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") {
Expand Down
6 changes: 4 additions & 2 deletions content/ppapi_plugin/broker_process_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(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<uint32_t>(sites.size()), site_array.get());

return PP_ToBool(result);
}
Expand Down
5 changes: 4 additions & 1 deletion content/renderer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions jingle/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions media/audio/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
2 changes: 2 additions & 0 deletions media/base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion remoting/protocol/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 1deb76b

Please sign in to comment.