1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import("//build/config/compiler/compiler.gni")
6 import("//build/config/sanitizers/sanitizers.gni")
7 import("//build/config/win/visual_studio_version.gni")
9 # Compiler setup for the Windows SDK. Applied to all targets.
11 # The include path is the stuff returned by the script.
12 #include_dirs = msvc_config[0] TODO(brettw) make this work.
17 "CERT_CHAIN_PARA_HAS_EXTRA_FIELDS",
18 "NTDDI_VERSION=0x06030000",
23 # This is required for ATL to use XP-safe versions of its functions.
28 # Sets the default Windows build version. This is separated because some
29 # targets need to manually override it for their compiles.
32 "_WIN32_WINNT=0x0603",
37 # Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs.
39 if (current_cpu == "x64") {
40 ldflags = [ "/MACHINE:X64" ]
42 "$windows_sdk_path\Lib\winv6.3\um\x64",
43 "$visual_studio_path\VC\lib\amd64",
44 "$visual_studio_path\VC\atlmfc\lib\amd64",
49 "/SAFESEH", # Not compatible with x64 so use only for x86.
52 "$windows_sdk_path\Lib\winv6.3\um\x86",
53 "$visual_studio_path\VC\lib",
54 "$visual_studio_path\VC\atlmfc\lib",
57 ldflags += [ "/largeaddressaware" ]
62 # This default linker setup is provided separately from the SDK setup so
63 # targets who want different library configurations can remove this and specify
65 config("common_linker_setup") {
72 # Suggested by Microsoft Devrel to avoid
73 # LINK : fatal error LNK1248: image size (80000000)
74 # exceeds maximum allowable size (80000000)
75 # which started happening more regularly after VS2013 Update 4.
76 "/maxilksize:2147483647",
79 # ASLR makes debugging with windbg difficult because Chrome.exe and
80 # Chrome.dll share the same base name. As result, windbg will name the
81 # Chrome.dll module like chrome_<base address>, where <base address>
82 # typically changes with each launch. This in turn means that breakpoints in
83 # Chrome.dll don't stick from one launch to the next. For this reason, we
84 # turn ASLR off in debug builds.
86 ldflags += [ "/DYNAMICBASE:NO" ]
88 ldflags += [ "/DYNAMICBASE" ]
93 "/DELAYLOAD:dbghelp.dll",
94 "/DELAYLOAD:dwmapi.dll",
95 "/DELAYLOAD:shell32.dll",
96 "/DELAYLOAD:uxtheme.dll",
100 # Subsystem --------------------------------------------------------------------
102 # This is appended to the subsystem to specify a minimum version.
103 if (current_cpu == "x64") {
104 # The number after the comma is the minimum required OS version.
105 # 5.02 = Windows Server 2003.
106 subsystem_version_suffix = ",5.02"
109 subsystem_version_suffix = ",5.01"
113 ldflags = [ "/SUBSYSTEM:CONSOLE$subsystem_version_suffix" ]
116 ldflags = [ "/SUBSYSTEM:WINDOWS$subsystem_version_suffix" ]
119 # Incremental linking ----------------------------------------------------------
121 incremental_linking_on_switch = [ "/INCREMENTAL" ]
122 incremental_linking_off_switch = [ "/INCREMENTAL:NO" ]
124 default_incremental_linking_switch = incremental_linking_on_switch
126 default_incremental_linking_switch = incremental_linking_off_switch
129 # Applies incremental linking or not depending on the current configuration.
130 config("default_incremental_linking") {
131 ldflags = default_incremental_linking_switch
134 # Explicitly on or off incremental linking
135 config("incremental_linking") {
136 ldflags = incremental_linking_on_switch
138 config("no_incremental_linking") {
139 ldflags = incremental_linking_off_switch
142 # Some large modules can't handle incremental linking in some situations. This
143 # config should be applied to large modules to turn off incremental linking
144 # when it won't work.
145 config("default_large_module_incremental_linking") {
146 if (symbol_level > 0 && (current_cpu == "x86" || !is_component_build)) {
147 # When symbols are on, things get so large that the tools fail due to the
148 # size of the .ilk files.
149 ldflags = incremental_linking_off_switch
151 # Otherwise just do the default incremental linking for this build type.
152 ldflags = default_incremental_linking_switch
156 # Character set ----------------------------------------------------------------
158 # Not including this config means "ansi" (8-bit system codepage).
166 # Lean and mean ----------------------------------------------------------------
168 # Some third party code might not compile with WIN32_LEAN_AND_MEAN so we have
169 # to have a separate config for it. Remove this config from your target to
170 # get the "bloaty and accomodating" version of windows.h.
171 config("lean_and_mean") {
172 defines = [ "WIN32_LEAN_AND_MEAN" ]
175 # Nominmax --------------------------------------------------------------------
177 # Some third party code defines NOMINMAX before including windows.h, which
178 # then causes warnings when it's been previously defined on the command line.
179 # For such targets, this config can be removed.
182 defines = [ "NOMINMAX" ]
185 # Target WinRT ----------------------------------------------------------------
187 # When targeting Windows Runtime, certain compiler/linker flags are necessary.
189 config("target_winrt") {
192 "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP",
200 # Internal stuff --------------------------------------------------------------
202 # Config used by the MIDL template to disable warnings.
203 config("midl_warnings") {
205 # MIDL generates code like "#endif !_MIDL_USE_GUIDDEF_".
206 cflags = [ "-Wno-extra-tokens" ]