Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the clang -cc1 option do?

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?

like image 551
sp497 Avatar asked Jan 24 '12 17:01

sp497


People also ask

Why you should use Clang?

Clang is much faster and uses far less memory than GCC. Clang aims to provide extremely clear and concise diagnostics (error and warning messages), and includes support for expressive diagnostics. GCC's warnings are sometimes acceptable, but are often confusing and it does not support expressive diagnostics.

How does Clang work?

Clang Design: Like many other compilers design, Clang compiler has three phase: The front end that parses source code, checking it for errors, and builds a language-specific Abstract Syntax Tree (AST) to represent the input code. The optimizer: its goal is to do some optimization on the AST generated by the front end.

What is Clang in LLVM?

Clang is an "LLVM native" C/C++/Objective-C compiler, which aims to deliver amazingly fast compiles, extremely useful error and warning messages and to provide a platform for building great source level tools.


2 Answers

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.

like image 135
ritter Avatar answered Sep 30 '22 23:09

ritter


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.

like image 26
Anton Korobeynikov Avatar answered Sep 30 '22 22:09

Anton Korobeynikov