avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] clarification on gcc


From: Erik Christiansen
Subject: Re: [avr-gcc-list] clarification on gcc
Date: Tue, 25 Jun 2013 17:47:59 +1000
User-agent: Mutt/1.5.21+145 (2a1c5d3dd72e) (2012-12-30)

On 24.06.13 10:16, Parthasaradhi Nayani wrote:
> Dear all,
> What are the differences between GCC and AVR-GCC save for the
> libraries? GCC is supposed to cross compile for various processors so
> if I have a source file, can I not compile this source file using
> regular GGC say on Linux by using appropriate switches like selecting
> an AVR controller (-mcu = mega64)?

Let us agree that "regular GGC" is a native compiler, e.g. running under
linux, on an intel cpu. As a native compiler it produces intel machine
code, using linux libraries. That is all it can do, because when that
native compiler was compiled, it was built for just that native target.

Let us accept you're comparing that to a cross-compiler running under
linux on an intel cpu, to compile for the avr target. It will run on
intel, in a linux environment, but produce assembler source code for the
avr target, because the cross-compiler was built with "$ ../configure
--target=avr". Thus it can never produce code to run on intel, powerpc,
or any other target.

Furthermore, the complete avr-gcc cross-compiling toolchain includes
binutils which has also been built with "--target=avr", so that it will
contain an avr-gas executable  which accepts avr assembler, and outputs
avr object files. (I.e. avr machine code.) It cannot be made to
understand intel or powerpc assembler source, or generate machine code
for such targets.

It is the gcc _source_code_ which supports many targets, not a compiled
cross-compiler. Once built for one target, the compiler has zero
knowledge of other targets, so cannot be made to deal with them.
Similarly, if it was built with "--enable-languages=c,c++", don't expect
fortran or ada compilers to appear.

For a quick comparison of the object file formats that a toolchain can
be made to produce, run these commands:

$ objdump -i         # The native compiler.

$ avr-objdump -i     # Your avr toolchain.

If what you're looking for isn't there, it can't do it.

Sometimes it is even necessary to have several cross-compilers for one
processor family. E.g. even if you have been happily using a powerpc
cross-compiler for other embedded work, it is advisable to use a custom
toolchain when working with the U-Boot linux bootloader.

If any confusion remains, then it might also be worth reading:
               http://en.wikipedia.org/wiki/Cross_compiler

Erik

-- 
Life is complex: it has a real part and an imaginary part. - Martin Terma




reply via email to

[Prev in Thread] Current Thread [Next in Thread]