It's been a while since I'm seeing all sorts of warnings when building with MSVC 2019 (some of them below):
[1921/4575] Building CXX object projects\compiler-rt\lib\s...rCommonSymbolizer.x86_64.dir\sanitizer_stack_store.cpp.obj D:\git\llvm-project\compiler-rt\lib\sanitizer_common\sanitizer_stack_store.cpp(241): warning C4200: nonstandard extension used: zero-sized array in struct/union D:\git\llvm-project\compiler-rt\lib\sanitizer_common\sanitizer_stack_store.cpp(241): note: This member will be ignored by a defaulted constructor or copy/move assignment operator [2110/4575] Building C object projects\compiler-rt\lib\builtins\CMakeFiles\clang_rt.builtins-x86_64.dir\udivmoddi4.c.objD:\git\llvm-project\compiler-rt\lib\builtins\udivmoddi4.c(62) : warning C4723: potential divide by 0 [2114/4575] Building C object projects\compiler-rt\lib\builtins\CMakeFiles\clang_rt.builtins-x86_64.dir\cpu_model.c.obj D:\git\llvm-project\compiler-rt\lib\builtins\cpu_model.c(18): warning C4067: unexpected tokens following preprocessor directive - expected a newline [2158/4575] Building C object projects\compiler-rt\lib\builtins\CMakeFiles\clang_rt.builtins-x86_64.dir\emutls.c.obj D:\git\llvm-project\compiler-rt\lib\builtins\emutls.c(39): warning C4200: nonstandard extension used: zero-sized array in struct/union [2179/4575] Building CXX object projects\compiler-rt\lib\u...keFiles\RTUbsan_cxx.x86_64.dir\ubsan_type_hash_win.cpp.obj C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\stdint.h(51): warning C4005: 'INT32_MIN': macro redefinition D:\git\llvm-project\compiler-rt\lib\sanitizer_common\sanitizer_internal_defs.h(365): note: see previous definition of 'INT32_MIN' C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\stdint.h(52): warning C4005: 'INT64_MIN': macro redefinition D:\git\llvm-project\compiler-rt\lib\sanitizer_common\sanitizer_internal_defs.h(371): note: see previous definition of 'INT64_MIN' C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\stdint.h(55): warning C4005: 'INT32_MAX': macro redefinition D:\git\llvm-project\compiler-rt\lib\sanitizer_common\sanitizer_internal_defs.h(367): note: see previous definition of 'INT32_MAX' C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\stdint.h(56): warning C4005: 'INT64_MAX': macro redefinition D:\git\llvm-project\compiler-rt\lib\sanitizer_common\sanitizer_internal_defs.h(373): note: see previous definition of 'INT64_MAX' C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\stdint.h(59): warning C4005: 'UINT32_MAX': macro redefinition D:\git\llvm-project\compiler-rt\lib\sanitizer_common\sanitizer_internal_defs.h(369): note: see previous definition of 'UINT32_MAX' C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\stdint.h(60): warning C4005: 'UINT64_MAX': macro redefinition D:\git\llvm-project\compiler-rt\lib\sanitizer_common\sanitizer_internal_defs.h(375): note: see previous definition of 'UINT64_MAX' C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\stdint.h(91): warning C4005: 'UINTPTR_MAX': macro redefinition D:\git\llvm-project\compiler-rt\lib\sanitizer_common\sanitizer_internal_defs.h(378): note: see previous definition of 'UINTPTR_MAX']
After this patch, there's no more warnings. Tested in various configs, with clang-cl and MSVC.
I thought /external: is only available in recent MSVC versions. Do we need to guard this on the version or check whether it's available?