# march=athlon activate 3dnow?

## dman777

Not sure where to post this but since it involves functions of the CPU I decided to post it here....

 when i compiled compiz fusion on my amd sempron cpu(about 7 yrs old) i used -march=athlon. when i try to run it i get a illegal instruction set error. can anyone help? does compiz-fusion use 3dnow feature of the amd cpu? I can not use -march=native...to make a long story short.

----------

## NeddySeagoon

dman777,

Please post your 

```
emerge --info
```

 and your 

```
/proc/cpuinfo
```

----------

## dman777

```

Portage 2.1.9.24 (default/linux/x86/10.0, gcc-4.4.4, glibc-2.11.2-r3, 2.6.34-gentoo-r12 i686)

=================================================================

System uname: Linux-2.6.34-gentoo-r12-i686-Mobile_AMD_Sempron-tm-_Processor_2800+-with-gentoo-1.12.14

Timestamp of tree: Wed, 15 Dec 2010 05:00:01 +0000

app-shells/bash:     4.1_p7

dev-lang/python:     2.6.5-r3, 3.1.2-r4

dev-util/cmake:      2.8.1-r2

sys-apps/baselayout: 1.12.14-r1

sys-apps/sandbox:    2.3-r1

sys-devel/autoconf:  2.13, 2.65-r1

sys-devel/automake:  1.9.6-r3, 1.10.3, 1.11.1

sys-devel/binutils:  2.20.1-r1

sys-devel/gcc:       4.4.4-r2

sys-devel/gcc-config: 1.4.1

sys-devel/libtool:   2.2.10

sys-devel/make:      3.81-r2

virtual/os-headers:  2.6.30-r1 (sys-kernel/linux-headers)

ACCEPT_KEYWORDS="x86"

ACCEPT_LICENSE="*"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-march=athlon"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT=""

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"

CXXFLAGS="-march=athlon"

DISTDIR="/usr/portage/distfiles"

FEATURES="assume-digests binpkg-logs distlocks fixlafiles fixpackages news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"

GENTOO_MIRRORS="http://mirror.mcs.anl.gov/pub/gentoo/"

LDFLAGS="-Wl,-O1 -Wl,--as-needed"

MAKEOPTS="-j6"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/var/db/old_ebuilds"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="3dnow 3dnowext X acl acpi berkdb bindist bzip2 cairo cli cracklib crypt cups cxx dbus dri evdev fortran fuse gdbm gimp glitz gnutls gpm gtk iconv iso14755 jpeg mmx modules mudflap ncurses nls nptl nptlonly nvidia opengl openmp pam pcre perl png pppd python qt3support qt4 readline session sse sse2 sse3 sse4a ssl svg sysfs tcpd tiff truetype udev unicode virtualbox x86 xcb xorg xvmc zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="synaptics evdev virtualbox keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" PHP_TARGETS="php5-2" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="radeon" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" 

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
```

```
processor   : 0

vendor_id   : AuthenticAMD

cpu family   : 15

model      : 28

model name   : Mobile AMD Sempron(tm) Processor 2800+

stepping   : 0

cpu MHz      : 1600.000

cache size   : 256 KB

fdiv_bug   : no

hlt_bug      : no

f00f_bug   : no

coma_bug   : no

fpu      : yes

fpu_exception   : yes

cpuid level   : 1

wp      : yes

flags      : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt 3dnowext 3dnow lahf_lm

bogomips   : 3200.20

clflush size   : 64

cache_alignment   : 64

address sizes   : 40 bits physical, 32 bits virtual

power management: ts fid vid ttp
```

I did this in startx and it was really difficult since I am so bad at controlling windows in it, so please let me know if anything didn't paste correctly.

----------

## NeddySeagoon

dman777,

You have USE="sse sse2 sse3 sse4a" set from somewhere but you CPU only supports sse and sse2.

Turn off   sse3 and sse4a  then 

```
emerge world -NDav
```

to rebuild all the packages that may have used sse3 and sse4a

3dnow, 3dnowext, mmx and mmxext are all ok as they are in your USE and in your cpuinfo.

-------- edit ----------

This one liner

```
 echo 'int main(){return 0;}' > test.c && gcc -v -Q -march=native -O2 test.c -o test && rm test.c test
```

shows what gcc would set for your CPU based on what it detects. Change the -march=native to  -march=athlon to see what gcc sets for that particular march.

gcc drops some of the multimedia extensions your Sempron has. march=athlon-xp seems a better match as it adds in sse.

However you also have nx and sse2, which athlon-xps don't.

You must not use -march=native if you intend to use distcc or you want your binaries to run on other CPUs.

----------

## dman777

Neddy,

Thank you so much! Your always a great help!

-dman777

----------

## dman777

Well, bad news. I am still getting illegal instruction when trying to run compiz fusion after the recompile. I took out the sse3 and sse4a and changed march to athlon-xp. Then I recompiled the whole system with emerge -ev world. 

To give an extra insight... my laptop is so slow(7 years old) it's not worth compiling on anymore. I used my home PC to build a new system with chroot. Then I copy the new root file system to my laptop. 

 None of the other programs are giving me this error, just compiz fusion so I believe it could still be some feature used that my cpu doesn't support. What do you think?

----------

## NeddySeagoon

dman777,

Its certainly something your CPU does not support - but what.

Post your emerge --info and /proc/cpuinfo and I'll look again

----------

## dman777

