1# Copyright 2013 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import("//build/config/c++/c++.gni") 6import("//build/config/chrome_build.gni") 7import("//build/config/clang/clang.gni") 8import("//build/config/compiler/compiler.gni") 9import("//build/config/rust.gni") 10import("//build/config/sanitizers/sanitizers.gni") 11import("//build/config/win/control_flow_guard.gni") 12import("//build/config/win/visual_studio_version.gni") 13import("//build/timestamp.gni") 14import("//build/toolchain/rbe.gni") 15import("//build/toolchain/toolchain.gni") 16 17assert(is_win) 18 19declare_args() { 20 # Turn this on to have the linker output extra timing information. 21 win_linker_timing = false 22 23 # possible values for target_winuwp_version: 24 # "10" - Windows UWP 10 25 # "8.1" - Windows RT 8.1 26 # "8.0" - Windows RT 8.0 27 target_winuwp_version = "10" 28 29 # possible values: 30 # "app" - Windows Store Applications 31 # "phone" - Windows Phone Applications 32 # "system" - Windows Drivers and Tools 33 # "server" - Windows Server Applications 34 # "desktop" - Windows Desktop Applications 35 target_winuwp_family = "app" 36 37 # Set this to use clang-style diagnostics format instead of MSVC-style, which 38 # is useful in e.g. Emacs compilation mode. 39 # E.g.: 40 # Without this, clang emits a diagnostic message like this: 41 # foo/bar.cc(12,34): error: something went wrong 42 # and with this switch, clang emits it like this: 43 # foo/bar.cc:12:34: error: something went wrong 44 use_clang_diagnostics_format = false 45} 46 47# This is included by reference in the //build/config/compiler config that 48# is applied to all targets. It is here to separate out the logic that is 49# Windows-only. 50config("compiler") { 51 if (current_cpu == "x86") { 52 asmflags = [ 53 # When /safeseh is specified, the linker will only produce an image if it 54 # can also produce a table of the image's safe exception handlers. This 55 # table specifies for the operating system which exception handlers are 56 # valid for the image. Note that /SAFESEH isn't accepted on the command 57 # line, only /safeseh. This is only accepted by ml.exe, not ml64.exe. 58 "/safeseh", 59 ] 60 } 61 62 cflags = [ 63 "/Gy", # Enable function-level linking. 64 "/FS", # Preserve previous PDB behavior. 65 "/bigobj", # Some of our files are bigger than the regular limits. 66 "/utf-8", # Assume UTF-8 by default to avoid code page dependencies. 67 ] 68 69 if (is_clang) { 70 cflags += [ 71 "/Zc:twoPhase", 72 73 # Consistently use backslash as the path separator when expanding the 74 # __FILE__ macro when targeting Windows regardless of the build 75 # environment. 76 "-ffile-reproducible", 77 ] 78 } 79 80 # Force C/C++ mode for the given GN detected file type. This is necessary 81 # for precompiled headers where the same source file is compiled in both 82 # modes. 83 cflags_c = [ "/TC" ] 84 cflags_cc = [ "/TP" ] 85 86 cflags += [ 87 # Work around crbug.com/526851, bug in VS 2015 RTM compiler. 88 "/Zc:sizedDealloc-", 89 ] 90 91 if (is_clang) { 92 # Required to make the 19041 SDK compatible with clang-cl. 93 # See https://crbug.com/1089996 issue #2 for details. 94 cflags += [ "/D__WRL_ENABLE_FUNCTION_STATICS__" ] 95 96 # Tell clang which version of MSVC to emulate. 97 cflags += [ "-fmsc-version=1934" ] 98 99 if (is_component_build) { 100 cflags += [ 101 # Do not export inline member functions. This makes component builds 102 # faster. This is similar to -fvisibility-inlines-hidden. 103 "/Zc:dllexportInlines-", 104 ] 105 } 106 107 if (current_cpu == "x86") { 108 if (host_cpu == "x86" || host_cpu == "x64") { 109 cflags += [ "-m32" ] 110 } else { 111 cflags += [ "--target=i386-windows" ] 112 } 113 } else if (current_cpu == "x64") { 114 if (host_cpu == "x86" || host_cpu == "x64") { 115 cflags += [ "-m64" ] 116 } else { 117 cflags += [ "--target=x86_64-windows" ] 118 } 119 } else if (current_cpu == "arm64") { 120 cflags += [ "--target=aarch64-pc-windows" ] 121 } else { 122 assert(false, "unknown current_cpu " + current_cpu) 123 } 124 125 # Chrome currently requires SSE3. Clang supports targeting any Intel 126 # microarchitecture. MSVC only supports a subset of architectures, and the 127 # next step after SSE2 will be AVX. 128 if (current_cpu == "x86" || current_cpu == "x64") { 129 cflags += [ "-msse3" ] 130 } 131 132 # Enable ANSI escape codes if something emulating them is around (cmd.exe 133 # doesn't understand ANSI escape codes by default). Make sure to not enable 134 # this if remoteexec is in use, because this will lower cache hits. 135 if (!use_remoteexec && 136 exec_script("//build/win/use_ansi_codes.py", [], "trim string") == 137 "True") { 138 cflags += [ "-fansi-escape-codes" ] 139 } 140 141 if (use_clang_diagnostics_format) { 142 cflags += [ "/clang:-fdiagnostics-format=clang" ] 143 } 144 } 145 146 # Disabled with cc_wrapper because of https://github.com/mozilla/sccache/issues/264 147 if (use_lld && !use_thin_lto && cc_wrapper == "") { 148 # /Brepro lets the compiler not write the mtime field in the .obj output. 149 # link.exe /incremental relies on this field to work correctly, but lld 150 # never looks at this timestamp, so it's safe to pass this flag with 151 # lld and get more deterministic compiler output in return. 152 # In LTO builds, the compiler doesn't write .obj files containing mtimes, 153 # so /Brepro is ignored there. 154 cflags += [ "/Brepro" ] 155 } 156 157 ldflags = [] 158 159 if (use_lld) { 160 # lld defaults to writing the current time in the pe/coff header. 161 # For build reproducibility, pass an explicit timestamp. See 162 # build/compute_build_timestamp.py for how the timestamp is chosen. 163 # (link.exe also writes the current time, but it doesn't have a flag to 164 # override that behavior.) 165 ldflags += [ "/TIMESTAMP:" + build_timestamp ] 166 167 # Don't look for libpaths in %LIB%, similar to /X in cflags above. 168 ldflags += [ "/lldignoreenv" ] 169 } 170 171 # Some binaries create PDBs larger than 4 GiB. Increasing the PDB page size 172 # to 8 KiB allows 8 GiB PDBs. The larger page size also allows larger block maps 173 # which is a PDB limit that was hit in https://crbug.com/1406510. The page size 174 # can easily be increased in the future to allow even larger PDBs or larger 175 # block maps. 176 # This flag requires lld-link.exe or link.exe from VS 2022 or later to create 177 # the PDBs, and tools from circa 22H2 or later to consume the PDBs. 178 # Debug component builds can generate PDBs that exceed 8 GiB, so use an 179 # even larger page size, allowing up to 16 GiB PDBs. 180 if (is_debug && !is_component_build) { 181 ldflags += [ "/pdbpagesize:16384" ] 182 } else { 183 ldflags += [ "/pdbpagesize:8192" ] 184 } 185 186 if (!is_debug && !is_component_build) { 187 # Enable standard linker optimizations like GC (/OPT:REF) and ICF in static 188 # release builds. 189 # Release builds always want these optimizations, so enable them explicitly. 190 ldflags += [ 191 "/OPT:REF", 192 "/OPT:ICF", 193 "/INCREMENTAL:NO", 194 "/FIXED:NO", 195 ] 196 197 if (use_lld) { 198 # String tail merging leads to smaller binaries, but they don't compress 199 # as well, leading to increased mini_installer size (crbug.com/838449). 200 ldflags += [ "/OPT:NOLLDTAILMERGE" ] 201 } 202 203 # TODO(siggi): Is this of any use anymore? 204 # /PROFILE ensures that the PDB file contains FIXUP information (growing the 205 # PDB file by about 5%) but does not otherwise alter the output binary. It 206 # is enabled opportunistically for builds where it is not prohibited (not 207 # supported when incrementally linking, or using /debug:fastlink). 208 ldflags += [ "/PROFILE" ] 209 } 210 211 # arflags apply only to static_libraries. The normal linker configs are only 212 # set for executable and shared library targets so arflags must be set 213 # elsewhere. Since this is relatively contained, we just apply them in this 214 # more general config and they will only have an effect on static libraries. 215 arflags = [ 216 # "No public symbols found; archive member will be inaccessible." This 217 # means that one or more object files in the library can never be 218 # pulled in to targets that link to this library. It's just a warning that 219 # the source file is a no-op. 220 "/ignore:4221", 221 ] 222} 223 224# This is included by reference in the //build/config/compiler:runtime_library 225# config that is applied to all targets. It is here to separate out the logic 226# that is Windows-only. Please see that target for advice on what should go in 227# :runtime_library vs. :compiler. 228config("runtime_library") { 229 cflags = [] 230 cflags_cc = [] 231 232 # Defines that set up the CRT. 233 defines = [ 234 "__STD_C", 235 "_CRT_RAND_S", 236 "_CRT_SECURE_NO_DEPRECATE", 237 "_SCL_SECURE_NO_DEPRECATE", 238 ] 239 240 # Defines that set up the Windows SDK. 241 defines += [ 242 "_ATL_NO_OPENGL", 243 "_WINDOWS", 244 "CERT_CHAIN_PARA_HAS_EXTRA_FIELDS", 245 "PSAPI_VERSION=2", 246 "WIN32", 247 "_SECURE_ATL", 248 ] 249 250 if (current_os == "winuwp") { 251 # When targeting Windows Runtime, certain compiler/linker flags are 252 # necessary. 253 defines += [ 254 "WINUWP", 255 "__WRL_NO_DEFAULT_LIB__", 256 ] 257 if (target_winuwp_family == "app") { 258 defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP" ] 259 } else if (target_winuwp_family == "phone") { 260 defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP" ] 261 } else if (target_winuwp_family == "system") { 262 defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_SYSTEM" ] 263 } else if (target_winuwp_family == "server") { 264 defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_SERVER" ] 265 } else { 266 defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] 267 } 268 cflags_cc += [ "/EHsc" ] 269 270 # This warning is given because the linker cannot tell the difference 271 # between consuming WinRT APIs versus authoring WinRT within static 272 # libraries as such this warning is always given by the linker. Since 273 # consuming WinRT APIs within a library is legitimate but authoring 274 # WinRT APis is not allowed, this warning is disabled to ignore the 275 # legitimate consumption of WinRT APIs within static library builds. 276 arflags = [ "/IGNORE:4264" ] 277 278 if (target_winuwp_version == "10") { 279 defines += [ "WIN10=_WIN32_WINNT_WIN10" ] 280 } else if (target_winuwp_version == "8.1") { 281 defines += [ "WIN8_1=_WIN32_WINNT_WINBLUE" ] 282 } else if (target_winuwp_version == "8.0") { 283 defines += [ "WIN8=_WIN32_WINNT_WIN8" ] 284 } 285 } else { 286 # When not targeting Windows Runtime, make sure the WINAPI family is set 287 # to desktop. 288 defines += [ "WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP" ] 289 } 290} 291 292# Chromium only supports Windowes 10+. 293# Some third-party libraries assume that these defines set what version of 294# Windows is available at runtime. Targets using these libraries need to 295# manually override this config for their compiles. 296config("winver") { 297 defines = [ 298 "NTDDI_VERSION=NTDDI_WIN10_NI", 299 300 # We can't say `=_WIN32_WINNT_WIN10` here because some files do 301 # `#if WINVER < 0x0600` without including windows.h before, 302 # and then _WIN32_WINNT_WIN10 isn't yet known to be 0x0A00. 303 "_WIN32_WINNT=0x0A00", 304 "WINVER=0x0A00", 305 ] 306} 307 308# Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs. 309config("sdk_link") { 310 if (current_cpu == "x86") { 311 ldflags = [ 312 "/SAFESEH", # Not compatible with x64 so use only for x86. 313 "/largeaddressaware", 314 ] 315 } 316} 317 318# This default linker setup is provided separately from the SDK setup so 319# targets who want different library configurations can remove this and specify 320# their own. 321config("common_linker_setup") { 322 ldflags = [ 323 "/FIXED:NO", 324 "/ignore:4199", 325 "/ignore:4221", 326 "/NXCOMPAT", 327 "/DYNAMICBASE", 328 ] 329 330 if (win_linker_timing) { 331 ldflags += [ 332 "/time", 333 "/verbose:incr", 334 ] 335 } 336} 337 338config("default_cfg_compiler") { 339 # Emit table of address-taken functions for Control-Flow Guard (CFG). 340 # This is needed to allow functions to be called by code that is built 341 # with CFG enabled, such as system libraries. 342 # The CFG guards are only emitted if |win_enable_cfg_guards| is enabled. 343 if (win_enable_cfg_guards) { 344 if (is_clang) { 345 cflags = [ "/guard:cf" ] 346 } 347 rustflags = [ "-Ccontrol-flow-guard" ] 348 } else { 349 if (is_clang) { 350 cflags = [ "/guard:cf,nochecks" ] 351 } 352 rustflags = [ "-Ccontrol-flow-guard=nochecks" ] 353 } 354} 355 356# To disable CFG guards for a target, remove the "default_cfg_compiler" 357# config, and add "disable_guards_cfg_compiler" config. 358config("disable_guards_cfg_compiler") { 359 # Emit table of address-taken functions for Control-Flow Guard (CFG). 360 # This is needed to allow functions to be called by code that is built 361 # with CFG enabled, such as system libraries. 362 if (is_clang) { 363 cflags = [ "/guard:cf,nochecks" ] 364 } 365 rustflags = [ "-Ccontrol-flow-guard=nochecks" ] 366} 367 368config("cfi_linker") { 369 # Control Flow Guard (CFG) 370 # https://msdn.microsoft.com/en-us/library/windows/desktop/mt637065.aspx 371 # /DYNAMICBASE (ASLR) is turned off in debug builds, therefore CFG cannot be 372 # turned on either. 373 # ASan and CFG leads to slow process startup. Chromium's test runner uses 374 # lots of child processes, so this means things are really slow. Disable CFG 375 # for now. https://crbug.com/846966 376 if (!is_debug && !is_asan) { 377 # Turn on CFG bitmap generation and CFG load config. 378 ldflags = [ "/guard:cf" ] 379 } 380} 381 382# This is a superset of all the delayloads needed for chrome.exe, chrome.dll, 383# and chrome_elf.dll. The linker will automatically ignore anything which is not 384# linked to the binary at all (it is harmless to have an unmatched /delayload). 385# 386# We delayload most libraries as the dlls are simply not required at startup (or 387# at all, depending on the process type). In unsandboxed process they will load 388# when first needed. 389# 390# Some dlls open handles when they are loaded, and we may not want them to be 391# loaded in renderers or other sandboxed processes. Conversely, some dlls must 392# be loaded before sandbox lockdown. 393# 394# Some dlls themselves load others - in particular, to avoid unconditionally 395# loading user32.dll - we require that the following dlls are all delayloaded: 396# user32, gdi32, comctl32, comdlg32, cryptui, d3d9, dwmapi, imm32, msi, ole32, 397# oleacc, rstrtmgr, shell32, shlwapi, and uxtheme. 398# 399# Advapi32.dll is unconditionally loaded at process startup on Windows 10, but 400# on Windows 11 it is not, which makes it worthwhile to delay load it. 401# Additionally, advapi32.dll exports several functions that are forwarded to 402# other DLLs such as cryptbase.dll. If calls to those functions are present but 403# there are some processes where the functions are never called then delay 404# loading of advapi32.dll avoids pulling in those DLLs (such as cryptbase.dll) 405# unnecessarily, even if advapi32.dll itself is loaded. 406# 407# This config applies to chrome.exe, chrome.dll, chrome_elf.dll (& others). 408# 409# This config should also be used for any test binary whose goal is to run 410# tests with the full browser. 411config("delayloads") { 412 ldflags = [ 413 "/DELAYLOAD:api-ms-win-core-synch-l1-2-0.dll", 414 "/DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll", 415 "/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll", 416 "/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll", 417 "/DELAYLOAD:advapi32.dll", 418 "/DELAYLOAD:bcryptprimitives.dll", 419 "/DELAYLOAD:comctl32.dll", 420 "/DELAYLOAD:comdlg32.dll", 421 "/DELAYLOAD:credui.dll", 422 "/DELAYLOAD:cryptui.dll", 423 "/DELAYLOAD:d3d11.dll", 424 "/DELAYLOAD:d3d12.dll", 425 "/DELAYLOAD:d3d9.dll", 426 "/DELAYLOAD:dwmapi.dll", 427 "/DELAYLOAD:dxgi.dll", 428 "/DELAYLOAD:dxva2.dll", 429 "/DELAYLOAD:esent.dll", 430 "/DELAYLOAD:fontsub.dll", 431 "/DELAYLOAD:gdi32.dll", 432 "/DELAYLOAD:hid.dll", 433 "/DELAYLOAD:imagehlp.dll", 434 "/DELAYLOAD:imm32.dll", 435 "/DELAYLOAD:msi.dll", 436 "/DELAYLOAD:netapi32.dll", 437 "/DELAYLOAD:ncrypt.dll", 438 "/DELAYLOAD:ole32.dll", 439 "/DELAYLOAD:oleacc.dll", 440 "/DELAYLOAD:pdh.dll", 441 "/DELAYLOAD:propsys.dll", 442 "/DELAYLOAD:psapi.dll", 443 "/DELAYLOAD:rpcrt4.dll", 444 "/DELAYLOAD:rstrtmgr.dll", 445 "/DELAYLOAD:setupapi.dll", 446 "/DELAYLOAD:shell32.dll", 447 "/DELAYLOAD:shlwapi.dll", 448 "/DELAYLOAD:uiautomationcore.dll", 449 "/DELAYLOAD:urlmon.dll", 450 "/DELAYLOAD:user32.dll", 451 "/DELAYLOAD:usp10.dll", 452 "/DELAYLOAD:uxtheme.dll", 453 "/DELAYLOAD:wer.dll", 454 "/DELAYLOAD:wevtapi.dll", 455 "/DELAYLOAD:wininet.dll", 456 "/DELAYLOAD:winusb.dll", 457 "/DELAYLOAD:wsock32.dll", 458 "/DELAYLOAD:wtsapi32.dll", 459 ] 460} 461 462# This config (along with `:delayloads`) applies to chrome.exe & chrome_elf.dll. 463# Entries should not appear in both configs. 464config("delayloads_not_for_child_dll") { 465 ldflags = [ 466 "/DELAYLOAD:crypt32.dll", 467 "/DELAYLOAD:dbghelp.dll", 468 "/DELAYLOAD:dhcpcsvc.dll", 469 "/DELAYLOAD:dwrite.dll", 470 "/DELAYLOAD:iphlpapi.dll", 471 "/DELAYLOAD:oleaut32.dll", 472 "/DELAYLOAD:secur32.dll", 473 "/DELAYLOAD:userenv.dll", 474 "/DELAYLOAD:winhttp.dll", 475 "/DELAYLOAD:winmm.dll", 476 "/DELAYLOAD:winspool.drv", 477 "/DELAYLOAD:wintrust.dll", 478 "/DELAYLOAD:ws2_32.dll", 479 ] 480} 481 482# CRT -------------------------------------------------------------------------- 483 484# Configures how the runtime library (CRT) is going to be used. 485# See https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx for a reference of 486# what each value does. 487config("default_crt") { 488 if (is_component_build) { 489 # Component mode: dynamic CRT. Since the library is shared, it requires 490 # exceptions or will give errors about things not matching, so keep 491 # exceptions on. 492 configs = [ ":dynamic_crt" ] 493 } else { 494 if (current_os == "winuwp") { 495 # https://blogs.msdn.microsoft.com/vcblog/2014/06/10/the-great-c-runtime-crt-refactoring/ 496 # contains a details explanation of what is happening with the Windows 497 # CRT in Visual Studio releases related to Windows store applications. 498 configs = [ ":dynamic_crt" ] 499 } else { 500 # Desktop Windows: static CRT. 501 configs = [ ":static_crt" ] 502 } 503 } 504} 505 506# Use this to force use of the release CRT when building perf-critical build 507# tools that need to be fully optimized even in debug builds, for those times 508# when the debug CRT is part of the bottleneck. This also avoids *implicitly* 509# defining _DEBUG. 510config("release_crt") { 511 if (is_component_build) { 512 cflags = [ "/MD" ] 513 514 # /MD specifies msvcrt.lib as the CRT library, which is the dynamic+release 515 # version. Rust needs to agree, and its default mode is dynamic+release, so 516 # we do nothing here. See https://github.com/rust-lang/rust/issues/39016. 517 518 if (use_custom_libcxx) { 519 # On Windows, including libcpmt[d]/msvcprt[d] explicitly links the C++ 520 # standard library, which libc++ needs for exception_ptr internals. 521 ldflags = [ "/DEFAULTLIB:msvcprt.lib" ] 522 } 523 } else { 524 cflags = [ "/MT" ] 525 526 # /MT specifies libcmt.lib as the CRT library, which is the static+release 527 # version. Rust needs to agree, so we tell it to use the static+release CRT 528 # as well. See https://github.com/rust-lang/rust/issues/39016. 529 rustflags = [ "-Ctarget-feature=+crt-static" ] 530 531 if (use_custom_libcxx) { 532 ldflags = [ "/DEFAULTLIB:libcpmt.lib" ] 533 } 534 } 535} 536 537config("dynamic_crt") { 538 if (is_debug) { 539 # This pulls in the DLL debug CRT and defines _DEBUG 540 cflags = [ "/MDd" ] 541 542 # /MDd specifies msvcrtd.lib as the CRT library. Rust needs to agree, so we 543 # specify it explicitly. Rust defaults to the dynamic+release library, which 544 # we remove here, and then replace. See 545 # https://github.com/rust-lang/rust/issues/39016. 546 rustflags = [ 547 "-Clink-arg=/nodefaultlib:msvcrt.lib", 548 "-Clink-arg=msvcrtd.lib", 549 ] 550 551 if (use_custom_libcxx) { 552 ldflags = [ "/DEFAULTLIB:msvcprtd.lib" ] 553 } 554 } else { 555 cflags = [ "/MD" ] 556 557 # /MD specifies msvcrt.lib as the CRT library, which is the dynamic+release 558 # version. Rust needs to agree, and its default mode is dynamic+release, so 559 # we do nothing here. See https://github.com/rust-lang/rust/issues/39016. 560 561 if (use_custom_libcxx) { 562 ldflags = [ "/DEFAULTLIB:msvcprt.lib" ] 563 } 564 } 565} 566 567config("static_crt") { 568 if (is_debug) { 569 # This pulls in the static debug CRT and defines _DEBUG 570 cflags = [ "/MTd" ] 571 572 # /MTd specifies libcmtd.lib as the CRT library. Rust needs to agree, so we 573 # specify it explicitly. We tell Rust that we're using the static CRT but 574 # remove the release library that it chooses, and replace with the debug 575 # library. See https://github.com/rust-lang/rust/issues/39016. 576 rustflags = [ 577 "-Ctarget-feature=+crt-static", 578 "-Clink-arg=/nodefaultlib:libcmt.lib", 579 "-Clink-arg=libcmtd.lib", 580 ] 581 582 if (use_custom_libcxx) { 583 ldflags = [ "/DEFAULTLIB:libcpmtd.lib" ] 584 } 585 } else { 586 cflags = [ "/MT" ] 587 588 # /MT specifies libcmt.lib as the CRT library, which is the static+release 589 # version. Rust needs to agree, so we tell it to use the static+release CRT 590 # as well. See https://github.com/rust-lang/rust/issues/39016. 591 rustflags = [ "-Ctarget-feature=+crt-static" ] 592 593 if (use_custom_libcxx) { 594 ldflags = [ "/DEFAULTLIB:libcpmt.lib" ] 595 } 596 } 597} 598 599# Subsystem -------------------------------------------------------------------- 600 601# This is appended to the subsystem to specify a minimum version. 602# The number after the comma is the minimum required OS version. 603# Set to 10.0 since we only support >= Win10 since M110. 604subsystem_version_suffix = ",10.0" 605 606config("console") { 607 ldflags = [ "/SUBSYSTEM:CONSOLE$subsystem_version_suffix" ] 608} 609config("windowed") { 610 ldflags = [ "/SUBSYSTEM:WINDOWS$subsystem_version_suffix" ] 611} 612 613# Incremental linking ---------------------------------------------------------- 614 615# Applies incremental linking or not depending on the current configuration. 616config("default_incremental_linking") { 617 # Enable incremental linking for debug builds and all component builds - any 618 # builds where performance is not job one. 619 # TODO(thakis): Always turn this on with lld, no reason not to. 620 if (is_debug || is_component_build) { 621 ldflags = [ "/INCREMENTAL" ] 622 if (use_lld) { 623 # lld doesn't use ilk files and doesn't really have an incremental link 624 # mode; the only effect of the flag is that the .lib file timestamp isn't 625 # updated if the .lib doesn't change. 626 # TODO(thakis): Why pass /OPT:NOREF for lld, but not otherwise? 627 # TODO(thakis): /INCREMENTAL is on by default in link.exe, but not in 628 # lld. 629 ldflags += [ "/OPT:NOREF" ] 630 631 # TODO(crbug.com/40267564): Mixing incrememntal and icf produces an error 632 # in lld-link. 633 ldflags += [ "/OPT:NOICF" ] 634 } 635 } else { 636 ldflags = [ "/INCREMENTAL:NO" ] 637 } 638} 639 640# Character set ---------------------------------------------------------------- 641 642# Not including this config means "ansi" (8-bit system codepage). 643config("unicode") { 644 defines = [ 645 "_UNICODE", 646 "UNICODE", 647 ] 648} 649 650# Lean and mean ---------------------------------------------------------------- 651 652# Some third party code might not compile with WIN32_LEAN_AND_MEAN so we have 653# to have a separate config for it. Remove this config from your target to 654# get the "bloaty and accommodating" version of windows.h. 655config("lean_and_mean") { 656 defines = [ "WIN32_LEAN_AND_MEAN" ] 657} 658 659# Nominmax -------------------------------------------------------------------- 660 661# Some third party code defines NOMINMAX before including windows.h, which 662# then causes warnings when it's been previously defined on the command line. 663# For such targets, this config can be removed. 664 665config("nominmax") { 666 defines = [ "NOMINMAX" ] 667} 668