Table of Contents
The new Clang Toolchain in C++Builder 12.1!
RAD Studio 12.1 has big news: we have released the first version of our new Clang-based toolchain! This is a complete revision of the entire technology stack, and provides a solid, modern, ‘done the right way’ foundation for all of C++ going forward.
Technical Info
The new toolchain targets Windows 64-bit Intel apps, and is based on Clang 15, with a new STL, a new C++ runtime, and uses the Windows Universal C Runtime (UCRT.) It has a new linker, and uses the COFF and PDB object and debug file formats. For more information, see the second Behind the Build webinar from just a few weeks before 12.1 released. We also have documentation on upgrading with key things to know.
All binaries (the compiler, linker etc) are 64-bit EXEs, meaning they can handle large memory requirements – and you’d be surprised how often this is needed for C++. This even includes when compiling in the IDE, where we call out to the external process.
What does it provide?
The toolchain has a focus on quality above features (it is version 1, but we want what we release to be solid), on doing things right and making the right choices, on resolving the key areas through that quality that affect you, and on setting C++Builder up for a really exciting future.
Examples of the right choices:
- We are using the platform standard COFF object file format
- We are using the platform standard PDB debug file format (this should allow you to use other specialised debuggers, if you need)
- Making heavy use of open source software, such as LLVM’s STL (libc++)
- Removing duplicate efforts: we used to have our own C runtime, but there’s one built into Windows now (the UCRT); we use that
- Shipping both the old Win64 toolchain and the new one side by side in the IDE (yes, both are there!), so you can upgrade and test moving from old to new just by toggling platform. This should really help upgrading: there’s no sudden, required switch.
Examples of quality in areas that affect you:
- The linker: there should be no more memory issues, it’s the same linker used to build Chrome
- The linker: it’s about four times faster than the old ilink
- The STL: a complete replacement, with a high-quality STL with excellent standards test results
Examples of setting up for the future:
- Recent version of Clang, and much easier to keep up to date (the only reason it’s not the absolute latest now is to reduce multiple moving targets)
- Platform standards look towards interoperability
- Open source STL looks towards constant (ongoing) quality and features
- Etc.
Examples of quality above features:
- A very strong focus on C++ standards compliance: mid-last-year, nine months before release, we were already passing many more tests than our previous old toolchain
- A very strong focus on additional quality: we had a special focus on exception handling, where not only do we pass multiple test suites but we created over 700 new tests for various scenarios ourselves
What has it not got?
Quality above features means that version 1 does not include everything. The notable absences are that packages can only be statically linked, not dynamically linked, in this release; packages built in C++ must similarly be statically linked (ie built as .libs) currently; and we don’t yet have CMake support. We’re also in the process right now of updating libraries on GetIt, like Boost. Read this blog post for info on plans for these features, and common tasks and how to achieve them.
We recommend using the toolchain unless these are blockers for you due to its greatly increased overall quality.
What has it got?
Huge benefits! We are closing tickets left, right and center because code that did not work in the past, works now.
Try it out for a new, fast linker. A new, high quality STL (ever had issues with std::variant or other types? Try it now.) Using the PDB format, if you want to use, eg, WinDbg. Huge C++ compatibility: if you need to compile 3rd party code, use this toolchain. You get the idea!
The future
This is a foundational release and we really want you to try it out! Remember, when you install RAD Studio or C++Builder, both the old and new Win64 toolchains are available at the same time, in parallel. Just add the new one to your projects (in the Projects view, right-click, Add Platform, ‘Win64 Modern’) and you can then toggle back and forth between them by double-clicking the platform target you want.
We do intend to remove the old Win64 toolchain in future once we ship dynamic packages, so we recommend taking advantage of the current parallel toolchains as an upgrade feature.
We hope you’re as excited by this release as we are. While we know it’s a version 1, in terms of quality it’s a solid version 1 and we’re really keen to see you try it out and test it against your code… and see what you can achieve now that you couldn’t before!
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition
Thank you for the hard work. My initial experiences using 12.1 were very positive. I had no trouble using open source libraries that previously could not be compiled with CPPB. Are there plans to support other platforms (macOS, Linux, iOS, Android)?
That’s great to hear! Sounds like you’re able to do what we hoped you’d be able to do.
Re other platforms — nothing concrete. We regard this as a foundation that will let us achieve other things in future, and that includes possibly things like Android or macOS etc, but we have no plans to share yet what and when. You can email me what you need, if you’d like? We always try to track what our customers need in order to make these decisions: [email protected].
Any support for new Clang Toolchain (64-bit Modern) for c++Builder packages?
Absolutely! They should be coming soon 🙂
(Note we are not able to promise things before they GA, so, consider this under that standard disclaimer slide we put on our webinars.)
Hi,
what is the “if defined(???)” for the new tool chain?
Hello. We recommend using the following:
#include
#include
int _tmain(int argc, _TCHAR* argv[])
{
#if defined(__CODEGEARC__) && (__clang_major__ >= 15)
std::cout << "C++Builder Modern Compiler, 12.1 or newer";
#else
std::cout << "A different compiler";
#endif
}
This checks that it's our compiler, and checks the Clang version is 15 or higher. This means you're checking for the new toolchain as it is today, and all future versions of this toolchain. You can also check for _WIN64, because while today it's x64 only in future it may expand.
Looks like the comment system ate the formatting and includes (it was just a standard console app) but hopefully you get the idea 🙂 The key line is:
> #if defined(__CODEGEARC__) && (__clang_major__ >= 15)