```
localhost one # emerge --info

!!! CONFIG_PROTECT is empty

Portage 2.1.9.24 (default/linux/x86/10.0, gcc-4.4.4, glibc-2.11.2-r3, 2.6.34-gentoo-r12 i686)

=================================================================

System uname: Linux-2.6.34-gentoo-r12-i686-Mobile_AMD_Sempron-tm-_Processor_2800+-with-gentoo-1.12.14

Timestamp of tree: Fri, 26 Nov 2010 09:00:01 +0000

app-shells/bash:     4.1_p7

dev-lang/python:     2.6.5-r3, 3.1.2-r4

dev-util/cmake:      2.8.1-r2

sys-apps/baselayout: 1.12.14-r1

sys-apps/sandbox:    2.3-r1

sys-devel/autoconf:  2.13, 2.65-r1

sys-devel/automake:  1.9.6-r3, 1.10.3, 1.11.1

sys-devel/binutils:  2.20.1-r1

sys-devel/gcc:       4.4.4-r2

sys-devel/gcc-config: 1.4.1

sys-devel/libtool:   2.2.10

sys-devel/make:      3.81-r2

virtual/os-headers:  2.6.30-r1 (sys-kernel/linux-headers)

ACCEPT_KEYWORDS="x86"

ACCEPT_LICENSE="*"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-march=athlon-xp"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT=""

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"

CXXFLAGS="-march=athlon-xp"

DISTDIR="/usr/portage/distfiles"

FEATURES="assume-digests binpkg-logs distlocks fixlafiles fixpackages news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"

GENTOO_MIRRORS="http://mirror.mcs.anl.gov/pub/gentoo/"

LDFLAGS="-Wl,-O1 -Wl,--as-needed"

MAKEOPTS="-j6"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/var/db/old_ebuilds"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="3dnow 3dnowext X acl acpi berkdb bindist bzip2 cairo cli cracklib crypt cups cxx dbus dri evdev fortran fuse gdbm gimp glitz gnutls gpm gtk iconv iso14755 jpeg mmx modules mudflap ncurses nls nptl nptlonly nvidia opengl openmp pam pcre perl png pppd python qt3support qt4 readline session sse sse2 ssl svg sysfs tcpd tiff truetype udev unicode virtualbox x86 xcb xorg xvmc zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="synaptics evdev virtualbox keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" PHP_TARGETS="php5-2" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="radeon" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" 

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

```

```

localhost one # cat /proc/cpuinfo 

processor       : 0

vendor_id       : AuthenticAMD

cpu family      : 15

model           : 28

model name      : Mobile AMD Sempron(tm) Processor 2800+

stepping        : 0

cpu MHz         : 1600.000

cache size      : 256 KB

fdiv_bug        : no

hlt_bug         : no

f00f_bug        : no

coma_bug        : no

fpu             : yes

fpu_exception   : yes

cpuid level     : 1

wp              : yes

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt 3dnowext 3dnow lahf_lm

bogomips        : 3200.17

clflush size    : 64

cache_alignment : 64

address sizes   : 40 bits physical, 32 bits virtual

power management: ts fid vid ttp

```

[/code]

----------

## NeddySeagoon

dman777,

Your CPU flags line is

```
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt 3dnowext 3dnow lahf_lm 
```

We are only looking at a subset of them

```
flags :  mmx  sse sse2 mmxext 3dnowext 3dnow
```

all of those flags have similarly named USE flags, which you can and should use. You must not enable any other multimedia instructions or you risk the illegal instruction error.

mmx dates back to the Pentium 1 mmx 

3dnow! was AMDs answer to mmx

Next came mmxext from Intel and AMD responded with 3Dnowext.  

You can use all of them but your USE is missing mmxext.

You can also use sse and sse2 - which you have set.  I don't see anything there that will cause an illegal instruction.  Are you sure you rebuilt world with the -N option?

Your CXXFLAGS="-march=athlon-xp"  and CFLAGS="-march=athlon-xp"  would benefit from the addition of "-O2 -pipe" -O2 will make you code smaller and faster and -pipe will use memory for intermediate files, so things build faster.

Flags from a real athlon-xp are 

```
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse syscall mmxext 3dnowext 3dnow
```

Which are a subset of your flags, so -march=athlon-xp is good for you.

The only other thing I can think of is that there is a bug in AMDs sse or sse2 implementation. Google hasn't heard about it so thats unlikely.

----------

## Bircoph

Athlon-XP does not support SSE2, only SSE, so remove sse2 from your flags as well.

----------

## NeddySeagoon

Bircoph,

... but the target CPU is not an athon-xp, the target CPU is 

```
model name      : Mobile AMD Sempron(tm) Processor 2800+ 
```

which claims sse2 support in its /proc/cpuinfo.

In USE flags, sse2 turns on optional support where there are code paths explicity designed to use sse2. Its not in CFLAGS, which would allow gcc to use sse2 as it saw fit.

It could be I suppose.

----------

## pigeon768

Why can't you use "-march=native"?

Use "-march=k8 -O2 -pipe", although "-march=native -O2 -pipe" is preferable. Your cpu is based on the k8 architecture, not on the k7 architecture. -O2 is much better tested than the alternative.

You'll have to do "emerge -e @world" to recompile everything with the new CFLAGS, otherwise it has no effect.

----------

## dman777

I did use emerge -ev world.

before i chroot i do a:

mount -t proc none /mnt/laptop_compile/proc

mount -o bind /dev /mnt/laptop_compile/dev/

would this have anything to do with the problem i am having?

----------

