Re: "-march=native" possibly being misled on Debian i386?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2017-06-11 16:30 +0200, Toby Douglass wrote:
> I wrote:
> > Using the OS GCC (4.9.2, native build for i586-linux-gnu);
> > WIthout, I get arch i586, tune generic.
> > With, I get - ha! - "-march=native", and no tune.
> 
> This seems odd.
> 
> A bit more information now, pairs of command/output.
> 
> First on Debian 8, the OS provided 4.9.2 on my normal x86_64 machine.
> 
> gcc -E -x c /dev/null -v
> COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=x86-64'
> 
> gcc -march=native -E -x c /dev/null -v
> COLLECT_GCC_OPTIONS='-march=native' '-E' '-v'
> 
> gcc -mtune=native -E -x c /dev/null -v
> COLLECT_GCC_OPTIONS='-mtune=native' '-E' '-v' '-march=x86-64'
> 
> gcc -march=native -mtune=native -E -x c /dev/null -v
> COLLECT_GCC_OPTIONS='-march=native' '-mtune=native' '-E' '-v'

Oh no Toby... I didn't mean COLLECT_GCC_OPTIONS.  Its -march
is same as your input (or defaulted).

I mean:

gcc -march=native -E -x c /dev/null -v 2>&1 | grep cc1 | fmt
 /usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0/cc1 -E -quiet -v /dev/null
 *-march=ivybridge* -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3
 -mno-sse4a -mcx16 -msahf -mno-movbe -mno-aes -mno-sha -mpclmul
 -mpopcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi
 -mno-sgx -mno-bmi2 -mno-tbm -mavx -mno-avx2 -msse4.2 -msse4.1
 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mf16c -mfsgsbase -mno-rdseed
 -mno-prfchw -mno-adx -mfxsr -mxsave -mxsaveopt -mno-avx512f -mno-avx512er
 -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mno-clflushopt -mno-xsavec
 -mno-xsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma
 -mno-avx512vbmi -mno-avx5124fmaps -mno-avx5124vnniw -mno-clwb -mno-mwaitx
 -mno-clzero -mno-pku -mno-rdpid --param l1-cache-size=32 --param
 l1-cache-line-size=64 --param l2-cache-size=3072 -mtune=ivybridge

So we can see GCC guessed "ivybridge" on my laptop.  In fact it's
correct.  W/o "-march=native":

gcc -E -x c /dev/null -v 2>&1 | grep cc1 | fmt
 /usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0/cc1 -E -quiet -v /dev/null
 -mtune=generic -march=x86-64

So the default is "x86-64".

> Interetin', eh?  tune is doing something, even though arch isn't.

-mtune is not doing anything.  With only -mtune (no -march) GCC just
use the default -march (configure option --with-arch=).  For example,
we have a Ubuntu server with GCC 4.9 from APT.

cc -v 2>&1 | fmt | grep with-arch-32
--enable-objc-gc --enable-multiarch --disable-werror *--with-arch-32=i686*

So...
cc -m32 -E -x c /dev/null -v 2>&1 | grep cc1 | fmt
 /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1 -E -quiet -v -imultilib 32
 -imultiarch i386-linux-gnu /dev/null -m32 -mtune=generic *-march=i686*
 -fstack-protector -Wformat -Wformat-security

> Going back to the version 1 Minnowboard (Atom E640), Debian 8, the OS
> provided GCC 4.9.2;
> 
> gcc -E -x c /dev/null -v
> COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=i586'
> 
> gcc -march=native -E -x c /dev/null -v
> COLLECT_GCC_OPTIONS='-march=native' '-E' '-v'
> 
> gcc -mtune=native -E -x c /dev/null -v
> COLLECT_GCC_OPTIONS='-mtune=native' '-E' '-v' '-march=i586'
> 
> gcc -march=native -mtune=native -E -x c /dev/null -v
> COLLECT_GCC_OPTIONS='-march=native' '-mtune=native' '-E' '-v'
> 
> Superficially at least, -march is looking a bit messed up.  However,
> it's more likely my expectation of what it is does is amiss =-)
-- 
Xi Ruoyao <ryxi@xxxxxxxxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux