-O2 optimization

M. Warner Losh imp at bsdimp.com
Wed Sep 13 10:11:52 PDT 2006


In message: <20060911163218.GA88778 at dragon.NUXI.org>
            "David O'Brien" <obrien at FreeBSD.org> writes:
: I've been wondering.  Since most ARM platforms are RAM and storage
: limited, should we not compile with -O2 and use -Os instead.
: 
: -Os is "Optimize for size. -Os enables all -O2 optimizations that do not
: typically increase code size. It also performs further optimizations
: designed to reduce code size".
: 
: So what do folks think about this patch?

I like the idea, but I'm not sure I like the testing of MACHINE_ARCH
directly for this.  Maybe something like OPT_SMALL being defined
instead?  However, the following change saved ~65kB in a ~1900kB
kernel I just built, or about 3%.  That seems signficant enough to me
to have a knob for.

: Index: kern.pre.mk
: ===================================================================
: RCS file: /home/ncvs/src/sys/conf/kern.pre.mk,v
: retrieving revision 1.76
: diff -u -p -r1.76 kern.pre.mk
: --- kern.pre.mk	17 Jul 2006 18:43:16 -0000	1.76
: +++ kern.pre.mk	11 Sep 2006 16:29:47 -0000
: @@ -27,7 +27,11 @@ COPTFLAGS?=	-O
:  . if defined(DEBUG)
:  _MINUS_O=	-O
:  . else
: +.  if ${MACHINE_ARCH} == "arm"
: +_MINUS_O=	-Os
: +.  else
:  _MINUS_O=	-O2
: +.  endif
:  . endif
:  . if ${MACHINE_ARCH} == "amd64"
:  COPTFLAGS?=-O2 -frename-registers -pipe
: 
: -- 
: -- David  (obrien at FreeBSD.org)
: Q: Because it reverses the logical flow of conversation.
: A: Why is top-posting (putting a reply at the top of the message) frowned upon?
: _______________________________________________
: freebsd-arm at freebsd.org mailing list
: http://lists.freebsd.org/mailman/listinfo/freebsd-arm
: To unsubscribe, send any mail to "freebsd-arm-unsubscribe at freebsd.org"
: 
: 


More information about the freebsd-arm mailing list