Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
C++ModernizationNewsRAD StudioWindows

[Yukon Beta Blog]: Win64 Clang Toolchains in RAD Studio 12

This blog post is based on a pre-release version of the RAD Studio software and it has been written with specific permission by Embarcadero. No feature is committed until the product GA release.

RAD Studio 12 is just around the corner, and we have exciting news to share!

In August, we ran an unusual webinar where we shared a behind-the-scenes look at some technology we’ve been working on for C++Builder and the C++ side of RAD Studio. One of the things we previewed was an upgraded Clang-based Win64 compiler – though not just an upgrade but some major technological improvements to core areas, with a new STL, a new linker, and more. It is a thorough rework of the entire toolchain with a strong eye to making the right decisions for quality and longevity.

New Clang

The C++ compiler is foundational to RAD Studio. Through the Clang & LLVM work, we make LLVM available to Delphi. And, of course, we need a modern, powerful C++ compiler to provide our C++ developers with the best source compatibility, libraries, app performance, and more.

Our goals for the work are:

  • Very high quality. A robust STL. A linker that can handle anything and any quantity you give it.
  • Excellent quality in all areas, such as exception handling
  • Excellent language standards compatibility.
  • High performance for the compiled code. Optimised runtimes.
  • Match platform standards as much as possible

How are we meeting those? Let’s go in reverse order.

Platform standards

The new toolchain is based on Clang 15*. The previous toolchain used the ELF object file format, a primarily Unix/Linux format, for historical reasons that are actually (long story) related to Kylix. For this toolchain, we are moving to COFF, which is the standard object file format for Windows compilers of any compiled language. Similarly, we are using the PDB debug format, which again is the standard. While we are not officially supporting any third party tools, there are many tools developers use which understand COFF & PDB and we hope that by adhering to the platform norms, we open up the opportunity to use a wide variety of tools with your apps and C++Builder.

[*] Clang 15 was current when this work started, and we are avoiding changing the wheels while the car is in motion. We plan to remain up to date and move forward with Clang itself in future.

High performance for the compiled code.

While we are aiming for correct compiled code behaviour above all else, we are also aiming for high performance. The new toolchain’s technology generates more optimized code, and allows additional optimisations that were not previously possible in future.

Cartoon of a rocketship labeled C++ taking off

Optimised runtimes

A C++ toolchain has multiple layers: a C runtime (providing things like printing to a console or file IO), a C++ runtime (providing things like exception handling), and the STL (providing C++ library functions like standard IO, algorithms, collections, etc.) For our toolchain, we are replacing all three.

Image showing three layers of the C++ runtime standard library C++ RTL and C RTL

Image showing three layers of the C++ runtime: standard library, C++ RTL, and C RTL. Image by DALL-E and David Millington

The C level runtime is using the Universal C Runtime (UCRT), a Windows component. It’s highly optimised and, echoing the platform standards, is part of Windows itself. It can also be installed on Windows 8, 7, Vista and even XP (note we do not support XP and Vista.) Of course, we’re adding our own methods that you’re used to from our runtime: if your code uses something of ours without you realising it wasn’t standard, don’t worry, it will be there.

The C++ runtime is new, and is based on a mixture of MinGW and LLVM. MinGW is an open source toolchain, though we are using only select carefully chosen parts. LLVM provides many key runtime areas. By focusing on LLVM we are also again sticking to standard libraries with known, shared behaviour.

Finally, the STL is LLVM’s libc++, an excellent, performant library.

Excellent language standards compatibility.

We run multiple test suites, and we see a much higher number of C++ and STL conformance tests passing with the new runtime trio than we did with the previous toolchain: a mark of the standards compliance, compatibility, and quality. We saw this even in our early internal versions and the passing tests just keep going up.

Excellent quality in all areas, such as exception handling

Our approach has been to do it right. Exception handling, for example, has always been a focus: in 10.4.2 we focused on improving core use cases and significantly improved quality. For the new toolchain, with a new C++ RTL, we are reworking this fully, generating hundreds of new tests for this behaviour alone. There are a wide variety of permutations: throw and catch in the same and different modules, rethrow, exceptions from Delphi, Delphi exceptions from C++, and many more. We also aim to pass this test suite for all except throw/catch in the same frame (something Clang itself does not support.)

