Karl
Karl

Reputation: 5733

How to fix error: bad value (native) for -march= switch and -mtune= switch?

I am compiling the library provided here: http://www.robots.ox.ac.uk/~vgg/software/fastann/, but

bash-3.2$ PREFIX=/usr/local/ cmake . && make                                    
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
 -Wall -O2 -g3 -msse2 -march=native -fno-exceptions -fno-rtti
--- Prefix = /usr/local/
-- Configuring done
-- Generating done
-- Build files have been written to: /path/to/dir
[ 14%] Building CXX object CMakeFiles/fastann.dir/dist_l2.cpp.o
/path/to/dir/dist_l2.cpp:1: error: bad value (native) for -march= switch
/path/to/dir/dist_l2.cpp:1: error: bad value (native) for -mtune= switch
make[2]: *** [CMakeFiles/fastann.dir/dist_l2.cpp.o] Error 1
make[1]: *** [CMakeFiles/fastann.dir/all] Error 2
make: *** [all] Error 2
bash-3.2$

This is only the first step in the provided instruction, and I don't know where to look next. Can somebody tell me what exactly is this error, and how to fix it?

Upvotes: 3

Views: 6530

Answers (2)

jww
jww

Reputation: 102346

How to fix error: bad value (native) for -march= switch and -mtune= switch?

The problem is with -march=nartive. According to Ian Lance Taylor on GCC's mailing list (Ian is one of the GCC devs):

The problem is that the driver code is not working, and the bug is that gcc doesn't handle that [-march=native] correctly. There is some code in gcc to handle the driver code failing, and it works for -mtune=native, but not for -march=native.

The driver code is supposed to change the -march=native to be -march=XXX for your CPU. The code is in gcc/config/i386/driver-i386.c.

So the workaround is to avoid using -march=native; and use either (1) -m32 or -m64, or (2) use -march=cpu-type, where cpu-type is one of the ones listed at 3.17.15 Intel 386 and AMD x86-64 Options of the GCC manual. The list is extensive, and it includes pentium, pentium2, pentium3 and pentium4.

Upvotes: 2

alk
alk

Reputation: 70971

Switch to using a version of gcc equal or larger then 4.2.

gcc's version 4.2 introduced the native march.


Use

gcc --version

to get gcc's version information.

Upvotes: 1

Related Questions