Home / Blog / Clang – a single compiler to handle all platforms.

Clang – a single compiler to handle all platforms.

I was asked to use a single compiler for all target platforms. Clang is already the default choice for many of them. However, this wasn’t the case on Windows, where Microsoft’s cl.exe was in use. 

Why? Supporting multiple compilers required additional work. 

There were many steps that I needed to take: 

– Extend our setup script, which configures developers’ workstations – Clang had to be installed in the proper version. 

– Embed setup checks into the build process – in case developers did not rerun the configuration script, this had to be communicated immediately. 

– Organize the transition period – to avoid locking the main branch, I  adjusted project parts step by step, ensuring they are buildable with both MSVC and Clang. 

– Provide a backup plan: Windows was our primary development platform, so in the event of an unexpected issue, we could not afford to halt project work entirely.

We used clang-cl, which provides a translation layer between cl.exe commands and Clang. Most of the unexpected issues happened in third-party libraries. The most common ones were: 

– Inconsistency in conditional compilation – some libraries were checking both for _MSC_VER and Windows-specific definition interchangeably (only valid if you use cl.exe on Windows).

– Intrinsics – third-party libraries relied on them, so it was necessary to use both MSVC and Clang versions. This was achieved by a simple trick: including the first project-specific header, which defined header guards for some internal OS headers (to prevent loading them and substituting other versions). and then including internal Microsoft headers in the correct order. 

– Exceptions are tricky – due to incompatibilities between MSVC and Clang (MSVC compatibility — Clang 21.0.0git documentation).

To sum up, replacing the compiler on the leading development platform requires not only adjusting developers’ environments but also a transition period and emergency fallback to the previous one. Moreover, you should be ready for unexpected issues, especially in third-party code. 

To sum up: 

replacing the compiler on the leading development platform requires not only adjusting developers’ environments but also a transition period and emergency fallback to the previous one. Moreover, you should be ready for unexpected issues, especially in third-party code.

Author

Wiktor Ławski

Senior Software Engineer

Wiktor has worked on software development for more than 10 years already. He focuses on rendering and supporting different platforms.

See more posts by this author

Looking for a proven work-for-hire team?

Get in touch to find out how we can support your game!

Hi! We use cookies and similar technologies to better know you and improve your experience with our website.
You can find out more by reading our Privacy Policy.