[cfe-dev] clang driver defaults to -mcpu=pentium4, why?

Daniel Dunbar daniel at zuster.org
Mon May 18 01:50:12 PDT 2009


On Mon, May 18, 2009 at 1:35 AM, Roman Divacky <rdivacky at freebsd.org> wrote:
> hi
>
> as $subj says, clang defaults to -mcpu=pentium4 for i386 arch. I wonder why.
> llvm provides autodetection of the current CPU. wouldnt that be more sane
> default?

Maybe, maybe not. Chris and I have argued back and forth about this topic... :)

The traditional gcc behavior is to be very conservative in choosing
the default arch. This has the upside that programs are more portable,
and the downside that they are slower.

Given the traditional gcc behavior, my personal feeling is that
changing the default to be the active CPU is risky. Developers may end
up distributing a binary they think is portable, but isn't, which will
be very confusing if it only fails in some corner case where a new
instruction was used.

On the other hand, its probably true that most compiler code is made
for the machine it is run on, or when it is being built for
distribution the architecture is already forced.

I'm open to being convinced that -march=native is the correct default...

> also, how can I enable the "build for my native cpu" now?

It should be with "-march=native", but this is not yet implemented in
the clang Driver. Patches/bugzillas welcome! :)

 - Daniel



More information about the cfe-dev mailing list