LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-11-2004, 11:39 AM   #1
ganja_guru
Member
 
Registered: Dec 2003
Location: Chennai, India
Distribution: Arch Linux 0.7
Posts: 393

Rep: Reputation: 30
compiling from source with i686 optimizations


whenever programs are compiled from source, using ./configure && make && make install..my guess is it builds them with i386 optimizations...is it possible to build programs with i686 optimizations..or better yet with AMD Atholn XP optimizations, so that theyre faster? if so, what are the specific compiler flags(ff thats what theyre called to do so???

thanx a bunch
 
Old 08-11-2004, 03:50 PM   #2
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
You would add a CFLAGS environment variable (and a CXXFLAGS variable - that is for compiling C++ source-code...) to be used by your compiler

I do it in my ~/.bash_profile - but you can do it on the command-line every time you want to use it.

To compile with gcc and use optimizations for athlon-xp you would give (a) command(s) like this:

CFLAGS="-O2 -march=athlon-xp"
export CFLAGS
CXXFLAGS=$CFLAGS
export CXXFLAGS

this will only work with gcc from version 3.x - not with gcc-2.95.x - they do not recognize this
"-march=athlon-xp" flag

With gcc-2.95.x you will have to use "-march=i686" - thats as close as you can get with these compiler-versions.

This will make the compiler output code, that is optimized (-O2) and specific for Athlon-xp and similar processors (-march=athlon-xp)

I have a AMD Duron 1200 which is almost the same as an Athlon - and I compiled the whole system with these optimizations - or even more...

The code produced will cause your binaries ... only executable on processors with the same or a greater instruction set than athlon-xp - if will - for instance - NOT run on a pentium-class processor - probably also not on an older duron - like a duron 800 (because this one has a smaller instruction-set)

If the created binaries are really faster - I don't know, but I guess...they are surely larger
 
Old 08-11-2004, 07:49 PM   #3
ganja_guru
Member
 
Registered: Dec 2003
Location: Chennai, India
Distribution: Arch Linux 0.7
Posts: 393

Original Poster
Rep: Reputation: 30
thanks for the quick reply..

ok so i have to input those four commands before everytime i do the usual ./configure && make&& make install right.??
i dont have a ~/.bash_profile can i add it to ~/.xprofile instead? and is there anyway to know whether its actually compiling for athlon xp...cause those commands are not very verbose and i didnt see any specific otput in ./configure which indicates that its compiling for athlon-xp..
 
Old 08-12-2004, 03:31 AM   #4
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
...the ~/.xprofile is probably not the best place to put those commands.
If you are using bash as your shell, you shold have this file

There should be even more: ~/.bashrc ~/.bash_profile ~/.bash_history ~/.alias

If they are not there - you are using the settings from your globlal config-files in /etc then...

They are: /etc/bashrc /etc/profile /etc/environment

About the way to use these variables:

if you do not know how to initialize those variables (via ~/.bash_profile or ~/.bashrc) it is easiest and best to do it from command line!
You do not have to issue these commands every time over and over again!
You need to do it just once for every terminal you open and want to have those variables available.
If you do'nt want them anymore - you do not have to close that terminal but to clear the variables:

unset CFLAGS
unset CXXFLAGS

and everything is back as it was...

./configure probably does tell you...
But it is a script that is designed to configure the source tree for you - among other things it changes Makefiles - and there you find that it put in the options you gave it - the configure script has next to nothing to do with compiling - that comes later

If you want to know, what the option "-march=atlon-xp" does - as well as the other ones - there is only one place I know of to surely find this information for your compiler:

man gcc

here are the important lines:

-mcpu=cpu-type

Tune to cpu-type everything applicable about the generated code, except for the ABI and the set of available instructions. The choices for cpu-type are i386, i486, i586, i686, pentium, pentium-mmx, pentiumpro, pentium2, pentium3, pentium4, k6, k6-2, k6-3, athlon, athlon-tbird, athlon-4, athlon-xp, athlon-mp, winchip-c6, winchip2 and c3.

While picking a specific cpu-type will schedule things appropriately for that particular chip, the compiler will not generate any code that does not run on the i386 without the -march=cpu-type option being used. i586 is equivalent to pentium and i686 is equivalent to pentiumpro. k6 and athlon are the AMD chips as opposed to the Intel ones.

-march=cpu-type

Generate instructions for the machine type cpu-type. The choices for cpu-type are the same as for -mcpu. Moreover, specifying -march=cpu-type implies -mcpu=cpu-type.



...that's why you only need to give -march=... (added by me)
 
Old 08-12-2004, 06:35 AM   #5
ganja_guru
Member
 
Registered: Dec 2003
Location: Chennai, India
Distribution: Arch Linux 0.7
Posts: 393

Original Poster
Rep: Reputation: 30
thank you very much man...i added them to /etc/profile...compiled showimg successfully...

thanks again..
 
Old 08-12-2004, 08:40 AM   #6
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
you're welcome!
 
Old 11-08-2004, 09:26 AM   #7
nielchiano
Member
 
Registered: Feb 2004
Location: 50N 3E
Distribution: Gentoo
Posts: 64

Rep: Reputation: 15
I've been looking for hours for this, but can't find the answer. Maybe you guys (or girls?) can help.
my /proc/cpuinfo tells me
Code:
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 6
model           : 7
model name      : AMD Duron(tm) Processor
stepping        : 0
cpu MHz         : 995.776
cache size      : 64 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 mmx fxsr sse syscall mmxext 3dnowext 3dnow
bogomips        : 1985.74
Question: What is the best (highest) option I can pass to -march=... without using opcodes that my processor doesn't support?
Surely i386 will work, and possible i686 too;
And I guess even athlon will do; but will athlon-xp still work? or are there new opcodes in the athlon xp?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling Firefox with i686 optimizations? Jacksteruk309 Linux - Newbie 3 10-19-2005 12:22 PM
compiling for i686 SVN Linux - Newbie 4 04-11-2004 04:24 PM
I need kernel source 2.4.20-20.9 i686 Peit Linux - General 8 10-10-2003 03:41 AM
no i686 kernel source? LooseCanon Red Hat 4 09-18-2003 05:22 PM
1586 vs i686 compiling? wrc1944 Linux - General 3 08-02-2002 09:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration