Reputation: 89
Using command clang -### a.c
can output the commands that clang a.c
calls.
For me, it outputs followings on my screen(focus on last three lines):
clang version 1.0 (https://llvm.org/svn/llvm-project/cfe/branches/release_26 exported)
Target: x86_64-unknown-linux-gnu
Thread model: posix
"/usr/local/bin/llvm+clang-2.6-x86_64-linux/bin/../libexec/clang-cc" "-triple" "x86_64-unknown-linux-gnu" "-S" "-disable-free" "-main-file-name" "a.c" "--relocation-model" "static" "--disable-fp-elim" "--unwind-tables=1" "--mcpu=x86-64" "--fmath-errno=1" "-fdiagnostics-show-option" "-o" "/tmp/cc-yffqSv.s" "-x" "c" "a.c"
"/usr/bin/gcc" "-c" "-m64" "-o" "/tmp/cc-pa2Qo4.o" "-x" "assembler" "/tmp/cc-yffqSv.s"
"/usr/bin/gcc" "-m64" "-o" "a.out" "/tmp/cc-pa2Qo4.o"
In the line: /usr/local/bin/llvm+clang-2.6-x86_64-linux/bin/../libexec/clang-cc" "-triple" "x86 ......
, it shows that the command clang
called this: /libexec/clang-cc
.
What does it(file "libexec/clang-cc") do?
And there is another question related I desired to ask:
Whether or not: command clang
uses the front end of the project "clang", and the back end of "gcc"?
Because I find the last two line of code above called "/usr/bin/gcc".
I have search this for hours, can you help me?
Thanks in advance.
Upvotes: 0
Views: 290
Reputation: 241671
You seem to be using quite an old version of Clang. You might want to try a newer one.
clang-cc
is the clang C compiler, which converts a C program to assembly language. [Note 1]. Depending on version and target, it may also be able to directly produce an object file. See the -integrated-as
command-line flag.
If your version of Clang does not have an assembler for your target architecture, the clang
driver will try to use the system assembler (and linker). On some systems, these will be part of Gcc, although there are other options.
Upvotes: 2
Reputation: 136208
What does it(file "libexec/clang-cc") do?
Its output "-o" "/tmp/cc-yffqSv.s"
suggests it outputs assembly.
and the back end of "gcc"?
The last two lines with gcc
invocations are:
a.out
.Upvotes: 2