Debian – How to recompile a Debian package with -Os

compilingdebiangcc

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?

Best 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).

Related Question