What does the clang -cc1 option do?

Compiler ConstructionLlvmClang

Compiler Construction Problem Overview


I'm a newbie in clang. I have read a paper about source to source transformation from cuda to opencl using clang compiler front end.

Can anyone tell me why the option -cc1 is sometimes used?

Compiler Construction Solutions


Solution 1 - Compiler Construction

The Clang compiler front-end has several additional Clang specific features which are not exposed through the GCC compatibility driver interface. The -cc1 argument indicates that the compiler front-end is to be used, and not the driver. The clang -cc1 functionality implements the core compiler functionality.

So, simply speaking. If you do not give -cc1 then you can expect the "look&feel" of standard GCC. That is the vast majority of compiler flags work just like you would expect them to work with GCC. If you pass the option "-cc1" then you get the Clang compiler flag set. Thus, there might be differences to GCC.

Hope that makes it a little clearer.

Solution 2 - Compiler Construction

The usual compiler consists of so-called compiler driver, which knows how to execute compiler itself, assembler, linker, etc. and compiler itself which just takes the source code (sometimes already preprocessed) and emit assembler/object code.

Clang implements all these components in the single binary, the difference is just the cmdline. Here clang -cc1 invokes the compiler itself with its internal/undocumented set of options, etc.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionsp497View Question on Stackoverflow
Solution 1 - Compiler ConstructionritterView Answer on Stackoverflow
Solution 2 - Compiler ConstructionAnton KorobeynikovView Answer on Stackoverflow