Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Is the gcc compiler compatible with the clang compiler?


Asked by Cassidy Hartman on Dec 01, 2021 FAQ



The Clang driver and language features are intentionally designed to be as compatible with the GNU GCC compiler as reasonably possible, easing migration from GCC to Clang. In most cases, code “just works”. Clang also provides an alternative driver, clang-cl, that is designed to be compatible with the Visual C++ compiler, cl.exe.
Additionally,
Clang is designed to be highly compatible with GCC. Clang's command-line interface is similar to and shares many flags and options with GCC. Clang implements many GNU language extensions and enables them by default. Clang implements many GCC compiler intrinsics purely for compatibility.
In fact, The first version of clang was Clang 1.0 and it was released with LLVM 2.6. The next version was Clang C++ which was able to parse GCC 4.2 libstdc, compile itself and function as a working code generator for non-trivial operations.
And,
Clang implements many GNU language extensions and enables them by default. Clang implements many GCC compiler intrinsics purely for compatibility. For example, even though Clang implements atomic intrinsics which correspond exactly with C11 atomics, it also implements GCC's __sync_* intrinsics for compatibility...
In this manner,
Some GCC compilation options cause the compiler to generate code that does not conform to the platform’s default ABI. Other options cause different program behavior for implementation-defined features that are not covered by an ABI.