"clang -v" shows a GCC call

Hi everyone,

I'm very new to the world of compilation and I've got to spend some time
time on LLVM.
As I have to produce a cross compiler for a completely new target and I
don't want to cross-build the binutils, I choose Clang as a replacement
frontend for llvm instead of llvm-gcc.

But first, I just would like to compile something on my Linux platform in
order to test the software, no question about cross-compiling at the moment.
The only problem is that every time I try to compile using the command
below, I get this result telling me that Clang is calling gcc instead of all
the LLVM tools

Here's the command and the result (I skipped a line at each GCC call):

$clang -v hello.c

clang version 1.0 (https://llvm.org/svn/llvm-project/cfe/branches/release_26
exported)
Target: i386-pc-linux-gnu
Thread model: posix
"/bin/clang-cc" -triple i386-pc-linux-gnu -S -disable-free -main-file-name
main.c --relocation-model static --disable-fp-elim --unwind-tables=0
--mcpu=pentium4 --fmath-errno=1 -v -fdiagnostics-show-option -o
/tmp/cc-G6QVZj.s -x c main.c
clang-cc version 1.0 based upon llvm 2.6 hosted on i686-pc-linux-gnu
ignoring nonexistent directory "/System/Library/Frameworks"
ignoring nonexistent directory "/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/lib/clang/1.0/include
/usr/include
End of search list.

"/usr/bin/gcc" -v -c -m32 -o /tmp/cc-J586JU.o -x assembler /tmp/cc-G6QVZj.s
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.4/specs
Configured with: ../configure --verbose --program-suffix=-3 --prefix=/usr
--exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--enable-languages=c,ada,c++,d,f77,pascal,java,objc --enable-nls
--without-included-gettext --enable-version-specific-runtime-libs
--without-x --enable-libgcj --disable-java-awt --with-system-zlib
--enable-interpreter --disable-libgcj-debug --enable-threads=posix
--enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptions
--enable-hash-synchronization --enable-libstdcxx-debug
Thread model: posix
gcc version 3.4.4 (Red Hat 3.4.4)
as -o /tmp/cc-J586JU.o /tmp/cc-G6QVZj.s

"/usr/bin/gcc" -v -m32 -o a.out /tmp/cc-J586JU.o
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.4/specs
Configured with: ../configure --verbose --program-suffix=-3 --prefix=/usr
--exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--enable-languages=c,ada,c++,d,f77,pascal,java,objc --enable-nls
--without-included-gettext --enable-version-specific-runtime-libs
--without-x --enable-libgcj --disable-java-awt --with-system-zlib
--enable-interpreter --disable-libgcj-debug --enable-threads=posix
--enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptions
--enable-hash-synchronization --enable-libstdcxx-debug
Thread model: posix
gcc version 3.4.4 (Red Hat 3.4.4)
collect2 -Bdynamic --dll-search-prefix=cyg -o a.out
/usr/lib/gcc/i386-redhat-linux/3.4.4/../../../crt0.o
-L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -L/usr/lib/gcc/i386-redhat-linux/3.4.4
-L/usr/lib/gcc/i386-redhat-linux/3.4.4/../../.. /tmp/cc-J586JU.o -lgcc
-lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc

Can you please tell me why is this happen ?

If there's a solution, can you please give it to me in order to make Clang
not using GCC ?

Excuse me if I wrote something stupid or just forgetting something. Just
tell me what's wrong.

Thanks in advance.

llvm (and clang) do not include binutils. You're seeing clang invoking the gcc shell to assemble the .s file that clang generated, then again to link the object file into an executable.

Thanks for your really fast answer.

I understood that, but this means that the llvm+Clang suite is not able to
create a machine binary file without any intervention of GCC ?

I thought it could.

This means too that I must port GCC+Binutils in order to have a LLVM port
for my architecture ?

That sound like a huge work, I've chosen LLVM at the beginnig because I
thought it could avoid me porting GCC+Binutils.

Thanks for the reply.

Jim Grosbach wrote:

You can define your own toolchain in clang. I think FreeBSD does that.
You need an assembler, a linker, and a way to call them.

It doesn't necesarely have to be binutils assembler, but it must
understand gas syntax (maybe clang -integrated-as can help here?).

Best regards,
--Edwin.

Not yet. We're working on it, though:

There are two answers. 1) we're in the process of building a new llvm-native assembler. When this is done, LLVM will be able to produce .o files without any other tools. 2) clang can talk directly to a system assembler if you teach it how to (by defining a "ToolChain" for your platform). In the absence of that, it uses GCC as an abstraction layer to make it more portable.

In the short term, I'd recommend adding a clang toolchain description for your target. This is pretty easy to do, ask on the cfe-dev list for more details.

-Chris

That's the link step and it's easier to use the gcc driver to accomplish the link
step.

At least I think, Daniel will correct me if I'm wrong :slight_smile:

-eric

Is anyone actively working on adding ELF object file support to the MC
project?

Thanks a lot for all your answers, now I think I understand how the
infrastructure works.

There's a pretty good community here, this is really cool !

I think I'm going to port the binutils for my architecture in order to have
an assembler and a linker, and stay with CLang+LLVM to generate native
asembler. ( *.s file )

Thank you all again, and keep up the good work !

Török Edwin wrote:

Thanks for your really fast answer.

I understood that, but this means that the llvm+Clang suite is not able
to
create a machine binary file without any intervention of GCC ?

I thought it could.

This means too that I must port GCC+Binutils in order to have a LLVM port
for my architecture ?

That sound like a huge work, I've chosen LLVM at the beginnig because I
thought it could avoid me porting GCC+Binutils.

You can define your own toolchain in clang. I think FreeBSD does that.
You need an assembler, a linker, and a way to call them.

It doesn't necesarely have to be binutils assembler, but it must
understand gas syntax (maybe clang -integrated-as can help here?).

Best regards,
--Edwin.
_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

=)=)=)

Is anyone actively working on adding ELF object file support to the MC
project?

I'm not aware of anyone. Same for COFF.

Török Edwin a écrit :

Anton Korobeynikov wrote:

Is anyone actively working on adding ELF object file support to the MC
project?

I'm not aware of anyone. Same for COFF.

I'm working on COFF. I've gotten as far as overhauling the COFF MCSection
implementation to match that of the MachO and ELF variants, but haven't come
up with a good way of verifying that everything is correct.

-Peter S. Housel-