Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtaining current GCC architecture

Tags:

gcc

How can I find out what the -march default argument is for the current architecture if I don't supply any?

like image 490
rid Avatar asked Jul 30 '12 18:07

rid


People also ask

How do I find my GCC configuration?

Run gcc --version -v . It will output the configure invocation.

How do I specify architecture in GCC?

If gcc -v shows GCC was configured with a --with-arch option (or --with-arch-32 and/or --with-arch-64 ) then that's what will be the default. Without a --with-arch option (and if there isn't a custom specs file in use) then the arch used will be the default for the target.

What is GCC programming?

GCC stands for “GNU Compiler Collection”. GCC is an integrated distribution of compilers for several major programming languages. These languages currently include C, C++, Objective-C, Objective-C++, Fortran, Ada, D, and Go. The abbreviation GCC has multiple meanings in common use.

Is GCC a build tool?

The GNU Compiler Collection (usually shortened to GCC) is a compiler system produced by the GNU Project supporting various programming languages. make is a "build tool" that invokes the compiler (which could be gcc) in a particular sequence to compile multiple sources and link them together.


1 Answers

gcc -dumpmachine gives you the target triplet, e.g. x86_64-unknown-linux-gnu

If gcc -v shows GCC was configured with a --with-arch option (or --with-arch-32 and/or --with-arch-64) then that's what will be the default.

Without a --with-arch option (and if there isn't a custom specs file in use) then the arch used will be the default for the target.

For x86, up to and including GCC 4.4, the default for 32-bit was -march=i386 and for 64-bit was -march=x86-64 (note the hyphen instead of underscore.)

For x86 with GCC 4.5 and later versions the default arch is inferred from the target triplet i.e. configuring for i586-pc-linux-gnu means the default is -march=i586, configuring for core2-pc-linux-gnu means the default is -march=core2.

Some other platforms also infer the default arch from the target triplet (and have done since before GCC 4.4) so e.g. ultrasparc2-sun-solaris2.10 implies -march=ultrasparc2.

like image 165
Jonathan Wakely Avatar answered Oct 30 '22 15:10

Jonathan Wakely