This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: conceptual help


Hello All!

On Tuesday 09 February 2010 09:15:15 Thomas Petazzoni wrote:
> On Mon, 8 Feb 2010 17:32:45 -0300
> Diego Saravia <dsa@unsa.edu.ar> wrote:
> > I dont understand why to use i586 i686 x86_64, etc as targets if gcc
> > produces only one excecutable for all i386 and x86_64 processors
> > it is not better to have only one gcc-binary, aka i386-gcc for all
> > that processors and use "i386-gcc -march=i586",  "i386-gcc
> > -march=i686" and  "i386-gcc -march=x86_64"?

When configured for x86, gcc can generate code for all of the i?86
variants, _and_ all the x86_64 variants as well (and conversely if
configured for x86_64).

What we want, although, is to select the _default_ CPU targeted by
the compiler. That is, just calling the cross-compiler (say:
i686-linux-gnu-gcc), then proper code is generated, and is optimised
for the i686 class of CPUs (eg. PentiumPro). This selection in deed
propagates down to the C library (and a few others) that then get
optimised for this very CPU, but might not run on any other.

See the gcc man page, section titled "Intel 386 and AMD x86-64 Options"
for options -mtune and -march.

> Yann will correct me if I'm wrong, but the thing is that the C library
> is built as part of the cross-compiling toolchain. And the C library is
> compiled for the target, and we might want to compile this code for the
> target with a specific CPU in mind, in order to generate better code
> when possible. Otherwise, we would always have to compile the C library
> for the smallest common denominator: i386, which prevents us from using
> improvements of the instruction sets on i486, Pentium and further
> families.

Basically, that's right. You have to know, however, that there is no such
thing as a "generic instruction set applicable to all [x86] processors"
(again, from the gcc man page). As an embedded point of view, we seldom
need to address different processors of the same kind; eg. your board
either has an i386 or an i586, not both. If you have two (or more) boards
with different CPUs, then I'd suggest you build one toolchain for each
board, as the C library and some gcc libs, such as libgcc, get optimised
for each of board.

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
`------------------------------^-------^------------------^--------------------'



--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]