delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/04/28/05:07:06

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Subject: Re: g++ 3.4.0 cygwin, codegen SSE & alignement issues
To: cygwin AT cygwin DOT com
Date: Wed, 28 Apr 2004 05:06:39 -0400 (EDT)
Cc: gcc AT ompf DOT org
MIME-Version: 1.0
Message-Id: <20040428090639.6DE49A8677@perpugilliam.csclub.uwaterloo.ca>
From: rridge AT csclub DOT uwaterloo DOT ca (Ross Ridge)

tbp wrote:
>Building an app of mine (multithreaded) with something like -O3 -march=k8
>the binary died with an illegal instruction. The offending instruction
>was a 'movaps %xmm0, 0x40(%esp)' with an unaligned esp.  As that was
>on a secondary thread after some external calls (opengl and so on)
>i thought it had to do with some cygwin/ABI issue or something.

It's an ABI incompatiblity issue, GCC expects a 16-byte aligned stack,
but the Windows ABI, to the extent one actually exists, only assumes
a 4-byte aligned stack (and even that's not a strict requirement).
Normally it's not a problem, but if you have any callbacks in your code
(eg. the one that starts the secondary thread) that are called by library
functions not compiled with GCC, then the stack can get misaligned.
 
>And 1hour ago i got g++ to produce that sequence (same app,
>slightly different compilation switches like -mfpmath=sse,387): 'xorps
>0x435d7c,%xmm1' That one is clearly wrong and doesn't have to do with
>stack alignment.

This is a GCC and/or Binutils (as/ld) bug.  GCC puts constants in the
".rdata" section, but this section only 4-byte aligned.

>Take note that my app doesn't generate sse1/2 on its own, it all comes
>from gcc.

Well, that makes the workaround simple, just use the "-mno-sse",
"-mno-sse2" options, don't use the "-mfpmath=sse" option and GCC shouldn't
generate any SSE1/2 instructions.

						Ross Ridge

-- 
 l/  //	  Ross Ridge -- The Great HTMU
[oo][oo]  rridge AT csclub DOT uwaterloo DOT ca
-()-/()/  http://www.csclub.uwaterloo.ca/u/rridge/ 
 db  //	  

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019