aboutsummaryrefslogtreecommitdiffstats
path: root/build/conf/compilers/msvc_compiler.conf
blob: 27b53a64cdece50ac074f6b0ba70c66249f9ffcd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
_MSVC_MACRO=_WIN32_WINNT
_MSVC_WINDOWS7=0x0601
_MSVC_WINDOWS8=0x0602

_MSVC_WARNS_ENABLED=
# 'expression' : signed/unsigned mismatch
_MSVC_WARNS_ENABLED+=/w14018
# 'class' : class has virtual functions, but destructor is not virtual
_MSVC_WARNS_ENABLED+=/w14265
# 'operator' : expression is always false
_MSVC_WARNS_ENABLED+=/w14296
# missing type specifier - int assumed
_MSVC_WARNS_ENABLED+=/w14431

_MSVC_WARNS_AS_ERRORS=
# 'function' undefined; assuming extern returning int
_MSVC_WARNS_AS_ERRORS+=/we4013

_MSVC_WARNS_DISABLED=
# conditional expression is constant
_MSVC_WARNS_DISABLED+=/wd4127
# nonstandard extension used : zero-sized array in struct/union
_MSVC_WARNS_DISABLED+=/wd4200
# nonstandard extension used : nameless struct/union
_MSVC_WARNS_DISABLED+=/wd4201
# elements of array will be default initialized
_MSVC_WARNS_DISABLED+=/wd4351
# 'this' : used in base member initializer list
_MSVC_WARNS_DISABLED+=/wd4355
# decorated name length exceeded, name was truncated
_MSVC_WARNS_DISABLED+=/wd4503
# default constructor could not be generated
_MSVC_WARNS_DISABLED+=/wd4510
# copy constructor could not be generated
_MSVC_WARNS_DISABLED+=/wd4511
# assignment operator could not be generated
_MSVC_WARNS_DISABLED+=/wd4512
# check operator precedence for possible error; use parentheses to clarify precedence
_MSVC_WARNS_DISABLED+=/wd4554
# 'object' can never be instantiated - user defined constructor required
_MSVC_WARNS_DISABLED+=/wd4610
# assignment within conditional expression
_MSVC_WARNS_DISABLED+=/wd4706
# forcing value to bool 'true' or 'false' (performance warning)
_MSVC_WARNS_DISABLED+=/wd4800
# The POSIX name for this item is deprecated
_MSVC_WARNS_DISABLED+=/wd4996
# function marked as __forceinline not inlined
_MSVC_WARNS_DISABLED+=/wd4714
# 'TAtomic' : top-level volatile in cast is ignored
_MSVC_WARNS_DISABLED+=/wd4197
# 'initializing' : conversion from 'int' to 'ui32', signed/unsigned mismatch
_MSVC_WARNS_DISABLED+=/wd4245
# 'ystd::function<void (uint8_t *)>': structure was padded due to alignment specifier
_MSVC_WARNS_DISABLED+=/wd4324
# 'register' is no longer a supported storage class
_MSVC_WARNS_DISABLED+=/wd5033

_C_WARNINGS_CLANG_CL=
_CXX_WARNINGS_CLANG_CL=
_CXX_WARNINGS_CLANG_CL_IDE_MSVS=
when ($CLANG_CL == "yes") {
    _C_WARNINGS_CLANG_CL=\
        -Wno-format \
        -Wno-parentheses \
        -Wno-unknown-warning-option

    _CXX_WARNINGS_CLANG_CL=\
        -Wimport-preprocessor-directive-pedantic \
        -Woverloaded-virtual \
        -Wno-ambiguous-reversed-operator \
        -Wno-defaulted-function-deleted \
        -Wno-deprecated-anon-enum-enum-conversion \
        -Wno-deprecated-enum-enum-conversion \
        -Wno-deprecated-enum-float-conversion \
        -Wno-deprecated-volatile \
        -Wno-undefined-var-template

    when ($IDE_MSVS == "yes") {
        _CXX_WARNINGS_CLANG_CL_IDE_MSVS=-Wno-unused-command-line-argument
    }
}

_C_WARNINGS =$_MSVC_WARNS_AS_ERRORS
_C_WARNINGS+=$_MSVC_WARNS_ENABLED
_C_WARNINGS+=$_MSVC_WARNS_DISABLED
_C_WARNINGS+=$_C_WARNINGS_CLANG_CL

_CXX_WARNINGS =
_CXX_WARNINGS+=$_CXX_WARNINGS_CLANG_CL
_CXX_WARNINGS+=$_CXX_WARNINGS_CLANG_CL_IDE_MSVS

_WINAPI_UNICODE=no

