blob: b69e93cdb4b3e2ba3e89b3fc0628679fbb0fcff4 [file] [log] [blame]
# Copyright 2023 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/config/win/visual_studio_version.gni")
# TODO(andrewsavage): No way host builds need all these flags
config("host") {
configs = [ ":common" ]
}
config("common") {
configs = []
cflags_cc = [ "/TP" ]
cflags = [ "/Z7" ]
ldflags = [
"/NXCOMPAT",
"/MANIFEST:NO",
]
libs = []
include_dirs = []
arflags = []
defines = [
"_UNICODE",
"UNICODE",
]
# msvs_base
# OutputDirectory and IntermediateDirectory, maybe CharacterSet
include_dirs += [
"$wdk_include_path/shared",
"$wdk_include_path/ucrt",
"$wdk_include_path/um",
"$wdk_include_path/winrt",
"$msvc_path/include",
]
cflags += [
"/EHsc",
"/std:c++14",
]
# msvs_debug/_devel/etc
ldflags += [ "/INCREMENTAL:NO" ]
if (is_debug) {
cflags += [
"/Od",
# Check stack frame validity and check for uninitialized variables at run time.
"/RTC1",
]
} else {
cflags += [ "/O2" ]
}
if (!is_gold) {
libs += [ "dbghelp.lib" ]
}
if (is_debug || is_devel) {
cflags += [
# Use debug multithreaded library.
"/MDd",
"/GS",
# Unit tests can have huge object files.
"/bigobj",
]
} else {
cflags += [
# Use release multithreaded library.
"/MD",
# Unreferenced variable.
# Often variables are only referenced in DCHECKs.
"/wd4189",
]
ldflags += [
"/OPT:REF",
"/OPT:ICF",
]
}
cflags += [
# Check for buffer overruns.
"/GS",
# "for" loop's initializer go out of scope after the for loop.
"/Zc:forScope",
# wchar_t is treated as a built-in type.
"/Zc:wchar_t",
# Don't send error reports to MS.
"/errorReport:none",
]
arflags += [
# Linking statically with C++/CX library is not recommended.
# TODO: Remove after removing ComponentExtensions
"/ignore:4264",
]
cflags += [
# Allow unused function input parameter.
"/wd4100",
# Conditional expression is constant.
# Triggers in many legitimate cases, like branching on a constant declared
# in type traits.
"/wd4127",
# Disable anonymous union warnings.
"/wd4201",
# 4244 (Level 2) - Implicit conversion from float to int
# 4244 (Level 3) - Implicit conversion from int to something smaller
# than int.
# 4244 (Level 4) - Implicit conversion of types, which may result in
# data loss.
"/wd4244",
# Class has virtual functions, but destructor is not virtual.
# Far less useful than in GCC because doesn't take into account the fact
# that destructor is not public.
"/wd4265",
# Inconsistent DLL linkage
"/wd4273",
# Matching delete operator for `new`. 4291 is also ignored by Chromium.
"/wd4291",
# Double -> float truncation. Not enabled on other compilers.
"/wd4305",
# cast truncates constant value.
# We do not care.
"/wd4309",
# casting constant number.
"/wd4310",
# An rvalue cannot be bound to a non-const reference.
# In previous versions of Visual C++, it was possible to bind an rvalue
# to a non-const reference in a direct initialization. This warning
# is useless as it simply describes proper C++ behavior.
"/wd4350",
# layout of class may have changed from a previous version of
# the compiler due to better packing of member. We don't care about
# binary compatibility with other compiler versions.
"/wd4371",
# relative include path contains '..'.
# This occurs in a lot third party libraries and we don't care.
"/wd4464",
# decorated name length exceeded, name was truncated.
"/wd4503",
# assignment operator could not be generated.
# This is expected for structs with const members.
"/wd4512",
# Unreferenced inline function has been removed.
# While detection of dead code is good, this warning triggers in
# third-party libraries which renders it useless.
"/wd4514",
# Expression before comma has no effect.
# Cannot be used because Microsoft uses _ASSERTE(("message", 0)) trick
# in malloc.h which is included pretty much everywhere.
"/wd4548",
# Use of noexcept in targets compiled without /EHsc triggers a warning
# "termination on exception is not guaranteed" which we consider benign
# because we don't expect exceptions to cross the boundary of modules
# compiled with /EHsc.
"/wd4577",
# Copy constructor could not be generated because a base class copy
# constructor is inaccessible.
# This is an expected consequence of using DISALLOW_COPY_AND_ASSIGN().
"/wd4625",
# Assignment operator could not be generated because a base class
# assignment operator is inaccessible.
# This is an expected consequence of using DISALLOW_COPY_AND_ASSIGN().
"/wd4626",
# Digraphs not supported.
"/wd4628",
# Sometimes template definitions and declarations are separate and MSVC
# complains when it fails to find the definition on seeing the template.
"/wd4661",
# Symbol is not defined as a preprocessor macro, replacing with '0'.
# Seems like common practice, used in Windows SDK and gtest.
"/wd4668",
# Function not inlined.
# It's up to the compiler to decide what to inline.
"/wd4710",
# Function selected for inline expansion.
# It's up to the compiler to decide what to inline.
"/wd4711",
# The type and order of elements caused the compiler to add padding
# to the end of a struct.
# Unsurprisingly, most of the structs become larger because of padding
# but it's a universally acceptable price for better performance.
"/wd4820",
# Disable static analyzer warning for std::min and std::max with
# objects.
# https://connect.microsoft.com/VisualStudio/feedback/details/783808/static-analyzer-warning-c28285-for-std-min-and-std-max
"/wd28285",
# Deprecated function warning.
"/wd4996",
# Compiler warnings introduced after upgrading to Visual Studio 2022.
# Implicit conversion from 'type' to bool. Possible information loss.
"/wd4800",
# Discarding return value of function with 'nodiscard' attribute.
"/wd4834",
"/wd4858",
# Unnamed class used in typedef name cannot declare members other than
# non-static data members, member enumerations, or member classes.
"/wd5208",
]
}