nightmorph 07/08/07 06:12:07 Modified: gcc-optimization.xml Log: clarifications per vapier's suggestions on bug 187209
Revision Changes Path 1.8 xml/htdocs/doc/en/gcc-optimization.xml file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/doc/en/gcc-optimization.xml?rev=1.8&view=markup plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/doc/en/gcc-optimization.xml?rev=1.8&content-type=text/plain diff : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/doc/en/gcc-optimization.xml?r1=1.7&r2=1.8 Index: gcc-optimization.xml =================================================================== RCS file: /var/cvsroot/gentoo/xml/htdocs/doc/en/gcc-optimization.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- gcc-optimization.xml 29 Jul 2007 06:58:08 -0000 1.7 +++ gcc-optimization.xml 7 Aug 2007 06:12:07 -0000 1.8 @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='UTF-8'?> -<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/gcc-optimization.xml,v 1.7 2007/07/29 06:58:08 nightmorph Exp $ --> +<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/gcc-optimization.xml,v 1.8 2007/08/07 06:12:07 nightmorph Exp $ --> <!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> @@ -22,8 +22,8 @@ <!-- See http://creativecommons.org/licenses/by-sa/2.5 --> <license/> -<version>1.4</version> -<date>2007-07-28</date> +<version>1.5</version> +<date>2007-08-06</date> <chapter> <title>Introduction</title> @@ -173,7 +173,8 @@ <p> Even though the CHOST variable in <path>/etc/make.conf</path> specifies the general architecture used, <c>-march</c> should still be used so that programs -can be optimized for your specific processor. +can be optimized for your specific processor. x86 and x86-64 CPUs (among others) +should make use of the <c>-march</c> flag. </p> <p> @@ -205,26 +206,45 @@ <p> -Also available are the <c>-mcpu</c> and <c>-mtune</c> flags. Either of these -should <e>only</e> be used when there is no available <c>-march</c> option. -What's the difference between them? <c>-march</c> is much more specific about -which processor features will be used when compiling code; it is a better -choice. <c>-mcpu</c> will produce much more generic code less optimized for your -machine. <c>-mtune</c> is even more generic than <c>-mcpu</c>. Whenever -possible, use <c>-march</c>. For some less common architectures such as PowerPC, -Sparc, and Alpha, <c>-mcpu</c> must be used. +Also available are the <c>-mtune</c> and <c>-mcpu</c> flags. These flags are +normally only used when there is no available <c>-march</c> option; certain +processor architectures may require <c>-mtune</c> or even <c>-mcpu</c>. +Unfortunately, <c>gcc</c>'s behavior isn't very consistent with how each flag +behaves from one architecture to the next. +</p> + +<p> +On x86 and x86-64 CPUs, <c>-march</c> will generate code specifically for that +CPU using all its available instruction sets and the correct ABI; it will have +no backwards compatibility for older/different CPUs. If you don't need to +execute code on anything other than the system you're running Gentoo on, +continue to use <c>-march</c>. You should only consider using <c>-mtune</c> when +you need to generate code for older CPUs such as i386 and i486. <c>-mtune</c> +produces more generic code than <c>-march</c>; though it will tune code for a +certain CPU, it doesn't take into account available instruction sets and ABI. +Don't use <c>-mtune</c> on x86 or x86-64 systems, as it is deprecated for those +arches. +</p> + +<p> +Only non-x86/x86-64 CPUs (such as Sparc, Alpha, and PowerPC) may require +<c>-mtune</c> or <c>-mcpu</c> instead of <c>-march</c>. On these architectures, +<c>-mtune</c>/<c>-mcpu</c> will sometimes behave just like <c>-march</c> (on +x86/x86-64) . . . but with a different flag name. Again, <c>gcc</c>'s behavior +and flag naming just isn't consistent across architectures, so be sure to check +the <c>gcc</c> <uri +link="http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Submodel-Options.html#Submodel-Options">manual</uri> +to determine which one you should use for your system. </p> <note> -For more suggested <c>-march</c> settings, please read chapter 5 of the -appropriate <uri link="/doc/en/handbook/">Gentoo Installation Handbook</uri> -for your arch. Also, read the <c>gcc</c> manual's list of <uri +For more suggested <c>-march</c>/<c>-mtune</c>/<c>-mcpu</c> settings, please +read chapter 5 of the appropriate <uri link="/doc/en/handbook/">Gentoo +Installation Handbook</uri> for your arch. Also, read the <c>gcc</c> manual's +list of <uri link="http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Submodel-Options.html#Submodel-Options">architecture-specific options</uri>, as well as more detailed explanations about the differences -between <c>-march</c>, <c>-mcpu</c>, and <c>-mtune</c>. This is quite helpful -for determining which <c>-march</c> setting you should use, especially since on -some architectures, such as x86, <c>-mcpu</c> is deprecated and <c>-mtune</c> -should be used instead. +between <c>-march</c>, <c>-mcpu</c>, and <c>-mtune</c>. </note> </body> @@ -339,11 +359,10 @@ <p> In particular, it makes troubleshooting applications written in Java much harder, though Java is not the only code affected by using this flag. So while -the flag can help, it also makes debugging harder; backtraces will be useless. -However, if you don't plan to do much debugging and haven't added any other -debugging-related CFLAGS such as <c>-ggdb</c> (and you aren't installing -packages with the <c>debug</c> USE flag), then try using -<c>-fomit-frame-pointer</c>. +the flag can help, it also makes debugging harder; backtraces in particular will +be useless. However, if you don't plan to do much software debugging and +haven't added any other debugging-related CFLAGS such as <c>-ggdb</c>, then you +can try using <c>-fomit-frame-pointer</c>. </p> <impo> -- [EMAIL PROTECTED] mailing list
