clang driver defaults to -mcpu=pentium4, why?

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?

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

thnx, roman

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... :slight_smile:

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! :slight_smile:

- Daniel

> 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... :slight_smile:

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...

I am ok with whatever is the 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! :slight_smile:

ok... I'll file a bugzilla (no energy for patches these days)

thnx!