A robust STL. A linker that can handle anything

Three chain links Image by DALL E 3I mentioned the STL above, but along with the change in object file format comes a change in linker.

Say goodbye to ilink.

Say hello to LLVM’s lld.

LLD has a very different architecture to ilink and we believe it will handle the complex, large apps that you build with ease.

Tech details

The toolchain uses:

  • Uses Clang 15
  • Uses LLVM’s lld as the linker
  • Emits COFF64 object files (note this means Delphi can also emit COFF64 object files in 12.0: the compiler option “-jf:coff” is specified by our targets files when the “-JL” or “-JPHN[E]” options are specified)
  • Emits PDB format debug info
  • Uses the Itanium ABI (not Microsoft ABI)
  • Uses LLVM’s libc++ STL
  • Uses UCRT for the C runtime
  • Uses a mix of LLVM and MinGW for the C++ runtime
  • Targets Win64
  • Named bcc64x

And of course the C++ extensions (property, closure, and so forth) and Delphi linking for VCL and FMX apps (this is not yet complete, and is coming), plus extensions that you may not even have realised were toolchain-dependent, such as auto-linking. This means you’ll get the same behaviour for your code – what you have already will remain working, of course – on this new, robust, modern, solid, performant, standardised, and exciting foundation.

Status

One key element of our approach to this upgrade has been to ‘do it right’: a solid foundation, thorough work, very high quality, and at every step, making the right decisions. We do not expect the toolchain to be ready in time for the 12.0 release. Doing it right means taking more time.

Image of a carpenter carving something intricate

A carpenter taking their time to carve something intricate with care. Image by DALL-E 3

However, the new toolchain is amazing in many, many ways and we really want you to see the direction we’re going. In version 12.0 we are happy to deliver this new toolchain as a Preview release, in parallel with the older toolchain you can keep using for your projects.

We’d love it if you test it out. Focus on ‘pure C++’; it isn’t ready for testing Delphi VCL/FMX yet. You’ll see a high-quality STL. You’ll see we’re using the COFF object format. You’ll see PDB debug files (and we’re very curious if you try using third party tools here, since it’s a widely supported format.) You’ll see performance. You’ll see standards compatibility. You’ll see a new C RTL. You’ll see a new C++ RTL. You’ll see a new linker (and we expect those of you with large projects that stress our current linker will love this one.) When we release 12.0, we’ll blog with details about using it.

In 12.0, the new toolchain is a Technology Preview. We’re still working on key areas like linking against the Delphi runtime (even though Delphi-compatibility features like properties are working.) But it’s different, and it’s amazing. We believe that the preview is foundational and hope the results of you seeing it will be exciting.

Toolchains in version 12.0

What will the Win64 toolchain in C++Builder / RAD Studio 12.0 look like? Well, as stated above, there will be two.

  1. We are shipping the existing Clang 5-based toolchain, and this is the one enabled in the IDE
  2. A Preview version of the new Clang 15-based toolchain, as command-line only (invoke it by calling the compiler, bcc64x.)

Any upgrade is easier if there’s a migration path, and so even when we have the toolchain ready we’re likely to ship the previous and new toolchains in parallel for at least one release to help you migrate and upgrade. (The new toolchain is higher quality in every way, and written for excellent compatibility with existing C++Builder, so we think it will be easy to switch. But once again, we’re trying to do it right, and that means not requiring a sudden switch of toolchains from one release to the next.)

Command line prompt running bcc64x

Overall

The new Clang toolchain is exciting, amazing material, with many areas that are far ahead of the existing toolchain, and we want to demonstrate to you, concretely, the direction we’re going with a Preview release in 12.0 – and let you use it, and let you use each new edition. The message: an immense amount of work, solid quality in every area, compatibility, standards, and modernity, built by making the right decisions. C++Builder is on rock-solid ground.

Sign up for the “What’s Coming” event on November 9th to learn more about RAD Studio, Delphi, and C++Builder 12.0.

This blog post is based on a pre-release version of the RAD Studio software and it has been written with specific permission by Embarcadero. No feature is committed until the product GA release.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

David is an Australian developer, currently living in far-north Europe. He is the senior product manager for C++ at Idera, looking after C++Builder and Visual Assist.

6 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES