Replaceing stock GCC CFLAGS

Hello.

I have just gotten to download a package that I built, that I called conky-small. I called it small because I compiled it with -Os. However looking at the build log it was not only built with -Os built also with -O2. At first I did not think that this was a problem, because from what I understand is that the last CFLAG entered would be the one that is used. So when I was testing out conky against the conky that I branched from, I was surprised that my conky-small said that I was using 144 meg of RAM. When I was using the https://build.opensuse.org/package/show/server:monitoring/conky conky it read correctly at using 44 meg of ram. I checked my conky-small against htop and htop reported that I was using 44 meg of ram and not 144 meg of RAM. Back when I used GENTOO I do remember some users complaining of application failures from accidentally including more than one CFLAGS. So I am curious, how do I put in my -Os CFLAG to override the -O2 CFLAG?

My spec file is the same as the original one, but above:

make %{?_smp_mflags}

I put CFLAGS="-Os"

So it looks like this

CFLAGS="-Os"
make %{?_smp_mflags}

Thank you!

Hi
There is a macro called %{optlags} you can use (well should use :wink: ) which shows up all sorts of coding errors, esp in the post build checks showing things are compiled without opt flags…


Default %{optflags}

-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables

You can also set flags to your desire via the pjoject config file, for example;
https://build.opensuse.org/project/prjconf/openSUSE:Factory

In your case either export (which may/may not work) it first or add inline;


export CFLAGS="-Os"

or

make CFLAGS="-Os" %{?_smp_mflags}

Lots of ways to do things :wink:

Thanks I will try that

Thank you once again, that fixed it for me.