LLVM-MSVC: Open Source LLVM Fork for Windows Kernel Development
What is LLVM-MSVC?
LLVM-MSVC is a specialized fork of the LLVM/Clang compiler toolchain that provides explicit compatibility with Microsoft Visual C++ (MSVC) features. It enables developers to compile Windows kernel mode drivers and user-mode applications using LLVM while maintaining full compatibility with MSVC 2022 syntax and ABI.
The project was created by Back Engineering to address the gap between LLVM/Clang's GCC-style approach and MSVC's unique syntax requirements. Key features include Structured Exception Handling (SEH) support, VMX intrinsics for virtualization development, naked function support for x64 assembly, and ARM64 driver support.
Key Features and Capabilities
- MSVC 2022 Compatibility: Full support for MSVC syntax, ensuring existing Windows codebases compile without modification.
- SEH Support: Almost fully compatible with Structured Exception Handling, critical for Windows kernel development.
- VMX Intrinsics: Built-in support for __vmx_vmread, __vmx_vmwrite and other virtualization intrinsics.
- Windows Kernel Drivers: Supports x64 and ARM64 Windows kernel mode driver development.
- Android GKI Support: Compile AArch64 Android Generic Kernel Image (GKI) drivers.
- Naked X64 Assembly: Write inline assembly functions without compiler-generated prologue/epilogue.
- Multi-core Compilation: /MP flag support for parallel compilation across CPU cores.
- Link Time Optimization: /GL flag support for whole-program optimization.
Installation and Quick Start
To install LLVM-MSVC for Windows driver development:
- Install Visual Studio 2015-2022 (2022 recommended) with Windows Driver Kit (WDK) 11
- Download the llvm-msvc installer from GitHub Releases page
- Run the llvm-msvc_X86_64_installer-PDB.exe installer
- Create a new Windows driver project in Visual Studio
- Select "LLVM-MSVC_v143_KernelMode" as the platform toolset
- Build your project using standard Visual Studio workflows
Supported Platforms
LLVM-MSVC supports development on Windows, Linux, and macOS, targeting:
- x64 (AMD64) Windows kernel mode drivers
- ARM64 (AArch64) Windows kernel mode drivers
- AArch64 Android GKI drivers
- Windows user-mode applications requiring MSVC ABI compatibility
License and Availability
LLVM-MSVC is free and open source software licensed under AGPL-3.0. The source code is available on GitHub at github.com/backengineering/llvm-msvc. Prebuilt binaries are available for download from the GitHub Releases page.
Why Choose LLVM-MSVC Over Standard MSVC?
Developers choose LLVM-MSVC for several reasons:
- Better Optimization: LLVM's optimization passes can produce faster code than MSVC in many cases.
- Cross-Platform Development: Develop on Linux or macOS while targeting Windows.
- Modern C++ Support: Often faster adoption of new C++ standards.
- Open Source: Full access to compiler source code for customization.
- Consistent Toolchain: Use the same compiler infrastructure across different target platforms.