Boost logo

Boost :

Subject: Re: [boost] Default x86 instruction set
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2013-05-07 11:24:06


On 05/05/13 00:02, Andrey Semashev wrote:
> Hi,
>
> I noticed that by default x86 32 bit builds are targeted for i386 (at least
> gcc toolset and its derivatives explicitly specify -march=i386 in the command
> line). Is there a reason to target for such an ancient instruction set by
> default?

I take it you mean why is
tools/build/v2/tools/gcc.jam
adding -march=i386 when using GCC on 32-bit systems.

I also think it shouldn't do that. I suppose the reason is due to a
limitation of Boost.Build that needs to know what the default is.
Most GCC 32-bit binaries will build for i386 by default, even on modern
linux distributions.

> Frankly, I'm not sure that the current Boost code would even run on a real
> 80386, since there are at least quite a few places with atomic operations,
> which I think were not present on that CPU.

Any code that relies on particular instructions should detect what the
target is to only use what is supported by the target, with fallback to
a portable implementation if possible.

It is also possible to not provide portable fallback, in which case the
library needs to be ported to each architecture manually.

> Also, I would like to use cpuid
> safely in my library, and this operation appeared only in some i486 and all
> Pentiums, so I would basically target my code for Pentium at the very least.

There is no problem with making a library that is specific to a given
architecture, as long as it is clearly documented and that the limited
scope is accepted during review.

> But perhaps we could raise the default to Pentium Pro (i686)?

The best solution is to not add any flag, and use whatever the default is.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk