LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-15-2003, 09:40 AM   #1
anonE9
LQ Newbie
 
Registered: Mar 2003
Location: adfa3 32awrFS
Distribution: a sdfa3 wefds
Posts: 19

Rep: Reputation: 0
Compiling (GCC) - Optimisation


Greetings fellow Linux users and potential Linux users!

The tweakability aspect of open-source appeals to me alot. I know alot of apps (more so windowS ones) do not even optimise for MMX (Intel Pentium) or 3DNow! (AMD).

Here are my specs, so please generate some instructions based on them:

* Pentium 4 1.8Ghz
* Using VectorLinux 3.2 (Debian-based I think)

... that's all you need to know, isn't it?!?!

Tell me what configuration files to configure, what flags to enable, etc. Include an explanation (if it is not self-explanitory) for each step, and some general instructions aswell. And please don't direct me to other pages on the 'Net, the ones I've tried have been unsatisfactory and unconcice, and/or outdated (e.g. the official GNU GCC documentation).

Looking forward to tweaking (i.e. optimising) my apps, and maybe, one day, building my own Linux From Scratch (LFS) system,

AnonE9
 
Old 03-15-2003, 10:06 AM   #2
crashmeister
Senior Member
 
Registered: Feb 2002
Distribution: t2 - trying to anyway
Posts: 2,541

Rep: Reputation: 47
Hehe - you are funny.The flags you use depend on the apps you compile and the compiler you use plus on the risk you are willing to take to end up with a binary that doesn't exactly what it is supposed to do.If you have the definite need to play with compiler flags you might want to consider gentoo.And here's the link to more info: http://forums.gentoo.org/viewtopic.p...light=gcc+flag

Oh - forgot to mention many flags don't get used depending on the processor type because the gcc guys disabled them.Plus many apps override your setting when you compile them.

Last edited by crashmeister; 03-15-2003 at 10:10 AM.
 
Old 03-15-2003, 10:16 AM   #3
niknah
Member
 
Registered: Dec 2002
Location: In front of a computer
Distribution: UPS, DHL, FedEx
Posts: 466

Rep: Reputation: 38
If you just take a normal program and try to mmx it, it isn't always going to run faster, try playing with some of these options and see if your program runs faster....
-mmmx -msse -msse2 -msse-math

also use -mcpu=pentium-mmx
 
Old 03-15-2003, 05:33 PM   #4
anonE9
LQ Newbie
 
Registered: Mar 2003
Location: adfa3 32awrFS
Distribution: a sdfa3 wefds
Posts: 19

Original Poster
Rep: Reputation: 0
Right so let me clear up a thing or two, I'm not a computer illiterate moran, but I'm new to Linux and I have questions on how do this, that and the other, as things are done differently on the Linux side (as is the case with different OSes) and there are many new things to learn.

I know you comprimise speed for stability when you optimise for your processor, but that depends on to what extent you optimise, i.e. if its just the architecture, the processor or others. I didn't say this in my initial post too clearly, and you didn't interperet it well, so I'll say it now:

give me some general instructions, a primer on optimisations with GCC. Tell me what configuration files where instructs GCC to do what when compiling, and how to do that by default every time.

And no, I don't intend on installing (or as the case may be, developing) a Gentoo system; I don't have the time or the extensive knowledge required (for the latter, yet)

And I won't be compiling each and every application, and when I do they won't always be with optimisations, depending on how convenient it is and if there is a noticable speed/stability effect. It's mostly the big applications I'm thinking about, e.g. Mozilla. I compiled Mozilla without any optimisations (i.e. 486) and boy was it slow! I know it's slow normally, but the default 0.9.x that was installed at the time performed much better. Or KDE. In other words the monolithic, perhaps bloated, but (for me and alot of other desktop users) indispensible projects.

Or the Linux kernel itself. Or resource-intensive video applications and libraries such as XVID (MPEG-4) or Transcode.

You get the drift, I've a fairly good idea of what I'm talking (and asking) about, but I'm a newbie, and this is a newbie forum after all.

So now, can you help?
 
Old 03-15-2003, 07:17 PM   #5
crashmeister
Senior Member
 
Registered: Feb 2002
Distribution: t2 - trying to anyway
Posts: 2,541

Rep: Reputation: 47
Nobody can really tell you what flags will work on your box with a specific program for sur if you want to go to extremes.
With the gcc2.x compiler versions you needed to enable a lot of flags because it only had processor flags for i386 - i686.gcc3 versions got flags for specific CPU's and the instructions that CPU understands are already enabled when you set the CPU flag to your type.You got two options there one is -mcpu=cpu-type;makes code that is optimised for the CPU but also works on any i386.If you put additionally -march=cpu-type it will only work on the specified CPU.
So basically -mcpu=cpu-type -march=cpu-type -O2 -pipe is considered to be on the safe side.You can also use -O3 but some apps don't like it too much and I've seen a comparison of different benchmarks that really work much faster with -O1 and -O2 but -O3 doesn't seem to be worth the trouble.
There are a lot of other options but those are way over my head.I'm happy I got gentoo running the way it is.About this you really need to check with the gcc website.I don't see what is outdated there.There is a manual that covers all the options for gcc3.2.2 and that is pretty much the latest release.
 
Old 03-15-2003, 09:20 PM   #6
anonE9
LQ Newbie
 
Registered: Mar 2003
Location: adfa3 32awrFS
Distribution: a sdfa3 wefds
Posts: 19

Original Poster
Rep: Reputation: 0
Thanks for the suggestion! Short and to the point.

And do these flags go anywhere in configuration files (at home directory or elsewhere), so that they are used by default for all compiles?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 using gcc Damitha Mandriva 1 12-17-2004 06:11 AM
Kernel compiling: gcc-3.3 is 586, should be gcc-3.3 386 Erik Plaggenmar Linux - Software 0 10-01-2004 12:38 PM
Various Compiling Errors (GCC compiling Openal, GUIlib, xmms-wma) gregorya Linux - Software 2 08-27-2004 06:03 AM
Compiling gcc CuteBug Linux - Software 2 02-22-2004 10:19 AM
Compiling C++ GCC poeta_boy Linux - Newbie 14 10-14-2003 05:23 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration