NetBSD Problem Report #46978

From apb@apb.cequrux.com  Tue Sep 18 06:52:15 2012
Return-Path: <apb@apb.cequrux.com>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 93A7463B907
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 18 Sep 2012 06:52:15 +0000 (UTC)
Message-Id: <20120918065151.89D2D3B611A@apb-laptoy.apb.alt.za>
Date: Tue, 18 Sep 2012 06:51:51 +0000 (UTC)
From: apb@cequrux.com
To: gnats-bugs@gnats.NetBSD.org
Subject: internal compiler error building qt4-libs
X-Send-Pr-Version: 3.95

>Number:         46978
>Category:       bin
>Synopsis:       internal compiler error building qt4-libs
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 18 06:55:00 +0000 2012
>Last-Modified:  Wed Oct 17 21:35:01 +0000 2012
>Originator:     Alan Barrett
>Release:        NetBSD 6.99.11
>Organization:
Not much
>Environment:
NetBSD 6.99.11 i386
Architecture: i386
Machine: i386
>Description:
	Building pkgsrc/x11/qt4-libs fails with the following messages from the
	c++ compiler:

painting/qdrawhelper_mmx.cpp: In function 'void qt_blend_color_argb_mmx(int, const QSpan*, void*)':
painting/qdrawhelper_mmx.cpp:115:1: internal compiler error: in insert_save, at caller-save.c:1306
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.

        Since the compiler comes from the NetBSD base system, I am
        filing this as "Category: bin".

>How-To-Repeat:
	1. NetBSD 6.99.11 i386, built from sources checked out with
	   cvs update -D"2012-09-15 12:00 UTC".

	2. pkgsrc source tree checked out from CVS with the same
	   cvs update -D"2012-09-15 12:00 UTC".

	3. cd pkgsrc/x11/qt4-libs ; make

	I used a pkg_comp chroot, but I have seen the same problem
	without it.

	4. After a long time, it fails.  The last command, and the
	error messages, are:

libtool --silent --mode=compile c++ -c -Winline -mmmx -O2 -I/usr/pkg/include \
  -I/usr/include/krb5 -I/usr/include -I/usr/X11R7/include \
  -I/usr/X11R7/include/freetype2 -I/usr/pkg/include -I/usr/include/krb5 \
  -I/usr/include -I/usr/X11R7/include -I/usr/X11R7/include/freetype2 \
  -D_REENTRANT -I/usr/X11R7/include -I/usr/X11R7/include/freetype2 -fPIC \
  -DQT_SHARED -DQT_BUILD_GUI_LIB -DQT_NO_USING_NAMESPACE \
  -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT3_SUPPORT \
  -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_NO_OPENTYPE -DQT_NO_STYLE_MAC \
  -DQT_NO_STYLE_WINDOWSVISTA -DQT_NO_STYLE_WINDOWSXP -DQT_NO_STYLE_WINDOWSCE \
  -DQT_NO_STYLE_WINDOWSMOBILE -DQT_NO_STYLE_S60 -DQ_INTERNAL_QAPP_SRC \
  -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE \
  -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_HAVE_SSE3 -DQT_HAVE_SSSE3 \
  -DQT_HAVE_SSE4_1 -DQT_HAVE_SSE4_2 -DQT_HAVE_AVX -D_LARGEFILE64_SOURCE \
  -D_LARGEFILE_SOURCE -I../../mkspecs/netbsd-g++ -I. -I../../include/QtCore \
  -I../../include -I../../include/QtGui -I.rcc/release-shared \
  -I../3rdparty/xorg -Iimage -I/usr/X11R7/include/freetype2 \
  -I../3rdparty/harfbuzz/src -Idialogs -I.moc/release-shared \
  -I/usr/X11R7/include -I.uic/release-shared -I/usr/pkg/include \
  painting/qdrawhelper_mmx.cpp -o .obj/release-shared/qdrawhelper_mmx.lo
