CPU Optimization Flags (-march) using Make

Hello all,

In trying to go through the shader tutorial I downloaded the latest ofx: 0.8.3 (Linux64) on Ubuntu.

The problem is that the default make configuration does not allow me to build ofx examples. They bail on an unknown assembler instruction:

/tmp/ccw0vdVg.s: Assembler messages:
/tmp/ccw0vdVg.s:1242: Error: no such instruction: `vfmadd312ss fftInterpValues_(,%rax,4),%xmm1,%xmm0’

Looking at the compiler output I see the only -march flag passed is:

-march=native

It seems for my i5-4670 processors, I should be passing:

-march=corei7-avx

But it’s unclear to me where I should add this flag. I tried in config.make PROJECT_CFLAGS, and PROJECT_OPTIMIZATION_CFLAGS_RELEASE, but either those are overridden or ignored.

So I managed to get things to compile by manually editing

libs/openFrameworksCompiled/project/linux64/config.linux64.default.mk

and replacing

PLATFORM_CFLAGS += -march=native

with

PLATFORM_CFLAGS += -march=corei7-avx

but that does not seem like the proper place for the change.

1 Like

It’s odd that it doesn’t work with native to be sure.

The “correct” way to make a change like this (apart from adding some conditionals or architecture inspection code to the default linux64 makefile) may be to use the PLATFORM_VARIANT approach.

Basically you copy the config.linux64.default.mk to config.linux64.corei70.mk (or something like it). In the copy you make your changes (as you have done).

Then when you use make you can call:

make PLATFORM_VARIANT=corei7

and it will choose your variant rather than the default one.

To make it even simpler, you might export your makeflags to include the variant.

An example of a platform variant for the UDOO board (arm7) is here with instructions.

Anyway, all of that said … it seems like this processor should compile without creating a variant – if you can figure out a way in the make file to conditionally chose the correct march flag (rather than native) it seems like that would be a nice feature to add to the default. I’d try it, but I don’t currently have access to the same hardware …

1 Like

are you compiling this on a virtual machine? some times those will report a wrong platform and the march=native flags will generate illegal instructions. we could add something in the makefile so it’s easy to change those from the config.make file but by now the only way to change it is the way you did. this is really a bug in some machines but it’s kind of common so it would be good to be able to change it easily

No, I’m not building on a virtual machine.

I looks like this could be a GCC 4.6 bug. Except in this bug, the native switch passes -march=corei7, and to get things working for me I had to manually pass a corei7 flag. So I’m even more confused. Searching for this bug on the GCC tracker did not yield any obvious results. It does seem others have seen similar issues with -march=native .

Thank is what I get for getting a new machine! :wink: