simde
simde copied to clipboard
Compile error if native simd intrinstic headers are included after SIMDe
I have the following minimal case that fails to compile on Ubuntu 16.04 (g++ 5.4 / libstdc++ 3.4.21). After submitting the issue I reproduced it also on other configurations.
$ cat test.cpp
#define SIMDE_ENABLE_NATIVE_ALIASES
#include "x86/sse2.h"
#include "smmintrin.h"
int main(int argc, const char** argv) { return 0; }
compile with g++ test.cpp -msse2 -O3
:
$ g++ test.cpp -msse2 -O3
In file included from x86/sse2.h:35:0,
from test.cpp:2:
/usr/lib/gcc/x86_64-linux-gnu/5/include/smmintrin.h: In function ‘__m128 simde_mm_round_ps(__m128, int)’:
x86/sse.h:491:37: error: redefinition of ‘__m128 simde_mm_round_ps(__m128, int)’
#define _mm_round_ps(a, rounding) simde_mm_round_ps(a, rounding)
^
x86/sse.h:386:1: note: ‘simde__m128 simde_mm_round_ps(simde__m128, int)’ previously defined here
simde_mm_round_ps (simde__m128 a, int rounding)
It seems like libstdc++
includes x86intrin.h
somewhere (random.h
?) and SIMDe does not like if that gets included after itself.
I looked into this a bit, and I really don't think there is anything we can do, sorry ☹.
I'm going to leave this open pending an addition to the Caveats section of the README, but I think the "fix" is really going to be to include SIMDe last, or to use the prefixed versions instead of native aliases.
Another user reported this to us, to me it looks like sse detection failing on older GCC compilers perhaps? I dont have the issue when building with GCC 10. (though im not sure if my libc++ is still including these intrinsics)
Sorry poked a bit more it looks like the x86intrins inclusion was changed in gcc 6.1.0, after that I think this conflict doesnt happen anymore.