http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56038
Bug #: 56038
Summary: declarations in xmmintrin.h conflict with mingw-w64
intrin.h in c++ mode
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Target: i686-w64-mingw32
Build: gcc 4.8 20130106 snapshot, r194954
While testing gcc 4.8 (for the target i686-w64-mingw32) I stumbled across a
compile failure while trying to build Qt5. Here's a minimal testcase to
reproduce this compile failure:
#include <algorithm>
#include <intrin.h>
int main()
{
return 0;
}
When trying to build this with gcc 4.8 and a recent mingw-w64 trunk snapshot
the following error occurs:
$ i686-w64-mingw32-g++ -O2 -msse2 -std=c++11 test.cpp
In file included from
/usr/lib64/gcc/i686-w64-mingw32/4.8.0/include/x86intrin.h:34:0,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/bits/opt_random.h:33,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/random:51,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/bits/stl_algo.h:67,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/algorithm:63,
from test.cpp:1:
/usr/lib64/gcc/i686-w64-mingw32/4.8.0/include/xmmintrin.h:997:1: error:
previous declaration of 'int _m_pextrw(__m64, int)' with 'C++' linkage
_m_pextrw (__m64 const __A, int const __N)
^
In file included from test.cpp:2:0:
/usr/i686-w64-mingw32/sys-root/mingw/include/intrin.h:561:5: error: conflicts
with new declaration with 'C' linkage
__MACHINEX86X_NOX64(int _m_pextrw(__m64,int))
^
In file included from
/usr/lib64/gcc/i686-w64-mingw32/4.8.0/include/x86intrin.h:34:0,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/bits/opt_random.h:33,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/random:51,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/bits/stl_algo.h:67,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/algorithm:63,
from test.cpp:1:
/usr/lib64/gcc/i686-w64-mingw32/4.8.0/include/xmmintrin.h:1018:1: error:
previous declaration of '__m64 _m_pinsrw(__m64, int, int)' with 'C++' linkage
_m_pinsrw (__m64 const __A, int const __D, int const __N)
^
In file included from test.cpp:2:0:
/usr/i686-w64-mingw32/sys-root/mingw/include/intrin.h:566:5: error: conflicts
with new declaration with 'C' linkage
__MACHINEX86X_NOX64(__m64 _m_pinsrw(__m64,int,int))
^
In file included from
/usr/lib64/gcc/i686-w64-mingw32/4.8.0/include/x86intrin.h:34:0,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/bits/opt_random.h:33,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/random:51,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/bits/stl_algo.h:67,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/algorithm:63,
from test.cpp:1:
/usr/lib64/gcc/i686-w64-mingw32/4.8.0/include/xmmintrin.h:1119:1: error:
previous declaration of '__m64 _m_pshufw(__m64, int)' with 'C++' linkage
_m_pshufw (__m64 __A, int const __N)
^
In file included from test.cpp:2:0:
/usr/i686-w64-mingw32/sys-root/mingw/include/intrin.h:578:5: error: conflicts
with new declaration with 'C' linkage
__MACHINEX86X_NOX64(__m64 _m_pshufw(__m64,int))
^
In file included from
/usr/lib64/gcc/i686-w64-mingw32/4.8.0/include/x86intrin.h:34:0,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/bits/opt_random.h:33,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/random:51,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/bits/stl_algo.h:67,
from
/usr/i686-w64-mingw32/sys-root/mingw/include/c++/algorithm:63,
from test.cpp:1:
/usr/lib64/gcc/i686-w64-mingw32/4.8.0/include/xmmintrin.h:716:1: error:
previous declaration of '__m128 _mm_shuffle_ps(__m128, __m128, int)' with 'C++'
linkage
_mm_shuffle_ps (__m128 __A, __m128 __B, int const __mask)
^
In file included from test.cpp:2:0:
/usr/i686-w64-mingw32/sys-root/mingw/include/intrin.h:656:5: error: conflicts
with new declaration with 'C' linkage
__MACHINEX86X_NOIA64(__m128 _mm_shuffle_ps(__m128,__m128,int const))
^
The above testcase built fine with gcc 4.7 and the exact same version of
mingw-w64, so I consider this a regression in gcc 4.8
With the (pretty straightforward) change below I managed to resolve the issue:
--- gcc/config/i386/xmmintrin.h.orig 2013-01-18 14:57:27.762645582 +0100
+++ gcc/config/i386/xmmintrin.h 2013-01-18 14:58:27.604561940 +0100
@@ -37,6 +37,10 @@
/* Get _mm_malloc () and _mm_free (). */
#include <mm_malloc.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* The Intel API is flexible enough that we must allow aliasing with other
vector types, and their scalar components. */
typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
@@ -1241,6 +1245,10 @@
(row3) = __builtin_ia32_movhlps (__t3, __t2); \
} while (0)
+#ifdef __cplusplus
+}
+#endif
+
/* For backward source compatibility. */
#ifdef __SSE2__
# include <emmintrin.h>
I don't know if this change is the correct fix, but it resolves the qt5 build
failure for me.