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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
08-11-2004, 11:39 AM
|
#1
|
Member
Registered: Dec 2003
Location: Chennai, India
Distribution: Arch Linux 0.7
Posts: 393
Rep:
|
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
|
|
|
08-11-2004, 03:50 PM
|
#2
|
Senior Member
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687
Rep:
|
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
|
|
|
08-11-2004, 07:49 PM
|
#3
|
Member
Registered: Dec 2003
Location: Chennai, India
Distribution: Arch Linux 0.7
Posts: 393
Original Poster
Rep:
|
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..
|
|
|
08-12-2004, 03:31 AM
|
#4
|
Senior Member
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687
Rep:
|
...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)
|
|
|
08-12-2004, 06:35 AM
|
#5
|
Member
Registered: Dec 2003
Location: Chennai, India
Distribution: Arch Linux 0.7
Posts: 393
Original Poster
Rep:
|
thank you very much man...i added them to /etc/profile...compiled showimg successfully...
thanks again..
|
|
|
08-12-2004, 08:40 AM
|
#6
|
Senior Member
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687
Rep:
|
you're welcome!
|
|
|
11-08-2004, 09:26 AM
|
#7
|
Member
Registered: Feb 2004
Location: 50N 3E
Distribution: Gentoo
Posts: 64
Rep:
|
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?
|
|
|
All times are GMT -5. The time now is 08:23 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|