Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 317513

Summary: [4.5] Core i5 misdetected as Atom w/ -march=native (was: illegal instruction in xulrunner)
Product: Gentoo Linux Reporter: Marc-Antoine Perennou <Marc-Antoine>
Component: Current packagesAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: RESOLVED FIXED    
Severity: normal CC: canarauc
Priority: High Keywords: Inclusion
Version: unspecified   
Hardware: AMD64   
OS: Linux   
URL: http://gcc.gnu.org/PR44046
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: build log
paludis --info
cpuinfo
gcc45-PR44046-core2.patch

Description Marc-Antoine Perennou 2010-04-27 17:19:09 UTC
When reinstalling gentoo on my new computer, I get a compile failure for xulrunner. I'm using gcc-4.5 but on the previous computer I was using it too and it built fine, the main difference is that the new one has a core i5 and -march=native in its CFLAGS.

Reproducible: Always

Actual Results:  
xulrunner fails to build

Expected Results:  
it works
Comment 1 Marc-Antoine Perennou 2010-04-27 17:19:45 UTC
Created attachment 229417 [details]
build log
Comment 2 Marc-Antoine Perennou 2010-04-27 17:20:11 UTC
Created attachment 229419 [details]
paludis --info
Comment 3 Marc-Antoine Perennou 2010-04-27 18:23:00 UTC
with CFLAGS="-march=core2 -O2 -pipe" it works well, I'll investigate to find which of the CFLAGS implied by -march=native with a core i5 causes the failure ...
Comment 4 Marc-Antoine Perennou 2010-04-27 19:08:41 UTC
Ok it's definitely a gcc 4.5 failure.
-march=native is equivalent to
-march=atom -msse4.2 -maes -mpclmul -mpopcnt -mcx16 -msahf -mtune=core2
replacing -march=atom (which appeared in gcc 4.5 afaik) by -march=core2 solves the problem.
Comment 5 SpanKY gentoo-dev 2010-04-27 20:27:26 UTC
so all the other flags work fine with -march=core2 ?
Comment 6 Marc-Antoine Perennou 2010-04-27 20:34:30 UTC
yep, built it fine changing only atom to core2 after copy/pasting this list (I even changed -msse4.2 to -msse4 to enable both .1 and .2 and it still works)
Comment 7 SpanKY gentoo-dev 2010-04-27 20:48:51 UTC
scheduling differences sholudnt matter.  docs dont say it, but source indicates atom provides -mmovbe over core2.  try using that flag with -march=core2 and see if you get the same result.
Comment 8 Marc-Antoine Perennou 2010-04-27 21:17:53 UTC
CFLAGS="-march=atom -msse4 -maes -mmovbe -mpclmul -mpopcnt -mcx16 -msahf -mtune=core2 -O2 -pipe"
=> failure
CFLAGS="-march=core2 -msse4 -maes -mmovbe -mpclmul -mpopcnt -mcx16 -msahf -mtune=core2 -O2 -pipe"
=> success
Comment 9 Marc-Antoine Perennou 2010-05-05 14:35:46 UTC
I finally switched back to gcc 4.4.3 for now, and I can confirm that -march=native gives me a -march=core2, not a -march=atom with it, and compilation works fine, so it's a 100% gcc 4.5 bug for sure
Comment 10 Ryan Hill (RETIRED) gentoo-dev 2010-05-08 03:52:19 UTC
xulrunner strips flags (even w/ USE=custom-optimization), so adding -mmovbe won't work.  i just added a few 4.5 flags to the exception list so -mno-movbe will be allowed now.  -march=atom -mno-movbe fixes the error.
Comment 11 Ryan Hill (RETIRED) gentoo-dev 2010-05-08 05:50:56 UTC
Your cpu is a Core i5 M 520, correct?  As far as I can see they don't have movbe - it was introduced with the Atom series.  So I would say that -march=native should instead be -march=core2 + a bunch of -m flags for that processor.

Could you provide the contents of /proc/cpuinfo and the output of

  $ echo "int main() { return 0; };" > test.c
  $ gcc-4.5.0 -march=native -v test.c -o test
Comment 12 Marc-Antoine Perennou 2010-05-08 06:05:56 UTC
Created attachment 230765 [details]
cpuinfo

yep, it's a core i5 M 520
Comment 13 Marc-Antoine Perennou 2010-05-08 08:36:36 UTC
Lou ~ # echo "int main() { return 0; };" > test.c                                                                                                                                                                      [10:35:26 - 08/05/2010]
Lou ~ # gcc-4.5.0 -march=native -v test.c -o test                                                                                                                                                                      [10:35:33 - 08/05/2010]
Utilisation des specs internes.
COLLECT_GCC=gcc-4.5.0
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configuré avec: /var/tmp/paludis/sys-devel-gcc-4.5.0/work/gcc-4.5.0/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-ppl --with-cloog --disable-lto --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --enable-cld --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.5.0/python --enable-java-awt=gtk --enable-languages=c,c++,java,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.5.0 p1.0'
Modèle de thread: posix
gcc version 4.5.0 (Gentoo 4.5.0 p1.0) 
COLLECT_GCC_OPTIONS= '-v' '-o' 'test'
 /usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.0/cc1 -quiet -v test.c -D_FORTIFY_SOURCE=2 -march=atom -mcx16 -msahf -maes -mpclmul -mpopcnt -msse4.2 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=3072 -mtune=core2 -quiet -dumpbase test.c -auxbase test -version -o /tmp/ccmAagyo.s
GNU C (Gentoo 4.5.0 p1.0) version 4.5.0 (x86_64-pc-linux-gnu)
	compiled by GNU C version 4.5.0, GMP version 4.3.2, MPFR version 2.4.2-p3, MPC version 0.8.1
heuristiques GGC: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
le répertoire « /usr/local/include » est ignoré car inexistant
le répertoire « /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/../../../../x86_64-pc-linux-gnu/include » est ignoré car inexistant
la recherche pour #include "..." débute ici :
la recherche pour #include <...> débute ici:
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include-fixed
 /usr/include
Fin de la liste de recherche.
GNU C (Gentoo 4.5.0 p1.0) version 4.5.0 (x86_64-pc-linux-gnu)
	compiled by GNU C version 4.5.0, GMP version 4.3.2, MPFR version 2.4.2-p3, MPC version 0.8.1
heuristiques GGC: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 12095ba8527fd11f187b76cec8ccc6c5
COLLECT_GCC_OPTIONS= '-v' '-o' 'test'
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/../../../../x86_64-pc-linux-gnu/bin/as -V -Qy --64 -o /tmp/ccJvSQFc.o /tmp/ccmAagyo.s
GNU assembler version 2.20.1 (x86_64-pc-linux-gnu) using BFD version (GNU Binutils) 2.20.1.20100303
COMPILER_PATH=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.0/:/usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.0/:/usr/libexec/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/../../../../x86_64-pc-linux-gnu/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/../../../../x86_64-pc-linux-gnu/lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS= '-v' '-o' 'test'
 /usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.0/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o test /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/../../../../lib64/crti.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/crtbegin.o -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/../../.. /tmp/ccJvSQFc.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/crtend.o /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/../../../../lib64/crtn.0
Comment 14 Ryan Hill (RETIRED) gentoo-dev 2010-05-09 18:40:19 UTC
Created attachment 230885 [details, diff]
gcc45-PR44046-core2.patch
Comment 15 Cănărău Constantin 2010-05-10 05:25:23 UTC
From patch:
+	case 0x1a:
+	case 0x1e:
+	case 0x1f:
+	case 0x2e:
+	  /* FIXME: Optimize for Nehalem.  */
+	  cpu = "core2";
+	  break;

I presume this fix misdetection for Core i7. Am I right ?
Comment 16 Ryan Hill (RETIRED) gentoo-dev 2010-05-10 05:40:45 UTC
I assume it will.  If you'd like to test it there's a copy in my personal overlay with all the patches we have so far.
Comment 17 Cănărău Constantin 2010-05-11 18:51:18 UTC
I applied the patch manually and it's worked.
Are there any method as --param l2-cache-size=8192 to be used for Nehalem architecture ?
By default 256kb is used when reverting to core2 from atom:--param l2-cache-size=256
Or, perhaps, am I doing something wrong ?
Comment 18 Ryan Hill (RETIRED) gentoo-dev 2010-06-20 06:24:01 UTC
Added to cvs.  Will be included in the next patchset.
Comment 19 Ryan Hill (RETIRED) gentoo-dev 2010-06-27 04:24:04 UTC
Released in 1.2.