msvc_compiler.conf 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. _MSVC_MACRO=_WIN32_WINNT
  2. _MSVC_WINDOWS7=0x0601
  3. _MSVC_WINDOWS8=0x0602
  4. _MSVC_WARNS_ENABLED=
  5. # 'expression' : signed/unsigned mismatch
  6. _MSVC_WARNS_ENABLED+=/w14018
  7. # 'class' : class has virtual functions, but destructor is not virtual
  8. _MSVC_WARNS_ENABLED+=/w14265
  9. # 'operator' : expression is always false
  10. _MSVC_WARNS_ENABLED+=/w14296
  11. # missing type specifier - int assumed
  12. _MSVC_WARNS_ENABLED+=/w14431
  13. _MSVC_WARNS_AS_ERRORS=
  14. # 'function' undefined; assuming extern returning int
  15. _MSVC_WARNS_AS_ERRORS+=/we4013
  16. _MSVC_WARNS_DISABLED=
  17. # conditional expression is constant
  18. _MSVC_WARNS_DISABLED+=/wd4127
  19. # nonstandard extension used : zero-sized array in struct/union
  20. _MSVC_WARNS_DISABLED+=/wd4200
  21. # nonstandard extension used : nameless struct/union
  22. _MSVC_WARNS_DISABLED+=/wd4201
  23. # elements of array will be default initialized
  24. _MSVC_WARNS_DISABLED+=/wd4351
  25. # 'this' : used in base member initializer list
  26. _MSVC_WARNS_DISABLED+=/wd4355
  27. # decorated name length exceeded, name was truncated
  28. _MSVC_WARNS_DISABLED+=/wd4503
  29. # default constructor could not be generated
  30. _MSVC_WARNS_DISABLED+=/wd4510
  31. # copy constructor could not be generated
  32. _MSVC_WARNS_DISABLED+=/wd4511
  33. # assignment operator could not be generated
  34. _MSVC_WARNS_DISABLED+=/wd4512
  35. # check operator precedence for possible error; use parentheses to clarify precedence
  36. _MSVC_WARNS_DISABLED+=/wd4554
  37. # 'object' can never be instantiated - user defined constructor required
  38. _MSVC_WARNS_DISABLED+=/wd4610
  39. # assignment within conditional expression
  40. _MSVC_WARNS_DISABLED+=/wd4706
  41. # forcing value to bool 'true' or 'false' (performance warning)
  42. _MSVC_WARNS_DISABLED+=/wd4800
  43. # The POSIX name for this item is deprecated
  44. _MSVC_WARNS_DISABLED+=/wd4996
  45. # function marked as __forceinline not inlined
  46. _MSVC_WARNS_DISABLED+=/wd4714
  47. # 'TAtomic' : top-level volatile in cast is ignored
  48. _MSVC_WARNS_DISABLED+=/wd4197
  49. # 'initializing' : conversion from 'int' to 'ui32', signed/unsigned mismatch
  50. _MSVC_WARNS_DISABLED+=/wd4245
  51. # 'ystd::function<void (uint8_t *)>': structure was padded due to alignment specifier
  52. _MSVC_WARNS_DISABLED+=/wd4324
  53. # 'register' is no longer a supported storage class
  54. _MSVC_WARNS_DISABLED+=/wd5033
  55. _C_WARNINGS_CLANG_CL=
  56. _CXX_WARNINGS_CLANG_CL=
  57. _CXX_WARNINGS_CLANG_CL_IDE_MSVS=
  58. when ($CLANG_CL == "yes") {
  59. _C_WARNINGS_CLANG_CL=\
  60. -Wno-format \
  61. -Wno-parentheses \
  62. -Wno-unknown-warning-option
  63. _CXX_WARNINGS_CLANG_CL=\
  64. -Wimport-preprocessor-directive-pedantic \
  65. -Woverloaded-virtual \
  66. -Wno-ambiguous-reversed-operator \
  67. -Wno-defaulted-function-deleted \
  68. -Wno-deprecated-anon-enum-enum-conversion \
  69. -Wno-deprecated-enum-enum-conversion \
  70. -Wno-deprecated-enum-float-conversion \
  71. -Wno-deprecated-volatile \
  72. -Wno-undefined-var-template
  73. when ($IDE_MSVS == "yes") {
  74. _CXX_WARNINGS_CLANG_CL_IDE_MSVS=-Wno-unused-command-line-argument
  75. }
  76. }
  77. _C_WARNINGS =$_MSVC_WARNS_AS_ERRORS
  78. _C_WARNINGS+=$_MSVC_WARNS_ENABLED
  79. _C_WARNINGS+=$_MSVC_WARNS_DISABLED
  80. _C_WARNINGS+=$_C_WARNINGS_CLANG_CL
  81. _CXX_WARNINGS =
  82. _CXX_WARNINGS+=$_CXX_WARNINGS_CLANG_CL
  83. _CXX_WARNINGS+=$_CXX_WARNINGS_CLANG_CL_IDE_MSVS
  84. _WINAPI_UNICODE=no
  85. _DEFINES_ARCH=
  86. when ($ARCH_X86_64 == "yes") {
  87. _DEFINES_ARCH=/D_WIN64 /DWIN64
  88. }
  89. elsewhen ($ARCH_ARMV7 == "yes") {
  90. _DEFINES_ARCH=/D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE /D__arm__
  91. }
  92. _DEFINES_WIN32_WINNT=/D$_MSVC_MACRO=$_MSVC_WINDOWS7
  93. when ($_WINAPI_UNICODE == "yes") {
  94. _DEFINES_UNICODE=/DUNICODE /D_UNICODE
  95. }
  96. otherwise {
  97. _DEFINES_UNICODE=/D_MBCS
  98. }
  99. _C_DEFINES=\
  100. /DARCADIA_ROOT=${ARCADIA_ROOT} \
  101. /DARCADIA_BUILD_ROOT=${ARCADIA_BUILD_ROOT} \
  102. /DFAKEID=$CPP_FAKEID \
  103. /DWIN32 \
  104. /D_WIN32 \
  105. /D_WINDOWS \
  106. /D_CRT_SECURE_NO_WARNINGS \
  107. /D_CRT_NONSTDC_NO_WARNINGS \
  108. /D_USE_MATH_DEFINES \
  109. /D__STDC_CONSTANT_MACROS \
  110. /D__STDC_FORMAT_MACROS \
  111. /D_USING_V110_SDK71_ \
  112. /D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES \
  113. /DWIN32_LEAN_AND_MEAN \
  114. /DNOMINMAX
  115. _C_DEFINES+=$_DEFINES_ARCH
  116. _C_DEFINES+=$_DEFINES_WIN32_WINNT
  117. _C_DEFINES+=$_DEFINES_UNICODE
  118. C_DEFINES+=$_C_DEFINES
  119. _MSVC_FLAGS_CLANG=
  120. _MSVC_FLAGS_CLANG_ARCH=
  121. _MSVC_FLAGS_CLANG_EQ_2019=
  122. when ($CLANG_CL == "yes") {
  123. # -fcase-insensitive-paths
  124. # Allow <windows.h> to be included via <Windows.h> in case-sensitive file-systems.
  125. #
  126. # -fms-compatibility-version
  127. # At the time clang-cl identifies itself as MSVC 19.11:
  128. # (actual value can be found in clang/lib/Driver/ToolChains/MSVC.cpp, the syntax would be like
  129. # ```
  130. # MSVT = VersionTuple(19, 11);
  131. # ```
  132. #
  133. # We override this value to match current value of the actual MSVC being used.
  134. #
  135. _MSVC_FLAGS_CLANG=-fcase-insensitive-paths -fms-compatibility-version=19.21
  136. when ($ARCH_X86_64 == "yes") {
  137. _MSVC_FLAGS_CLANG_ARCH=-m64
  138. }
  139. elsewhen ($ARCH_I386 == "yes") {
  140. _MSVC_FLAGS_CLANG_ARCH=-m32
  141. }
  142. otherwise {
  143. _MSVC_FLAGS_CLANG_ARCH=
  144. }
  145. }
  146. _MSVC_FLAGS=/nologo /Zm500 /GR /bigobj /FC /EHs /errorReport:prompt $MSVC_INLINE_FLAG /utf-8
  147. # enable standard conforming mode
  148. _MSVC_FLAGS+=/permissive-
  149. _MSVC_FLAGS+=$_MSVC_FLAGS_ARCH_OPT
  150. _MSVC_FLAGS+=$_MSVC_FLAGS_CLANG
  151. _MSVC_FLAGS+=$_MSVC_FLAGS_CLANG_ARCH
  152. _MSVC_FLAGS+=$_MSVC_FLAGS_CLANG_EQ_2019
  153. _MSVC_FLAGS+=$_MSVC_FLAGS_INCLUDE
  154. MSVC_INLINE_OPTIMIZED=yes
  155. when ($MSVC_INLINE_OPTIMIZED == "yes") {
  156. MSVC_INLINE_FLAG=/Zc:inline
  157. }
  158. when ($MSVC_INLINE_OPTIMIZED == "no") {
  159. MSVC_INLINE_FLAG=/Zc:inline-
  160. }
  161. # Use builtin offsetof implementation
  162. # instead of a crutcy macro defined in ucrt/stddef.h.
  163. # The latter can not be used in constexpr statements.
  164. _CXX_DEFINES=/D_CRT_USE_BUILTIN_OFFSETOF
  165. _FLAGS_C_ONLY=
  166. # Provide proper __cplusplus value
  167. # https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
  168. _CXX_FLAGS=/Zc:__cplusplus
  169. _FLAGS_MSVS_ONLY=
  170. DEBUG_INFO_FLAGS=/Z7
  171. when ($IDE_MSVS == "yes") {
  172. when ($CLANG_CL != "yes") {
  173. _FLAGS_MSVS_ONLY=/FD /MP
  174. }
  175. DEBUG_INFO_FLAGS=/Zi /FS
  176. }
  177. C_WARNING_OPTS=$_C_WARNINGS
  178. CXX_WARNING_OPTS=$_CXX_WARNINGS
  179. # https://msdn.microsoft.com/en-us/library/abx4dbyh.aspx
  180. when ($DLL_RUNTIME == "yes") {
  181. _FLAGS_DEBUG_RUNTIME=/MDd
  182. _FLAGS_RELEASE_RUNTIME=/MD
  183. }
  184. otherwise {
  185. _FLAGS_DEBUG_RUNTIME=/MTd
  186. _FLAGS_RELEASE_RUNTIME=/MT
  187. }
  188. CFLAGS_DEBUG=/Ob0 /Od /D_DEBUG $_FLAGS_DEBUG_RUNTIME
  189. CFLAGS_RELEASE=/Ox /Ob2 /Oi /DNDEBUG $_FLAGS_RELEASE_RUNTIME
  190. MASMFLAGS=
  191. _MASM_IO=/nologo /c /Fo${output;suf=${OBJECT_SUF}:SRC} ${input;msvs_source:SRC}
  192. when ($ARCH_ARMV7) {
  193. _MASM_IO=-o ${output;suf=${OBJECT_SUF}:SRC} ${input;msvs_source:SRC}
  194. }
  195. OBJ_CROSS_SUF=$OBJ_SUF
  196. OBJECT_SUF=$OBJ_SUF.obj
  197. CFLAGS+=$_MSVC_FLAGS $_FLAGS_MSVS_ONLY $CFLAGS_PER_TYPE $DEBUG_INFO_FLAGS $C_WARNING_OPTS $C_DEFINES $USER_CFLAGS $USER_CFLAGS_GLOBAL
  198. CXXFLAGS+=$CFLAGS $_STD_CXX $_CXX_FLAGS $_CXX_DEFINES $CXX_WARNING_OPTS $USER_CXXFLAGS $USER_CXXFLAGS_GLOBAL
  199. CONLYFLAGS+=$_FLAGS_C_ONLY $USER_CONLYFLAGS $USER_CONLYFLAGS_GLOBAL
  200. BC_CFLAGS+=$CFLAGS
  201. BC_CXXFLAGS+=$BC_CFLAGS $CXXFLAGS
  202. CFLAGS+=$_CFLAGS_UCRT_VC_INCLUDES
  203. when ($NO_WSHADOW == "yes") {
  204. C_WARNING_OPTS+=/wd4456 /wd4457
  205. }
  206. when ($NO_COMPILER_WARNINGS == "yes") {
  207. C_WARNING_OPTS=/w
  208. when ($CLANG_CL == "yes") {
  209. # Though /w is intended to switch off all the warnings,
  210. # it does not switch at least -Wregister and -Wreserved-user-defined-literal under clang-cl.
  211. #
  212. # Use -Wno-everything to force warning suppression.
  213. CXX_WARNING_OPTS=-Wno-everything
  214. }
  215. otherwise {
  216. CXX_WARNING_OPTS=
  217. }
  218. }
  219. when ($NO_OPTIMIZE == "yes") {
  220. OPTIMIZE=/Od
  221. }
  222. SFDL_FLAG=/E /C /P /TP /Fi$SFDL_TMP_OUT
  223. WERROR_FLAG=/WX
  224. CL_WRAPPER=${FIX_MSVC_OUTPUT} cl
  225. ML_WRAPPER=${FIX_MSVC_OUTPUT} ml
  226. when ($_UNDER_WINE == "yes") {
  227. CL_WRAPPER=
  228. ML_WRAPPER=
  229. }
  230. _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"}
  231. _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"}
  232. _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"}
  233. _SRC_M_CMD=$_EMPTY_CMD
  234. _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"}