_DEFINES_ARCH=
when ($ARCH_X86_64 == "yes") {
    _DEFINES_ARCH=/D_WIN64 /DWIN64
}
elsewhen ($ARCH_ARMV7 == "yes") {
    _DEFINES_ARCH=/D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE /D__arm__
}

_DEFINES_WIN32_WINNT=/D$_MSVC_MACRO=$_MSVC_WINDOWS7

when ($_WINAPI_UNICODE == "yes") {
    _DEFINES_UNICODE=/DUNICODE /D_UNICODE
}
otherwise {
    _DEFINES_UNICODE=/D_MBCS
}

_C_DEFINES=\
    /DARCADIA_ROOT=${ARCADIA_ROOT} \
    /DARCADIA_BUILD_ROOT=${ARCADIA_BUILD_ROOT} \
    /DFAKEID=$CPP_FAKEID \
    /DWIN32 \
    /D_WIN32 \
    /D_WINDOWS \
    /D_CRT_SECURE_NO_WARNINGS \
    /D_CRT_NONSTDC_NO_WARNINGS \
    /D_USE_MATH_DEFINES \
    /D__STDC_CONSTANT_MACROS \
    /D__STDC_FORMAT_MACROS \
    /D_USING_V110_SDK71_ \
    /D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES \
    /DWIN32_LEAN_AND_MEAN \
    /DNOMINMAX

_C_DEFINES+=$_DEFINES_ARCH
_C_DEFINES+=$_DEFINES_WIN32_WINNT
_C_DEFINES+=$_DEFINES_UNICODE

C_DEFINES+=$_C_DEFINES

_MSVC_FLAGS_CLANG=
_MSVC_FLAGS_CLANG_ARCH=
_MSVC_FLAGS_CLANG_EQ_2019=
when ($CLANG_CL == "yes") {
    # -fcase-insensitive-paths
    # Allow <windows.h> to be included via <Windows.h> in case-sensitive file-systems.
    #
    # -fms-compatibility-version
    # At the time clang-cl identifies itself as MSVC 19.11:
    # (actual value can be found in clang/lib/Driver/ToolChains/MSVC.cpp, the syntax would be like
    # ```
    # MSVT = VersionTuple(19, 11);
    # ```
    #
    # We override this value to match current value of the actual MSVC being used.
    #
    _MSVC_FLAGS_CLANG=-fcase-insensitive-paths -fms-compatibility-version=19.21
    when ($ARCH_X86_64 == "yes") {
        _MSVC_FLAGS_CLANG_ARCH=-m64
    }
    elsewhen ($ARCH_I386 == "yes") {
        _MSVC_FLAGS_CLANG_ARCH=-m32
    }
    otherwise {
        _MSVC_FLAGS_CLANG_ARCH=
    }

}

_MSVC_FLAGS=/nologo /Zm500 /GR /bigobj /FC /EHs /errorReport:prompt $MSVC_INLINE_FLAG /utf-8
# enable standard conforming mode
_MSVC_FLAGS+=/permissive-
_MSVC_FLAGS+=$_MSVC_FLAGS_ARCH_OPT
_MSVC_FLAGS+=$_MSVC_FLAGS_CLANG
_MSVC_FLAGS+=$_MSVC_FLAGS_CLANG_ARCH
_MSVC_FLAGS+=$_MSVC_FLAGS_CLANG_EQ_2019
_MSVC_FLAGS+=$_MSVC_FLAGS_INCLUDE

MSVC_INLINE_OPTIMIZED=yes
when ($MSVC_INLINE_OPTIMIZED == "yes") {
    MSVC_INLINE_FLAG=/Zc:inline
}
when ($MSVC_INLINE_OPTIMIZED == "no") {
    MSVC_INLINE_FLAG=/Zc:inline-
}

# Use builtin offsetof implementation
# instead of a crutcy macro defined in ucrt/stddef.h.
# The latter can not be used in constexpr statements.
_CXX_DEFINES=/D_CRT_USE_BUILTIN_OFFSETOF

_FLAGS_C_ONLY=

# Provide proper __cplusplus value
# https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
_CXX_FLAGS=/Zc:__cplusplus

_FLAGS_MSVS_ONLY=
DEBUG_INFO_FLAGS=/Z7
when ($IDE_MSVS == "yes") {
    when ($CLANG_CL != "yes") {
        _FLAGS_MSVS_ONLY=/FD /MP
    }
    DEBUG_INFO_FLAGS=/Zi /FS
}

C_WARNING_OPTS=$_C_WARNINGS
CXX_WARNING_OPTS=$_CXX_WARNINGS

