simde icon indicating copy to clipboard operation
simde copied to clipboard

Compile error if native simd intrinstic headers are included after SIMDe

Open milot-mirdita opened this issue 4 years ago • 4 comments

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.

milot-mirdita avatar Jul 03 '20 16:07 milot-mirdita

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.

nemequ avatar Jul 03 '20 19:07 nemequ

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)

kkartaltepe avatar Jan 04 '21 18:01 kkartaltepe

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.

kkartaltepe avatar Jan 04 '21 18:01 kkartaltepe

for those who have late gcc (debian), this might help ppa config gcc.

sukrosono avatar Jan 23 '21 11:01 sukrosono