Compiling from source with optimizations
First I should apologize for my likely naive questions, but I have only started playing with actual optimizations in the last week or so; I have always just compiled with the defaults before.
Anyway, I have recently been playing with compiler flags through the use od SlackBuild scripts, and had a few questions and thoughts that I would like cleared up.
1. I have read in the GCC documentation that -march implies -mtune to the same CPU type. But I have seen many scripts specifying both. Is it alright that I am just using -march?
2. In the official Slackware build scripts, the following is added to ./configure:
4. Finally, I have noticed that when I build a package that should be compiled only for Pentium 4 (if I am doing it right), I am able to run the binaries on the server. I had got the impression that once they were compiled for a specific CPU, that was it, and they would not run on a different chip (the server has an AMD XP 1500+, and my desktop has a 2.4 GHz P4). So this has gotten me thinking that I have either done something wrong and they are not fully optimized for Pentium 4, or that I was a little too gullible with what I read online about CPU optimizations.
Again, I am sorry if a lot of this is very obvious, but I have not been able to find clear explanations for some of these issues, and it seems like the kind of thing were you really want to hear other's first hand accounts to make sure you are getting the best performance. I should also note that I do "feel" a considerable performance boost in some applications (most notably, Wine) so I must be doing something right.
Not that I'm any kind of expert, but....
1. It shouldn't hurt. I specify both in my build flags and haven't had any problems.
2. i786 is the technology used in Intel's Pentium 4 chips.
3. --build=build-type is the machine that you are configuring and building the package on (your server)
--host=host-type is the machine that will run the resulting binaries. By default it is the same as build. Specify both --build and --host to cross-compile.
--target=target-type is the type of machine that any compiler tools in the package will produce code. By
default, it is the same as host.
4. Optimized, not exclusive. It will still run on x86 architectures, just not optimally.
From Gentoo handbook:
But even with -march, I have gone so far as to run Pentium 4 optimized binaries on a Pentium 3 and have not had problems, to say nothing of the AMD XP. But perhaps the code I was optimizing was too simplistic for the optimizations to make that much of an impact on the resulting binary, I was only using simple programs to test.
|All times are GMT -5. The time now is 12:51 PM.|