Microsoft promises Clang for Windows in November Visual C++ update
Improvement in cross-platform code is the aim
Microsoft will integrate the Clang open source C and C++ compiler with Visual C++ in an update expected in November 2015, according to presentations given at the recent CPPCon 2015 event in Bellevue, near Seattle.
Clang is a C, C++ and Objective-C compiler that generates intermediate code for LLVM, a related open source project, enabling it to target multiple platforms.
It was primarily developed by Apple, but has been open source since 2007, and is also used by Google, Sony and many others.
Visual Studio 2015 already integrates with Clang for Android and iOS development. If you are targeting Android you can choose between the GCC (Gnu C++) or Clang toolsets. Visual C++ iOS projects use a Mac as a remote build server.
The forthcoming Clang integration is different, since it uses Clang to compile Windows applications.
Visual C++ is comprised of several parts, including the Visual Studio IDE, the front-end compiler which generates an AST (Abstract Syntax Tree) representing the content of the program, and a back-end compiler which reads the AST and generates executable code.
The front-end compiler is called C1, and the back-end compiler C2. Two different teams within Microsoft work on C1 and C2.
Microsoft’s new integration uses Clang in place of C1, but continues to use C2 for the back-end. The steps, as presented by back-end leader Jim Radigan, are that Clang will emit LLVM IR (Intermediate Representation), which will then be converted into the intermediate form used by the C2 compiler, described by Radigan as tuples.
Code generation then continues as before, with C2’s UTC (Universal Tuple Compiler).
The purpose of Clang/C2 for Windows is to improve cross-platform support, as much for Microsoft’s own projects as for third-party developers. Microsoft’s approach with applications like Office is to put as much non-visual code as possible into cross-platform C++ code.
The mobile version of Office is now available on Android, iOS and the Windows 10 Universal Windows Platform. Using Clang for the front-end on all three platforms removes the possibility of bugs or workarounds caused by differences in C1 and Clang.
Developers will also welcome Clang because of its better standards compliance compared with Visual C++, for C as well as C++. Microsoft Engineering Manager Steve Carroll (from the front-end team), who also spoke at CPPCon, explained that while Microsoft’s support of the C99 and C11 standards is already much improved, Clang/C2 will complete it.
Carroll added that Microsoft is not abandoning C1 but will continue to improve it.
There are Microsoft extensions and Windows-specific features in the Visual C++ compilers which means they will still be needed. In addition, performance tests generally show slightly better performance for C1/C2 versus Clang/C2.
Radigan said Clang will not be forked and that Microsoft is contributing code back to the community to improve Clang and LLVM on Windows. No code specific to C2 will be proposed for the open source tools.
The initial release of Clang/C2 will be a preview, followed by a further update planned for February 2016.
There is more than Clang/C2 on the way for Visual C++. Microsoft is changing its approach to updates, so that more feature changes will be fully supported during the lifetime of Visual Studio 2015, rather than remaining in preview until the next major version. Support for asynchronous programming using “await” will be updated to match Microsoft’s current standards proposal, among other new features.
The company is also set to release a “build only” edition of Visual C++, which will install the compiler and command-line build tools without the Visual Studio IDE. ®
Sponsored: The Nuts and Bolts of Ransomware in 2016