Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 6 Nov 2011 20:23:54 +0400
From: Vasiliy Kulikov <>
Subject: Re: %optflags for new gcc


On Sat, Nov 05, 2011 at 19:21 +0400, Solar Designer wrote:
> >
> > "-fomit-frame-pointer
> > ...
> > Enabled at levels -O, -O2, -O3, -Os."
> > 
> > IOW, it it enabled by default on BOTH -O2 and -Os.
> I think this is an error in the documentation.
> Notice the "when not optimizing for size" remark.  Feel free to test and
> submit a documentation patch upstream (removing ", -Os" from the list).


> And it's a curious comment that "some vendors have patched the gcc to
> make this option default" (regarding -fstack-protector).  Do you know
> any examples?  Maybe Ubuntu (just a guess)?

Yes, Ubuntu does.  I think we may patch ld and gcc to enable SSP and
-z,relro by default, but explicitly pass FORTIFY_SOURCE=2 in
spec files, which behave well with them.  

Possible problems with FORTIFY_SOURCE:

I cannot find what wrong can happen with -z,now.  I'm finding only bug
in ld's implementation of "-z now" :-)

"ld -z now" might significantly slowdown the loading of bloated apps
with tons of dynamic libraries like X apps (OpenOffice, Firefox, etc.).
Given (almost?) all official Owl programs are very small in sense of
used dynamic libraries, we probably may want to use -z,now in %optflags,
but not change binutils' defaults.  In this case all manually compiled
programs, which might be rather large and use numerous dynlibs, will not
be significantly slowed down.

BTW, one note.  From


First enabled in Ubuntu 8.10. Provides compile-time best-practices
errors for certain libc functions, and provides run-time checks of
buffer lengths and memory regions. Only activated when compiled with -O2
or higher."

See the -O2 or higher restriction.  We'll need to check whether it is
-Os' case too.

> > But for bootstraping we probably should explicitly pass -fPIE to gcc in
> > gcc.spec.
> Why?  What problem would we have if we don't?

Ah, my mistake - we pass %optflags to gcc anyway in gcc.spec:


    # Let's compile the thing
    # STAGE1_CFLAGS is used for stage1 compiler
    # BOOT_FLAGS is used for stage2..n compiler
    # ..._FOR_TARGET is used for final compiler

    %__make bootstrap-lean \
        STAGE1_CFLAGS="-O -fomit-frame-pointer" \
        BOOT_CFLAGS="-O -fomit-frame-pointer" \
        CXXFLAGS_FOR_TARGET="${TARGET_OPT_FLAGS//-fno-rtti/}" \

So, no workaround for gcc is needed.



Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