Package: gcc-4.2 Version: 4.2.2-3 Severity: normal
The option "-march=native" can be used to set the target architecture from the current host (and "-mtune=native" should do the same thing for tuning). By my reading of the docs, "-march=native" should otherwise work just like any other -march option, in particular, if -mtune is not specified, it should default to the result of -march. However, that's not what happens. In fact, what seems to happen is that "-march=native" is specified, gcc defaults to -mtune=generic (which yields very crappy code in many cases). It doesn't work to specify -mtune=native (that just ends up as -mtune=generic again), so the only way to actually get good code is to explicitly specify a cpu type for -mtune -- and I presume it's exactly this annoyance the -mxxx=native option was supposed to make unnecessary! Here's some tests run on a pentium3 machine, grepping the output of -fverbose-asm to see the concrete target type the compiler chose (the output was also verified by looking at the code -- gcc generates very different code for a floating point abs operation on different targets): $ echo 'float x(float x){return x < 0 ? -x : x;}' > x.c First try just -march=native: $ gcc -fverbose-asm -O2 -mfpmath=sse -march=native -S x.c This result in arch=pentium3, but tune=generic: $ grep '\(-march\|-mtune\)' x.s # options passed: -march=pentium3 -mtune=generic -mfpmath=sse -auxbase -O2 Ok, so try explicitly saying -mtune=native too: $ gcc -fverbose-asm -O2 -mfpmath=sse -march=native -mtune=native -S x.c Nope: $ grep '\(-march\|-mtune\)' x.s # options passed: -march=pentium3 -mtune=generic -mfpmath=sse -auxbase -O2 Now try explicitly specifying -march=pentium3, but keeping -mtune=native: $ gcc -fverbose-asm -O2 -mfpmath=sse -march=pentium3 -mtune=native -S x.c Ugh: $ grep '\(-march\|-mtune\)' x.s # options passed: -mtune=generic -mfpmath=sse -march=pentium3 -auxbase -O2 Finally, just explicitly specify -march=pentium3: $ gcc -fverbose-asm -O2 -mfpmath=sse -march=pentium3 -S x.c Ok finally gcc chose the right default: $ grep '\(-march\|-mtune\)' x.s # options passed: -mfpmath=sse -march=pentium3 -auxbase -O2 -fverbose-asm Version info: $ head -2 x.s .file "x.c" # GNU C version 4.2.3 20071014 (prerelease) (Debian 4.2.2-3) (i486-linux-gnu) Thanks, -Miles -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (990, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental') Architecture: i386 (i686) Kernel: Linux 2.6.22.7 (PREEMPT) Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages gcc-4.2 depends on: ii binutils 2.18-1 The GNU assembler, linker and bina ii cpp-4.2 4.2.2-3 The GNU C preprocessor ii gcc-4.2-base 4.2.2-3 The GNU Compiler Collection (base ii libc6 2.6.1-6 GNU C Library: Shared libraries ii libgcc1 1:4.2.2-3 GCC support library ii libgomp1 4.2.2-3 GCC OpenMP (GOMP) support library Versions of packages gcc-4.2 recommends: ii libc6-dev 2.6.1-6 GNU C Library: Development Librari -- no debconf information -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]