good (working) CFLAGS for SPARC64 (Christian Baer)

Steven Hillis evultrole at
Fri Feb 2 20:36:58 UTC 2007


I've personally had some success with the following:
-O2 -mcpu=ultrasparc -pipe -fomit-frame-pointer -ffast-math
-finline-functions -fweb -frename-registers -mapp-regs

Now, I'm pretty sure there are people who would scold me about a few of
those uses, mapp-regs and fast-math specifically, but I don't have any
troubles as a result of them in what I do... I don't know the default
setting of mapp-regs, it varies from system to system (on in Linux, off in
Solaris, dunno in any BSD), this may be an unneeded flag. Likewise,
fomit-frame-pointer may be enabled by default or it may not, depends on how
gcc may decide if "doing so does not interfere with debugging"... I
personally don't care half a crap about debugging, so I stick it in just to
be sure. Most of the extra flags in there mess up debugging, so toss them
out if you care about that.

Really I guess most of that is either just being sure something is enabled
or going a little past -O3 without the funswitch-loops bit (I don't like
that option so I don't use it, don't ask me why, it's completely irrational,
I don't even know what it does. It broke a program one time during compile
and I've never used it since.)

Also, the fact that I get it to compile and run everything with those flags
may be a complete fluke, I've had problems with -O3 in the past (when -O was
the most recommended on the kernel) and I don't know what has changed since,
but what I have enabled now seems to be ok for me.

Also, I don't use -m64 as there is no 32-bit environment support in
FreeBSD-Sparc64 anyway, so it seems that adding it would be... redundant? if
this is not the case someone please chime in. I don't claim to know how
longs and pointers are set in binaries by default, it just seems it would be
the case.

Message: 1
> Date: Thu, 1 Feb 2007 13:52:25 +0100 (CET)
> From: Christian Baer <christian.baer at>
> Subject: good (working) CFLAGS for SPARC64
> To: freebsd-sparc64 at
> Message-ID: <epsnq9$jnn$4 at>
> Hello everybody! :-)
> I've been reading up a little on how to make my system a little faster.
> If you are running some Core2 Duo or a fast AMD64, you might not bother
> to even think about this, as the system will be fast enough "as is". But
> the fastest CPUs supported by FreeBSD are UltraSPARC II with 450MHz,
> probably making the U60 and U80 the fastest current SPARC64 machines for
> FreeBSD. Just the same, my U60 with 2GB auf RAM and 2 450MHz CPUs isn't
> exactly Formular 1. :-)
> Since the SPARC plattform in general seems to benifit a great deal from
> optimization flags at compile time (much more than i386) I thought it
> might be a good idea to look at a few options.
> First of all, I can't really find the options FreeBSD seems to have, no
> matter if I'm compiling world, kernel or something else. The file that
> the handbook states: /usr/share/examples/etc/make.conf doesn't exist.
> Actually, /usr/share/examples/etc/ doesn't even exist on my machine. I
> am running FreeBSD 6.2-STABLE (updated late night; CET). There is a file
> in /usr/src/share/examples/etc/ but it seems to be from the i386
> platform (CPU-type is PIII) and doesn't contain really sane defaults for
> SPARC64 and certainly doesn't seem to contain the defaults that apply to
> my system (from what I've observed). Is there such thing as a make.conf
> that contains all the defaults for sparc64? If so, where is it?
> Looking at what I see when compiling just about anything, I'd say the
> CFLAGS are set to "-O2 -pipe", where the second option doesn't really do
> much about the code being created. CXXFLAGS probably isn't set so the
> options there are the same as for CFLAGS. If these are the only settings
> passed on to the cc, it will probably create code that is "optimized"
> for the V7. At least, that would be the default according to the
> documentation of the gcc. V7 code isn't really all that good for any v9
> CPU, including my UltraSPARC II, as the istruction set is rather
> restricted.
> I was thinking of setting the CFLAGS to something like
> -O2 -pipe -mcpu=ultrasparc -m64
> Is that a sane configuration? Will the world and the kernel run with
> those? Has anyone ever tried that? :-)
> Since -O3 doesn't really help speeding up the result much (exept when
> you aretrying to kill time while compiling), I haven't bothered with
> that one. Does FreeBSD even compile with that on?
> Regards
> Chris

More information about the freebsd-sparc64 mailing list