# https://msdn.microsoft.com/en-us/library/abx4dbyh.aspx
when ($DLL_RUNTIME == "yes") {
    _FLAGS_DEBUG_RUNTIME=/MDd
    _FLAGS_RELEASE_RUNTIME=/MD
}
otherwise {
    _FLAGS_DEBUG_RUNTIME=/MTd
    _FLAGS_RELEASE_RUNTIME=/MT
}
CFLAGS_DEBUG=/Ob0 /Od /D_DEBUG $_FLAGS_DEBUG_RUNTIME
CFLAGS_RELEASE=/Ox /Ob2 /Oi /DNDEBUG $_FLAGS_RELEASE_RUNTIME

MASMFLAGS=
_MASM_IO=/nologo /c /Fo${output;suf=${OBJECT_SUF}:SRC} ${input;msvs_source:SRC}
when ($ARCH_ARMV7) {
    _MASM_IO=-o ${output;suf=${OBJECT_SUF}:SRC} ${input;msvs_source:SRC}
}

OBJ_CROSS_SUF=$OBJ_SUF
OBJECT_SUF=$OBJ_SUF.obj

CFLAGS+=$_MSVC_FLAGS $_FLAGS_MSVS_ONLY $CFLAGS_PER_TYPE $DEBUG_INFO_FLAGS $C_WARNING_OPTS $C_DEFINES $USER_CFLAGS $USER_CFLAGS_GLOBAL
CXXFLAGS+=$CFLAGS $_STD_CXX $_CXX_FLAGS $_CXX_DEFINES $CXX_WARNING_OPTS $USER_CXXFLAGS $USER_CXXFLAGS_GLOBAL
CONLYFLAGS+=$_FLAGS_C_ONLY $USER_CONLYFLAGS $USER_CONLYFLAGS_GLOBAL

BC_CFLAGS+=$CFLAGS
BC_CXXFLAGS+=$BC_CFLAGS $CXXFLAGS

CFLAGS+=$_CFLAGS_UCRT_VC_INCLUDES

when ($NO_WSHADOW == "yes") {
    C_WARNING_OPTS+=/wd4456 /wd4457
}

when ($NO_COMPILER_WARNINGS == "yes") {
    C_WARNING_OPTS=/w
    when ($CLANG_CL == "yes") {
        # Though /w is intended to switch off all the warnings,
        # it does not switch at least -Wregister and -Wreserved-user-defined-literal under clang-cl.
        #
        # Use -Wno-everything to force warning suppression.
        CXX_WARNING_OPTS=-Wno-everything
    }
    otherwise {
        CXX_WARNING_OPTS=
    }
}

when ($NO_OPTIMIZE == "yes") {
    OPTIMIZE=/Od
}

SFDL_FLAG=/E /C /P /TP /Fi$SFDL_TMP_OUT
WERROR_FLAG=/WX

CL_WRAPPER=${FIX_MSVC_OUTPUT} cl
ML_WRAPPER=${FIX_MSVC_OUTPUT} ml
when ($_UNDER_WINE == "yes") {
    CL_WRAPPER=
    ML_WRAPPER=
}

_SRC_C_NODEPS_CMD=${TOOLCHAIN_ENV} ${CL_WRAPPER} ${C_COMPILER} /c /Fo${OUTFILE} ${SRC} ${EXTRA_C_FLAGS} ${pre=/I :INC} ${CFLAGS} ${hide;kv:"soe"} ${hide;kv:"p CC"} ${hide;kv:"pc yellow"}
_SRC_CPP_CMD=${TOOLCHAIN_ENV} ${CL_WRAPPER} ${CXX_COMPILER} /c /Fo$_COMPILE_OUTPUTS ${input;msvs_source:SRC} ${EXTRA_C_FLAGS} ${pre=/I :_C__INCLUDE} ${CXXFLAGS} ${SRCFLAGS} ${_LANG_CFLAGS_VALUE} ${hide;kv:"soe"} ${hide;kv:"p CC"} ${hide;kv:"pc yellow"}
_SRC_C_CMD=${TOOLCHAIN_ENV} ${CL_WRAPPER} ${C_COMPILER} /c /Fo$_COMPILE_OUTPUTS ${input;msvs_source:SRC} ${EXTRA_C_FLAGS} ${pre=/I :_C__INCLUDE} ${CFLAGS} ${CONLYFLAGS} ${SRCFLAGS} ${hide;kv:"soe"} ${hide;kv:"p CC"} ${hide;kv:"pc yellow"}
_SRC_M_CMD=$_EMPTY_CMD
_SRC_MASM_CMD=${cwd:ARCADIA_BUILD_ROOT} ${TOOLCHAIN_ENV} ${ML_WRAPPER} ${MASM_COMPILER} ${MASMFLAGS} ${SRCFLAGS} $_MASM_IO ${kv;hide:"p AS"} ${kv;hide:"pc yellow"}