"-march=native" possibly being misled on Debian i386?

Toby Douglass toby.douglass@minodes.com
Sun Jun 11 07:32:00 GMT 2017

Hi all.

I have a potentially slightly fiendish problem, relating to GCCs
"-march=native" functionality, and I would appreciate any words of
wisdom which might be forthcoming.

I have recently acquired an i686 (actual genuine 32-bit Intel
processor) dev board, which I am using to support a library I write.

The board has no particular OS support provided, e.g. like Raspbian;
rather, you just install a normal Linux distro to it.

I've installed Debian, as I have Debian on all of the other dev boards I own.

A year or two ago, Debian depricated i386.  I may be completely wrong
in what I am about to say, but from what I've read, Googling, it seems
that i386 is now an alias for i686.  (I486 support had already
accidentally been dropped, and so they ditched i586 as well, and went
to i686 as the minimum).

The OS image I stalled from was "firmware-8.8.0-i386-netinst", an
unofficial build of the normal i386 net-install image, which contains
non-free firmware (as needed by the dev board I have).

Looking at my installed OS, I see this uname;

"Linux minnow 3.16.0-4-686-pae #1 SMP Debian 3.16.43-2 (2017-04-30)
i686 GNU/Linux"

So it is indeed the case that the installer picked the correct kernel.

However, when I look in /usr/lib, I find this...


And now we come to the crux of the matter;

If I run; "gcc -dM -E - < /dev/null | grep 86"

I get this (re-ordered for clarity);

#define __i586 1
#define __i586__ 1
#define __i386 1
#define __i386__ 1
#define i386 1

The compiler thinks it's on a 586, rather than a 686, but that's okay.

But when I use "-march=native", like so; "gcc -march=native -dM -E - <
/dev/null | grep 86"

I only get this!

#define __i386 1
#define __i386__ 1
#define i386 1

This is a problem for me.  I use these compiler defined macros to
control a porting abstraction layer, which in turn uses atomic
intrinsics.  The i386 has no atomic operations, the i486 has
everything except double-word CAS, and i586 and higher has the lot.

When I use "-march=native", building fails because the porting
abstraction layer throws a #error (due to it being on an unsupportable

Now, I may be completely wrong, but it looks to me where the OS is
pretending to be i386, it's actually misleading the mechanism behind
"-march=native".  There *is* no actual i686 Debian build, so I can't
just use that instead of the i386 Debian.

I want to use "-march=native" because it means the makefile selects
the correct target for whomever is building.

Any advice, insight, corrections, words of wisdom, etc?

More information about the Gcc-help mailing list