delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/04/28/11:18:29

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
Message-ID: <408FCABF.2050702@ompf.org>
Date: Wed, 28 Apr 2004 17:16:15 +0200
From: tbp <gcc AT ompf DOT org>
Reply-To: gcc AT ompf DOT org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031007
MIME-Version: 1.0
To: Ross Ridge <rridge AT csclub DOT uwaterloo DOT ca>, cygwin AT cygwin DOT com
Subject: Re: g++ 3.4.0 cygwin, codegen SSE & alignement issues
References: <20040428090639 DOT 6DE49A8677 AT perpugilliam DOT csclub DOT uwaterloo DOT ca>
In-Reply-To: <20040428090639.6DE49A8677@perpugilliam.csclub.uwaterloo.ca>

Ross Ridge wrote:
> 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.
Every library under my control were recompiled with gcc3.4 and more 
specifically SDL that i used to spawn those threads.
My code when it has alignement requirement tells the compiler about; the 
trouble is in that case that gcc emited sse instructions with 16byte 
requirement on its own without further checkings.

GCC 3.3.1 works like a charm when using fpmath=sse on the same source, 
tho i haven't seen it emitting memory references in conjunction with *ps 
instructions.

> 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).
Is there an official or semi official way to fix it or do i have to 
insert something like "mov esp, eax; and 0x15, eax; sub eax, esp" where 
it helps?

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

Alejandro López-Valencia wrote:
 > Or, instead, add -mms-bitfields -malign-double to your CFLAGS and
 > -Wl,--fdata-sections to your LDFLAGS sectiion. It may or may not work
 > but at least the failure will be different.
I've already tried -malign-double -fdata-sections. In fact i've tried 
every option remotly related to alignment under sun (but -mms-bitfields 
that i didn't know about) to no avail.

As a side note gcc 3.3.1 acts funny sometimes with -ffunction-sections 
-fdata-sections for cygwin/ming at link time when dealing with lots of 
objects.

> 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.
Or i could use gcc 3.3.1. Or use another compiler.
I understand -mfpmath=sse is flagged as experimental. What i don't get 
is why the compiler emits totally bogus code when using default 
switches: -O3 -march=k8 -> boom. -O3 -march=pentium4 -> boom.

I guess this has little to do with cygwin per se and i'm gonna file a 
bugreport to let the gcc ppl know.

Thanks for your time.

	tbp

PS: I've never found out how to build a 'cygming special' binary from 
gcc sources, i can only make a cygwin or mingw. What's the trick?


--
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