Gentoo, specify optimization for different compiles
Linux - SoftwareThis 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.
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.
Gentoo, specify optimization for different compiles
Hi,
I use Gentoo 2006.0. I was wondering if anybody knew of a way to specify which programs used which processor optimization flags, without editing the make or dist files or anything specifically. For example, Firefox works better when compiled with the -Os flag, because it is large and takes a long time to start up, so if you make the code as small as possible, it tends to start up faster, but once it's started, its not using much processing power so thats not needed, so it would be optimized for startup time. But then theres other programs that I would want to be optimized for processing power, for various reasons, so say I would compile games, servers, etc with the -O3 flag (or anything else that would be specifically benefitial to that program, doesn't have to just be -Os and -O3, those are only examples) because I don't really care how long they take to start up, but once they're started I want them to run as fast as possible.
I know in the make.conf file you can specify which optimization flags to use, but I would like to make the modification stick for specific programs, so that say, when I do an update of all the programs on my system, it would still compile Firefox with -Os, and still compile Quake 3 with -O3, without me having to manually change it, and it would stick through version changes, and emerge syncs.
If anybody knows of a way to do this, if you could point me in the right dirrection, it would be much appriciated!
Edit: I guess that doesn't answer your question. You want to set CFLAGS, not USE flags. Apparently this was a Request For Enhancement sometime last year, but I don't know if it has been implemented yet.
Otherwise you could probably do
CFLAGS="-Os" emerge ....
or something similar for each package.
Last edited by maroonbaboon; 04-28-2006 at 01:09 AM.
That link looks like it is describing ways to specify USE flags for specific programs, but I think the optimization flags are differnet, in the make.conf file, USE flags are like:
USE="X gtk -kde"
... and whatever. Where as the compiler flags are set like:
CFLAGS="-march=pentium3 -O2 -pipe"
... or whatever.
I would like to be able to change the CFLAGS variable for invididual programs and make the changes stick, so everytime I compiled Firefox, no matter what version, or if I had emerge sync'd from the last time I set it, it would compile with -Os, where as, say, if I compiled Fluxbox, it would always compile with -O3, and I could just let the regular make.conf handle the ones I don't want to modify. Right now, after every update (where I emerge sync, emerge world -upD) it will compile everything as -O2, and then I have to go back and RECOMPILE things like Firefox that I want to be -Os, which is time consuming and annoying. I don't think/know if there is a way to do this via the USE flags stuff, but I didn't think there was. I thought it was a completely different thing. One has to do with options passed to ./configure (i think), and the other has to do with what flags are passed to gcc upon compliation.
The assumption that Gentoo makes is that the user wants to compile every program with the same compiler flags, where as this is not always desireable in cases such as my own. Firefox starts like 8 seconds faster if I compile with -Os verses -O3. But if I compile everything in -Os, some things that I dont care about starting up fast feel slugish in operation, or don't work right.
I realised I had not answered your question, but my edit crossed over with your second post. If you google for "package specific CFLAGS" you will know as much or more than me.
Interesting fact about Firefox startup time. I didn't realise the difference could be so large.
Yeah, well, the real bottleneck in program start time I have found is the hard drive speed. If you make the program smaller, the drive has less to read, and can get it much faster, and although the processor churns through the code a bit slower, the outcome is a pretty drastic reduction in start time, at the cost of a little runtime efficiency, but in firefox I find that hardly noticeable, it's not a very processor intensive application. But the start time is irrellivant in things that start once and run all the time, like deamons, servers, X, the base of window managers, games, etc, because once they're started you ususally just leave them running for days at a time and it is more important to have them respond fast while they are running. Overall I am just trying to customize my system into being a little more snappy by selecting where I can make tradeoffs from start time, memory useage, and processor useage. The gains are relative, and each user perfers a different thing, but that's what Gentoo is about, so I am supprised there is not an easier way to do this.
I was thinking I may code something of my own to do this, now that I'm thinking about it it doesn't seem that it would be too difficult. The code would get the programs that were going to be emerged (by doing an emerge -p on whatever you were emerging I suppose), and grep them out, and then read from a file where I specify CFLAGS for each program I want to have specific CFLAGS, and then emerge each program and dependancy individually, matching and setting the CFLAGS for that program alone, then going on and doing a another emerge for the next one with different CFLAGS. A front end to emerge/portage I guess you could say. I would elaborate, but I have class. I'll post it here if I start a project like that, it seems useful.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.