Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

There are a few larger programs I am interested in compiling with -Os. The normal method I use to patch/recompile programs is apt-get source followed by dpkg-buildpackage.

I learned from the dpkg-buildflags man page that I can set global flags in a configuration file. This seems to work for only some packages if I append the flags I want. The problem is that most programs ignore the flags and build with -O2 (and in some cases -O3) anyway.

Is there a way I can force the compiler to use -Os?

share|improve this question
1  
Can you list some specific packages so other people can try to help/reproduce your problem? –  Mikel Apr 20 '11 at 12:05
    
Alright. Well, the handbrake-gtk package from Debian multimedia gets -O3 from a script, I think the only way to set it up to compile with -Os is to modify the scripts. I was hoping there was a global way to do so. When I tried to rebuild pulseaudio, it accepts my build options, but appends -O2 to the end making it impossible to build it as -Os. –  NightwishFan Apr 21 '11 at 5:21
    
You can normally set the compile options in the rules file. Are you saying this doesn't work for you? –  Faheem Mitha Apr 21 '11 at 14:58
    
I looked at handbrake. You could just change this line in debian/rules - ./configure --gcc=/usr/lib/ccache/gcc CXX="$(CXX)" CFLAGS="$(CFLAGS)" \ --build build --prefix=/usr –  Faheem Mitha Apr 21 '11 at 15:02
    
Ok, I see. You want to change that everywhere. –  Faheem Mitha Apr 21 '11 at 15:03
show 1 more comment

1 Answer

There is no way to set this absolutely globally, short of patching the compiler itself. There is no firm policy for configuring this thing. The dpkg-buildflags approach is an attempt to unify this to some degree, bit it is still young. It should work for most packages, but if it doesn't, you'll have to patch the source package (and perhaps inform the package maintainer to sort this out).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.