From the very beginning, the PVS-Studio C ++ analyzer for Windows (then still Viva64 version 1.00 in 2006) was assembled with the MSVC compiler. With the release of new C ++ releases, the analyzer core learned to work on Linux and macOS, and the project structure was switched to use CMake. But on Windows, the build was still done using the MSVC compiler. On April 29, 2019, the Visual Studio developers announced the inclusion of a set of LLVM utilities and the Clang compiler in their development environment. And now we finally got our hands on to try it in action.
Performance testing
SelfTester. . , - , , . SelfTester " β ".
β . , , SelfTester' . , .
C++ Clang, SelfTester 11 .
13% β , , , ?
, . 8 , 1,6 ( ~500 - ).
, LTO ( ) .
, .
Clang
CMake .
Clang Visual Studio Installer.
Clang-cl β "", clang cl.exe. , MSBuild, .
LLVM, GitHub. , Visual Studio . toolset' llvm, clangcl, .
toolchain solution Visual Studio:
cmake -G "Visual Studio 16 2019" -Tclangcl <src>
GUI:
, . , , .
lang-cl CL, , .
, /W4 /WX. Clang , . :
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
....
if (WIN32)
add_compile_options(-Wno-error=deprecated-declarations
-Wno-error=reorder-ctor
-Wno-error=format-security
-Wno-error=macro-redefined
-Wno-error=bitwise-op-parentheses
-Wno-error=missing-field-initializers
-Wno-error=overloaded-virtual
-Wno-error=invalid-source-encoding
-Wno-error=multichar
-Wno-unused-local-typedef
-Wno-c++11-narrowing)
....
endif()
endif()
.
GCC Clang int128, MSVC Windows. Int128 Windows ( ifdef', C/C++). , :
if (MSVC)
set(DEFAULT_INT128_ASM ON)
else ()
set(DEFAULT_INT128_ASM OFF)
endif ()
if (MSVC AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(DEFAULT_INT128_ASM ON)
else ()
set(DEFAULT_INT128_ASM OFF)
endif ()
builtin' (lld) , clang.exe clang-cl.exe. MSBuild , , . , , .
if (CMAKE_GENERATOR MATCHES "Visual Studio")
link_libraries("$(LLVMInstallDir)\\lib\\clang\\\
${CMAKE_CXX_COMPILER_VERSION}\\lib\\windows\\\
clang_rt.builtins-x86_64.lib")
else()
link_libraries(clang_rt.builtins-x86_64)
endif()
! . :
- IntegerInterval, :
Dataflow- Int128, SIMD-. :
MOVAPS SIMD-. , 0, 8. , :
class alignas(16) Int128
.
- Docker-:
MSVC , Clang . , Windows Microsoft Visual C++ Redistributable. , .
, , 10%.
PVS-Studio Windows Clang.