OGRECave/ogre-next

Compilation errors with x86intrin.h

Opened this issue · 0 comments

System Information

  • Ogre Version: v2.2 / v2.3
  • Operating System / Platform: Manjaro Linux
  • Compiler: g++ (GCC) 14.2.1 20240805

Detailled description

Including x86intrin.h after Math/Array/OgreArrayConfig.h causes compilation errors.

The problem is that fma4intrin.h (included by x86intrin.h) defines _mm_nmsub_ps which gets mangled by:

#define _mm_nmsub_ps( a, b, c ) _mm_sub_ps( c, _mm_mul_ps( a, b ) )

This commit 359b9a3 seems to reference a similar issue.

Replacing _mm_nmsub_ps with a different identifier fixes the errors. Making sure x86intrin.h is included first also fixes the errors.

Build log

/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/include/fma4intrin.h: At global scope:
/home/nimble/projects/ogre-next/OgreMain/include/Math/Array/OgreArrayConfig.h:86:60: error: ‘_mm_mul_ps’ is not a type
   86 |         #define _mm_nmsub_ps( a, b, c )     _mm_sub_ps( c, _mm_mul_ps( a, b ) )
      |                                                            ^~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/include/x86intrin.h:36,
                 from /home/nimble/projects/ogre-next/Samples/2.0/Tutorials/Tutorial00_Basic/Tutorial00_Basic.cpp:26:
/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/include/fma4intrin.h: In function ‘__m128 _mm_sub_ps(__m128, int (*)(__m128, __m128))’:
/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/include/fma4intrin.h:117:53: error: ‘__A’ was not declared in this scope; did you mean ‘__C’?
  117 |   return (__m128) __builtin_ia32_vfmaddps (-(__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
      |                                                     ^~~
      |                                                     __C
/usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/include/fma4intrin.h:117:66: error: ‘__B’ was not declared in this scope; did you mean ‘__C’?
  117 |   return (__m128) __builtin_ia32_vfmaddps (-(__v4sf)__A, (__v4sf)__B, -(__v4sf)__C);
      |                                                                  ^~~
      |                                                                  __C