public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56038] New: declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode
@ 2013-01-18 22:05 erik-gcc-bugzilla at vanpienbroek dot nl
  2013-02-15 10:41 ` [Bug c++/56038] " kretz at kde dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: erik-gcc-bugzilla at vanpienbroek dot nl @ 2013-01-18 22:05 UTC (permalink / raw)
  To: gcc-bugs


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: unassigned@gcc.gnu.org
        ReportedBy: erik-gcc-bugzilla@vanpienbroek.nl
                CC: ktietz70@googlemail.com
            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.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56038] declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode
  2013-01-18 22:05 [Bug c++/56038] New: declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode erik-gcc-bugzilla at vanpienbroek dot nl
@ 2013-02-15 10:41 ` kretz at kde dot org
  2013-03-25  4:12 ` net147 at gmail dot com
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kretz at kde dot org @ 2013-02-15 10:41 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56038

Matthias Kretz <kretz at kde dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kretz at kde dot org

--- Comment #1 from Matthias Kretz <kretz at kde dot org> 2013-02-15 10:40:46 UTC ---
I also just came across this issue with GCC 4.7.2 on Windows. It appears that
all the intrin.h headers are missing the extern "C" part. Since the functions
are always inline and thus the symbols never show up anywhere this has not been
a problem before. But now that another header declares those functions a second
time something must be done.

Maybe what also needs to happen is that in the mingw environment the intrin.h
header does not declare the SSE/AVX intrinsics, but instead includes the proper
xxxintrin.h headers.

In any case, I believe the intrinsics should always be declared with C linkage.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56038] declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode
  2013-01-18 22:05 [Bug c++/56038] New: declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode erik-gcc-bugzilla at vanpienbroek dot nl
  2013-02-15 10:41 ` [Bug c++/56038] " kretz at kde dot org
@ 2013-03-25  4:12 ` net147 at gmail dot com
  2013-03-25 10:38 ` net147 at gmail dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: net147 at gmail dot com @ 2013-03-25  4:12 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56038

--- Comment #2 from Jonathan Liu <net147 at gmail dot com> 2013-03-25 04:12:41 UTC ---
I can reproduce this with MinGW-w64 GCC 4.8.0 x86 DW2/SJLJ. It does not occur
with MinGW-w64 GCC 4.8.0 x86_64 SEH/SJLJ.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56038] declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode
  2013-01-18 22:05 [Bug c++/56038] New: declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode erik-gcc-bugzilla at vanpienbroek dot nl
  2013-02-15 10:41 ` [Bug c++/56038] " kretz at kde dot org
  2013-03-25  4:12 ` net147 at gmail dot com
@ 2013-03-25 10:38 ` net147 at gmail dot com
  2013-03-26 12:26 ` kai.koehne at digia dot com
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: net147 at gmail dot com @ 2013-03-25 10:38 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56038

--- Comment #4 from Jonathan Liu <net147 at gmail dot com> 2013-03-25 10:38:33 UTC ---
Created attachment 29719
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29719
Add extern "C" modifier in intrinsics headers for C++


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56038] declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode
  2013-01-18 22:05 [Bug c++/56038] New: declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode erik-gcc-bugzilla at vanpienbroek dot nl
                   ` (2 preceding siblings ...)
  2013-03-25 10:38 ` net147 at gmail dot com
@ 2013-03-26 12:26 ` kai.koehne at digia dot com
  2013-06-10  8:37 ` kai.koehne at digia dot com
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kai.koehne at digia dot com @ 2013-03-26 12:26 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56038

--- Comment #5 from Kai Koehne <kai.koehne at digia dot com> 2013-03-26 12:26:04 UTC ---
Can confirm that the patch fixes the issue when applied locally.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56038] declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode
  2013-01-18 22:05 [Bug c++/56038] New: declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode erik-gcc-bugzilla at vanpienbroek dot nl
                   ` (3 preceding siblings ...)
  2013-03-26 12:26 ` kai.koehne at digia dot com
@ 2013-06-10  8:37 ` kai.koehne at digia dot com
  2013-09-20  7:29 ` vanboxem.ruben at gmail dot com
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kai.koehne at digia dot com @ 2013-06-10  8:37 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56038

--- Comment #6 from Kai Koehne <kai.koehne at digia dot com> ---
The issue is still there with 4.8.1 . It understand that the discussion on Kai
Tietz' original patch has stalled ... Any suggestion on how we can move this
forward?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56038] declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode
  2013-01-18 22:05 [Bug c++/56038] New: declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode erik-gcc-bugzilla at vanpienbroek dot nl
                   ` (4 preceding siblings ...)
  2013-06-10  8:37 ` kai.koehne at digia dot com
@ 2013-09-20  7:29 ` vanboxem.ruben at gmail dot com
  2013-09-20 14:36 ` jacek at codeweavers dot com
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: vanboxem.ruben at gmail dot com @ 2013-09-20  7:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56038

Ruben Van Boxem <vanboxem.ruben at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vanboxem.ruben at gmail dot com

--- Comment #7 from Ruben Van Boxem <vanboxem.ruben at gmail dot com> ---
Can this patch please be either applied or rejected for a valid reason?

As far as I understand, something might be "broken" in the compiler wrt
inlining:
http://gcc.gnu.org/ml/gcc-patches/2010-03/msg00059.html
which affects this issue indirectly. Nearly three years have passed since the
original discussion.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56038] declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode
  2013-01-18 22:05 [Bug c++/56038] New: declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode erik-gcc-bugzilla at vanpienbroek dot nl
                   ` (5 preceding siblings ...)
  2013-09-20  7:29 ` vanboxem.ruben at gmail dot com