painting/qdrawhelper_mmx.cpp: In function 'void qt_blend_color_argb_mmx(int, const QSpan*, void*)':
painting/qdrawhelper_mmx.cpp:115:1: internal compiler error: in insert_save, at caller-save.c:1306
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
gmake[1]: *** [.obj/release-shared/qdrawhelper_mmx.lo] Error 1
gmake[1]: Leaving directory `/pkg_comp/obj/pkgsrc/x11/qt4-libs/work.apb/qt-everywhere-opensource-src-4.8.3/src/gui'
gmake: *** [sub-gui-sub_src_target_ordered] Error 2
*** Error code 2

Stop.
make: stopped in /usr/pkgsrc/x11/qt4-libs
*** Error code 1


>Fix:
	Not known.

>Audit-Trail:
From: Alan Barrett <apb@cequrux.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/46978: internal compiler error building qt4-libs
Date: Wed, 19 Sep 2012 22:05:51 +0200

 On Tue, 18 Sep 2012, apb@cequrux.com wrote:
 >painting/qdrawhelper_mmx.cpp: In function 'void qt_blend_color_argb_mmx(int, const QSpan*, void*)':
 >painting/qdrawhelper_mmx.cpp:115:1: internal compiler error: in insert_save, at caller-save.c:1306

 The compiler bug is still present in g++ (NetBSD nb1 20120916) 4.5.4
 on NetBSD/i386, although the line number has changed from 1306 to 1300:
 "internal compiler error: in insert_save, at caller-save.c:1300"

 The following patch to x11/qt4-libs/hacks.mk allowed me to successfully build
 the package, by using -O1 instead of -O2 in CXXFLAGS.  It's conditional
 on the OS, MACHINE_ARCH, and compiler version.


 Index: x11/qt4-libs/hacks.mk
 ===================================================================
 --- x11/qt4-libs/hacks.mk	3 Aug 2011 16:38:31 -0000	1.1
 +++ x11/qt4-libs/hacks.mk	19 Sep 2012 11:22:11 -0000
 @@ -10,3 +10,20 @@ PKG_HACKS+=		macosx-codegen
   BUILDLINK_TRANSFORM+=	rename:-O[0-9]*:-O1
   .  endif
   .endif
 +
 +
 +### [Wed Sep 19 09:24:11 UTC 2012 : apb]
 +### g++-4.5.3 and 4.5.4 on NetBSD/i386 fails with an internal compiler error
 +### when building gui/painting/qdrawhelper_mmx.cpp.
 +### Building with -O1 instead of -O2 seems to work around the problem.
 +.if ${OPSYS} == "NetBSD" && ${MACHINE_ARCH} == "i386"
 +.  include "../../mk/compiler.mk"
 +.  if !empty(CC_VERSION:Mgcc-4.5.*)
 +PKG_HACKS+=		pr46978
 +SUBST_CLASSES+=		pr46978
 +SUBST_STAGE.pr46978=	post-configure
 +SUBST_MESSAGE.pr46978=	Working around optimizer bug (NetBSD PR 46978)
 +SUBST_FILES.pr46978=	src/gui/Makefile
 +SUBST_SED.pr46978=	-e '/^CXXFLAGS/s/-O2/-O1/'
 +.  endif
 +.endif

From: Nick Hudson <skrll@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, apb@cequrux.com,
  joerg@netbsd.org
Subject: Re: bin/46978: internal compiler error building qt4-libs
Date: Thu, 20 Sep 2012 09:00:08 +0100

 On Wednesday 19 September 2012 21:10:06 Alan Barrett wrote:
 > The following reply was made to PR bin/46978; it has been noted by GNATS.
 > 
 > From: Alan Barrett <apb@cequrux.com>
 > To: gnats-bugs@netbsd.org
 > Cc:
 > Subject: Re: bin/46978: internal compiler error building qt4-libs
 > Date: Wed, 19 Sep 2012 22:05:51 +0200
 > 
 >  On Tue, 18 Sep 2012, apb@cequrux.com wrote:
 >  >painting/qdrawhelper_mmx.cpp: In function 'void
 >  >qt_blend_color_argb_mmx(int, const QSpan*, void*)':
 >  >painting/qdrawhelper_mmx.cpp:115:1: internal compiler error: in
 >  >insert_save, at caller-save.c:1306
 > 
 >  The compiler bug is still present in g++ (NetBSD nb1 20120916) 4.5.4
 >  on NetBSD/i386, although the line number has changed from 1306 to 1300:
 >  "internal compiler error: in insert_save, at caller-save.c:1300"

 1297:   /* Verify that the alignment of spill space is equal to or greater
 1298:      than required.  */
 1299:   gcc_assert (MIN (MAX_SUPPORTED_STACK_ALIGNMENT,
 1300:                   GET_MODE_ALIGNMENT (GET_MODE (mem))) <= MEM_ALIGN (mem));

 I wonder if it's related to joerg's commit

 http://mail-index.netbsd.org/source-changes/2012/09/14/msg037276.html

 Nick

From: "Alan Barrett" <apb@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46978 CVS commit: pkgsrc/x11/qt4-libs
Date: Thu, 20 Sep 2012 08:38:40 +0000

 Module Name:	pkgsrc
 Committed By:	apb
 Date:		Thu Sep 20 08:38:40 UTC 2012

 Modified Files:
 	pkgsrc/x11/qt4-libs: hacks.mk

 Log Message:
 Workaround for PR 46978:
 g++-4.5.3 and 4.5.4 on NetBSD/i386 fails with an internal compiler error
 when building gui/painting/qdrawhelper_mmx.cpp.


 To generate a diff of this commit:
 cvs rdiff -u -r1.1 -r1.2 pkgsrc/x11/qt4-libs/hacks.mk

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: David Laight <david@l8s.co.uk>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/46978: internal compiler error building qt4-libs
Date: Thu, 20 Sep 2012 23:07:06 +0100

 On Thu, Sep 20, 2012 at 08:05:03AM +0000, Nick Hudson wrote:
 > The following reply was made to PR bin/46978; it has been noted by GNATS.
 >  > 
 >  >  The compiler bug is still present in g++ (NetBSD nb1 20120916) 4.5.4
 >  >  on NetBSD/i386, although the line number has changed from 1306 to 1300:
 >  >  "internal compiler error: in insert_save, at caller-save.c:1300"
 >  
 >  1297:   /* Verify that the alignment of spill space is equal to or greater
 >  1298:      than required.  */
 >  1299:   gcc_assert (MIN (MAX_SUPPORTED_STACK_ALIGNMENT,
 >  1300:                   GET_MODE_ALIGNMENT (GET_MODE (mem))) <= MEM_ALIGN (mem));
 >  
 >  I wonder if it's related to joerg's commit
 >  
 >  http://mail-index.netbsd.org/source-changes/2012/09/14/msg037276.html

 I've just tried to guess what the LHS and RHS of that comparison might be.
 But it is lurking well inside many #defines and functions.
 Might be worth trying to print MAX_SUPPORTED_STACK_ALIGNMENT,
 GET_MODE_ALIGNMENT (GET_MODE (mem)) and MEM_ALIGN(mem) when the assert
 would fail.
 I think there is also an 'rtx' print routing lurking that could be used
 for 'mem'.

 	David

 -- 
 David Laight: david@l8s.co.uk

From: Joerg Sonnenberger <joerg@britannica.bec.de>
To: Nick Hudson <skrll@netbsd.org>
Cc: gnats-bugs@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
	apb@cequrux.com, joerg@netbsd.org
Subject: Re: bin/46978: internal compiler error building qt4-libs
Date: Mon, 24 Sep 2012 21:55:15 +0200

 New test case is:

 typedef int __attribute__((vector_size(8))) m64;
 m64 _mm_setzero_si64 ();
 m64 _negate (m64, m64);
 void
 qt_blend_color_argb_x86 ()
 {
     m64 mmx_0x00ff = _mm_setzero_si64 ();
     m64 mmx_0x0000 = _mm_setzero_si64 ();
     m64 ca;
     m64 ica = _negate (ca, mmx_0x00ff);
 }

 Compiling this with -mmx -O2 results in the given crash.
 Unpatched gcc shows the same behavior with -mpreferred-stack-boundary=2.

 Best bet so far is that the memory alignment is computed too early,
 before the stack alignment is finalized.

 Joerg

From: "Alan Barrett" <apb@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46978 CVS commit: pkgsrc/x11/qt4-tools
Date: Tue, 25 Sep 2012 08:07:32 +0000

 Module Name:	pkgsrc
 Committed By:	apb
 Date:		Tue Sep 25 08:07:32 UTC 2012

 Added Files:
 	pkgsrc/x11/qt4-tools: hacks.mk

 Log Message:
 qt4-tools needs the same workaround as qt4-libs for the compiler bug
 in PR 46978.  When building on NetBSD/i386 with gcc-4.5.*, use -O1
 instead of -O2 for C++ files in the src/gui subdirectory.


 To generate a diff of this commit:
 cvs rdiff -u -r0 -r1.1 pkgsrc/x11/qt4-tools/hacks.mk

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Joerg Sonnenberger <joerg@britannica.bec.de>
To: Nick Hudson <skrll@netbsd.org>
Cc: gnats-bugs@netbsd.org, gnats-admin@netbsd.org
Subject: Re: bin/46978: internal compiler error building qt4-libs
Date: Sun, 30 Sep 2012 23:08:45 +0200

 --7AUc2qLy4jB3hD7Z
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 More detailed analysis shows that this happens under the following
 conditions:

 (1) MMX is enabled
 (2) MMX registers are spilled to the stack
 (3) Stack alignment is 32bit
 (4) Preferred stack boundary is 32bit too

 What happens is that ix86_local_alignment gets called to create the
 stack slot for a MMX register with mode DImode. This is handled as if it
 was a "long long" and the 64bit alignment is overriden and downgraded to
 32bit.

 The attached patch makes sure that MMX registers use the vector mode,
 not DImode for spill slots to distinguish this from "long long".

 Joerg

 --7AUc2qLy4jB3hD7Z
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="i386.h.diff"

 Index: i386.h
 ===================================================================
 RCS file: /home/joerg/repo/netbsd/src/external/gpl3/gcc/dist/gcc/config/i386/i386.h,v
 retrieving revision 1.1.1.2
 diff -u -p -r1.1.1.2 i386.h
 --- i386.h	18 Sep 2012 06:15:11 -0000	1.1.1.2
 +++ i386.h	30 Sep 2012 20:20:51 -0000
 @@ -1085,6 +1085,7 @@ enum target_cpu_default

  #define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE)			\
    (CC_REGNO_P (REGNO) ? VOIDmode					\
 +   : MMX_REGNO_P (REGNO) ? V8QImode					\
     : (MODE) == VOIDmode && (NREGS) != 1 ? VOIDmode			\
     : (MODE) == VOIDmode ? choose_hard_reg_mode ((REGNO), (NREGS), false) \
     : (MODE) == HImode && !TARGET_PARTIAL_REG_STALL ? SImode		\

 --7AUc2qLy4jB3hD7Z--

From: David Laight <david@l8s.co.uk>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/46978: internal compiler error building qt4-libs
Date: Mon, 1 Oct 2012 07:52:51 +0100

 On Sun, Sep 30, 2012 at 09:10:08PM +0000, Joerg Sonnenberger wrote:
 > The following reply was made to PR bin/46978; it has been noted by GNATS.
 > 
 > From: Joerg Sonnenberger <joerg@britannica.bec.de>
 > To: Nick Hudson <skrll@netbsd.org>
 > Cc: gnats-bugs@netbsd.org, gnats-admin@netbsd.org
 > Subject: Re: bin/46978: internal compiler error building qt4-libs
 > Date: Sun, 30 Sep 2012 23:08:45 +0200
 > 
 >  --7AUc2qLy4jB3hD7Z
 >  Content-Type: text/plain; charset=us-ascii
 >  Content-Disposition: inline
 >  
 >  More detailed analysis shows that this happens under the following
 >  conditions:
 >  
 >  (1) MMX is enabled
 >  (2) MMX registers are spilled to the stack
 >  (3) Stack alignment is 32bit
 >  (4) Preferred stack boundary is 32bit too
 >  
 >  What happens is that ix86_local_alignment gets called to create the
 >  stack slot for a MMX register with mode DImode. This is handled as if it
 >  was a "long long" and the 64bit alignment is overriden and downgraded to
 >  32bit.
 >  
 >  The attached patch makes sure that MMX registers use the vector mode,
 >  not DImode for spill slots to distinguish this from "long long".

 What effect does that have on the generated coded?
 In particular does it unnecessarily add code to realign the stack?
 The instructions used for MMX registers do not need to 64bit alignment.

 IIRC these registers get use for FP and load/store will happen from structure
 members won't be aligned.

 There is a slight performance benefit from aligning 64 bit items, but
 this is sensible achieved by hoping to maintain teh stack alignment.

 	David

 -- 
 David Laight: david@l8s.co.uk

From: "Joerg Sonnenberger" <joerg@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46978 CVS commit: src/external/gpl3/gcc/dist/gcc/config/i386
Date: Sat, 6 Oct 2012 14:10:46 +0000

 Module Name:	src
 Committed By:	joerg
 Date:		Sat Oct  6 14:10:46 UTC 2012

 Modified Files:
 	src/external/gpl3/gcc/dist/gcc/config/i386: i386.h

 Log Message:
 PR 46978: ICE on spilling MMX registers

 GCC/i386 has code to lower the required alignment for long long to 32bit
 as the CPU doesn't need more. It is also using the same mode for setting
 up the MMX registers and in turn, the stack slots reserved for spilling
 require 32bit alignment. The actual vector types used keep the original
 64bit alignment, so when the compiler wants to spill a MMX register, it
 hits an assertion. Fix this by using the vector type as raw type for MMX
 registers.


 To generate a diff of this commit:
 cvs rdiff -u -r1.1.1.2 -r1.2 \
     src/external/gpl3/gcc/dist/gcc/config/i386/i386.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46978 CVS commit: [netbsd-6] src/external/gpl3/gcc/dist/gcc/config/i386
Date: Wed, 17 Oct 2012 21:30:33 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Wed Oct 17 21:30:33 UTC 2012

 Modified Files:
 	src/external/gpl3/gcc/dist/gcc/config/i386 [netbsd-6]: i386.c i386.h
 	    netbsd-elf.h netbsd64.h

 Log Message:
 Pull up following revision(s) (requested by joerg in ticket #560):
 	external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h: revision 1.3
 	external/gpl3/gcc/dist/gcc/config/i386/netbsd64.h: revision 1.2
 	external/gpl3/gcc/dist/gcc/config/i386/i386.c: revision 1.2
 	external/gpl3/gcc/dist/gcc/config/i386/i386.h: revision 1.2
 Fix GCC to correctly implement the i386 psABI on NetBSD.
 This consists of two parts:
 - for NetBSD/i386 and NetBSD/AMD64 with -m32, use a default stack
   alignment of 23bit as specified by the ABI
 - ensure that double and long long variables on the stack are by default
   only aligned to 32bit, if there is nothing else in the function
   needing a larger stack alignment
 The combination ensures that SSE variables on the stack trigger the
 realignment logic, but just using double or long long doesn't.
 PR 46978: ICE on spilling MMX registers
 GCC/i386 has code to lower the required alignment for long long to 32bit
 as the CPU doesn't need more. It is also using the same mode for setting
 up the MMX registers and in turn, the stack slots reserved for spilling
 require 32bit alignment. The actual vector types used keep the original
 64bit alignment, so when the compiler wants to spill a MMX register, it
 hits an assertion. Fix this by using the vector type as raw type for MMX
 registers.


 To generate a diff of this commit:
 cvs rdiff -u -r1.1.1.1 -r1.1.1.1.4.1 \
     src/external/gpl3/gcc/dist/gcc/config/i386/i386.c \
     src/external/gpl3/gcc/dist/gcc/config/i386/i386.h \
     src/external/gpl3/gcc/dist/gcc/config/i386/netbsd64.h
 cvs rdiff -u -r1.2 -r1.2.2.1 \
     src/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.