Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

question from:https://stackoverflow.com/questions/11727855/obtaining-current-gcc-architecture

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
267 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...