@ 2013-09-20 14:36 ` jacek at codeweavers dot com
  2013-09-20 15:35 ` hjl.tools at gmail dot com
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jacek at codeweavers dot com @ 2013-09-20 14:36 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56038

Jacek Caban <jacek at codeweavers dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jacek at codeweavers dot com

--- Comment #8 from Jacek Caban <jacek at codeweavers dot com> ---
It would be great if this could be fixed in GCC so that we wouldn't need to
work around linkage differences in headers, but this should not be a problem
for mingw-w64 since rev 6303, which added a work around to intrin.h.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56038] declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode
  2013-01-18 22:05 [Bug c++/56038] New: declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode erik-gcc-bugzilla at vanpienbroek dot nl
                   ` (6 preceding siblings ...)
  2013-09-20 14:36 ` jacek at codeweavers dot com
@ 2013-09-20 15:35 ` hjl.tools at gmail dot com
  2013-09-20 16:08 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: hjl.tools at gmail dot com @ 2013-09-20 15:35 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56038

--- Comment #9 from H.J. Lu <hjl.tools at gmail dot com> ---
Does mingw provide its own SSE/MMX intrinsic implementations?
Can mingw just include <xmmintrin.h> where SSE/MMX instrincis
is needed?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56038] declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode
  2013-01-18 22:05 [Bug c++/56038] New: declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode erik-gcc-bugzilla at vanpienbroek dot nl
                   ` (7 preceding siblings ...)
  2013-09-20 15:35 ` hjl.tools at gmail dot com
@ 2013-09-20 16:08 ` jason at gcc dot gnu.org
  2014-03-22 15:34 ` tim.lebedkov at gmail dot com
  2014-03-23 19:17 ` erik-gcc-bugzilla at vanpienbroek dot nl
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2013-09-20 16:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56038

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #9)
> Does mingw provide its own SSE/MMX intrinsic implementations?
> Can mingw just include <xmmintrin.h> where SSE/MMX instrincis
> is needed?

Right.  Why does mingw need to declare these functions itself?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56038] declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode
  2013-01-18 22:05 [Bug c++/56038] New: declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode erik-gcc-bugzilla at vanpienbroek dot nl
                   ` (8 preceding siblings ...)
  2013-09-20 16:08 ` jason at gcc dot gnu.org
@ 2014-03-22 15:34 ` tim.lebedkov at gmail dot com
  2014-03-23 19:17 ` erik-gcc-bugzilla at vanpienbroek dot nl
  10 siblings, 0 replies; 12+ messages in thread
From: tim.lebedkov at gmail dot com @ 2014-03-22 15:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56038

tim.lebedkov at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tim.lebedkov at gmail dot com

--- Comment #11 from tim.lebedkov at gmail dot com ---
Qt 5.2.1 cannot be build in 32 bit with mingw-w64 4.8.2 because of this bug.
Why is it not fixed?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/56038] declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode
  2013-01-18 22:05 [Bug c++/56038] New: declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode erik-gcc-bugzilla at vanpienbroek dot nl
                   ` (9 preceding siblings ...)
  2014-03-22 15:34 ` tim.lebedkov at gmail dot com
@ 2014-03-23 19:17 ` erik-gcc-bugzilla at vanpienbroek dot nl
  10 siblings, 0 replies; 12+ messages in thread
From: erik-gcc-bugzilla at vanpienbroek dot nl @ 2014-03-23 19:17 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56038

--- Comment #12 from Erik van Pienbroek <erik-gcc-bugzilla at vanpienbroek dot nl> ---
(In reply to tim.lebedkov from comment #11)
> Qt 5.2.1 cannot be build in 32 bit with mingw-w64 4.8.2 because of this bug.
> Why is it not fixed?

A fix for this issue was applied in the intrin.h of mingw-w64 v3.1.0 (which was
released in January 2014). Here's the commit in question:
http://sourceforge.net/p/mingw-w64/code/6303/ You might want to consider
updating your toolchain.

I can't judge whether the fix applied in mingw-w64 is correct or whether
something needs to be changed in gcc itself as well. Therefore I'm leaving this
bug open for now. If the gcc devs think otherwise feel free to close this bug.
Qt5 itself can now be built properly against gcc 4.8.2 and mingw-w64 v3.1.0
without any issues.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-03-23 19:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-18 22:05 [Bug c++/56038] New: declarations in xmmintrin.h conflict with mingw-w64 intrin.h in c++ mode erik-gcc-bugzilla at vanpienbroek dot nl
2013-02-15 10:41 ` [Bug c++/56038] " kretz at kde dot org
2013-03-25  4:12 ` net147 at gmail dot com
2013-03-25 10:38 ` net147 at gmail dot com
2013-03-26 12:26 ` kai.koehne at digia dot com
2013-06-10  8:37 ` kai.koehne at digia dot com
2013-09-20  7:29 ` vanboxem.ruben at gmail dot com
2013-09-20 14:36 ` jacek at codeweavers dot com
2013-09-20 15:35 ` hjl.tools at gmail dot com
2013-09-20 16:08 ` jason at gcc dot gnu.org
2014-03-22 15:34 ` tim.lebedkov at gmail dot com
2014-03-23 19:17 ` erik-gcc-bugzilla at vanpienbroek dot nl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).