diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn index 96d012d0e..a9b377ed4 100644 --- a/config/compiler/BUILD.gn +++ b/config/compiler/BUILD.gn @@ -17,6 +17,9 @@ if (current_cpu == "arm" || current_cpu == "arm64") { if (current_cpu == "mipsel" || current_cpu == "mips64el") { import("//build/config/mips.gni") } +if (is_win) { + import("//build/config/win/visual_studio_version.gni") +} if (is_mac) { import("//build/config/mac/symbols.gni") } @@ -909,20 +912,22 @@ config("default_warnings") { "/wd4459", ] - cflags += [ - # C4312 is a VS 2015 64-bit warning for integer to larger pointer. - # TODO(brucedawson): fix warnings, crbug.com/554200 - "/wd4312", - ] - - if (current_cpu == "x86") { + if (visual_studio_version == "2015") { cflags += [ - # VC++ 2015 changes 32-bit size_t truncation warnings from 4244 to - # 4267. Example: short TruncTest(size_t x) { return x; } - # Since we disable 4244 we need to disable 4267 during migration. - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - "/wd4267", + # C4312 is a VS 2015 64-bit warning for integer to larger pointer. + # TODO(brucedawson): fix warnings, crbug.com/554200 + "/wd4312", ] + + if (current_cpu == "x86") { + cflags += [ + # VC++ 2015 changes 32-bit size_t truncation warnings from 4244 to + # 4267. Example: short TruncTest(size_t x) { return x; } + # Since we disable 4244 we need to disable 4267 during migration. + # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. + "/wd4267", + ] + } } # VS xtree header file needs to be patched or 4702 (unreachable code @@ -935,6 +940,7 @@ config("default_warnings") { # Building with Clang on Windows is a work in progress and very # experimental. See crbug.com/82385. + # Keep this in sync with the similar block in build/common.gypi if (is_clang) { cflags += [ # TODO(hans): Make this list shorter eventually, http://crbug.com/504657 @@ -1544,7 +1550,7 @@ config("symbols") { import("//build/toolchain/goma.gni") cflags = [ "/Zi" ] # Produce PDB file, no edit and continue. - if (is_win_fastlink) { + if (is_win_fastlink && visual_studio_version != "2013") { # Tell VS 2015+ to create a PDB that references debug # information in .obj and .lib files instead of copying # it all. This flag is incompatible with /PROFILE diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn index 3da274701..52ae78f9c 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn @@ -48,24 +48,36 @@ config("compiler") { cflags_c = [ "/TC" ] cflags_cc = [ "/TP" ] - cflags += [ - # Tell the compiler to crash on failures. This is undocumented - # and unsupported but very handy. - "/d2FastFail", + # Flags not supported in version 2013. + if (visual_studio_version != "2013" && visual_studio_version != "2013e") { + cflags += [ + # Tell the compiler to crash on failures. This is undocumented + # and unsupported but very handy. + "/d2FastFail", + ] + } - # Work around crbug.com/526851, bug in VS 2015 RTM compiler. - "/Zc:sizedDealloc-", + if (visual_studio_version == "2015") { + cflags += [ + # Work around crbug.com/526851, bug in VS 2015 RTM compiler. + "/Zc:sizedDealloc-", - # Disable thread-safe statics to avoid overhead and because - # they are disabled on other platforms. See crbug.com/587210 - # and -fno-threadsafe-statics. - "/Zc:threadSafeInit-", - ] + # Disable thread-safe statics to avoid overhead and because + # they are disabled on other platforms. See crbug.com/587210 + # and -fno-threadsafe-statics. + "/Zc:threadSafeInit-", + ] + } # Building with Clang on Windows is a work in progress and very # experimental. See crbug.com/82385. + # Keep this in sync with the similar block in build/common.gypi if (is_clang) { - cflags += [ "-fmsc-version=1900" ] + if (visual_studio_version == "2013") { + cflags += [ "-fmsc-version=1800" ] + } else if (visual_studio_version == "2015") { + cflags += [ "-fmsc-version=1900" ] + } if (current_cpu == "x86") { cflags += [ "-m32" ] diff --git a/config/win/visual_studio_version.gni b/config/win/visual_studio_version.gni index 982fbe8d3..5bfa9a762 100644 --- a/config/win/visual_studio_version.gni +++ b/config/win/visual_studio_version.gni @@ -9,7 +9,7 @@ declare_args() { visual_studio_path = "" # Version of Visual Studio pointed to by the visual_studio_path. - # Currently always "2015". + # Use "2013" for Visual Studio 2013, or "2013e" for the Express version. visual_studio_version = "" # Directory of the Windows driver kit. If visual_studio_path is empty, this