LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Compiling (GCC) - Optimisation (https://www.linuxquestions.org/questions/programming-9/compiling-gcc-optimisation-49952/)

anonE9 03-15-2003 08:40 AM

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

crashmeister 03-15-2003 09:06 AM

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.

niknah 03-15-2003 09:16 AM

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

anonE9 03-15-2003 04:33 PM

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?

crashmeister 03-15-2003 06:17 PM

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.

anonE9 03-15-2003 08:20 PM

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?


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