public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
From: "Dave Korn" <dave.korn@artimi.com>
To: <insight@sources.redhat.com>
Subject: [PATCH] HEAD build fails on cygwin (probably also mingw) in tcl/win subdir
Date: Tue, 26 Jul 2005 16:40:00 -0000	[thread overview]
Message-ID: <SERRANODh08nt9fDUyD00000746@SERRANO.CAM.ARTIMI.COM> (raw)

[-- Attachment #1: Type: text/plain, Size: 3059 bytes --]



      Hi all,

  CVS insight doesn't currently build on cygwin: it comes to a halt building
the target tcl lib, with the following errors when it comes to do the final
link:

----------------------snip----------------------
Creating library file: libtcl84.a
tclWin32Dll.o: In function `TclpCheckStackSpace':
/repository/tools/temp/src/tcl/win/tclWin32Dll.c:364: undefined reference to
`__except_checkstackspace_handler'
tclWinChan.o: In function `Tcl_MakeFileChannel':
/repository/tools/temp/src/tcl/win/tclWinChan.c:1056: undefined reference to
`__except_makefilechannel_handler'
tclWinFCmd.o: In function `DoCopyFile':
/repository/tools/temp/src/tcl/win/tclWinFCmd.c:558: undefined reference to
`__except_docopyfile_handler'
tclWinFCmd.o: In function `TclpObjRenameFile':
/repository/tools/temp/src/tcl/win/tclWinFCmd.c:204: undefined reference to
`__except_dorenamefile_handler'
collect2: ld returned 1 exit status
make[2]: *** [tcl84.dll] Error 1
make[2]: Leaving directory `/repository/tools/temp/obj/tcl/win'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/repository/tools/temp/obj/tcl'
make: *** [all-tcl] Error 2
----------------------snip----------------------

  The reason these functions are seemingly undefined is that, despite being
present in the source, they are all declared static, and only referenced
from within an inline asm statement.  This never used to cause any problem,
but cygwin has recently moved from gcc-3.3.x to gcc-3.4.x series, and the
optimisers must have gotten a bit cleverer.  The code in tclWinFCmd attempts
to spoof out the compiler by placing a recursive call to
_except_dorenamefile_handler inside _except_dorenamefile_handler; these
days, that successfully suppresses the 'function defined but not referenced'
warning, but isn't enough to fool the compiler into emitting the function
any more.

  Anyway, since the source code already uses unprotected __attribute__s in
that area, I figured it was ok to use '__attribute__ ((used))'.  Other
solutions could have included making the function reference visible to the
compiler, either by inserting a fake call, or by taking the address of it to
pass in to the inline asm, or making it extern rather than static, but this
looks like a reasonable and minimally-intrusive change to me.

  BTW, is the tcl dll supposed to be multithread safe?  The use of static
variables to store ESP/EBP before the exception and reload them afterward
looks, on the face of it, like it would have to be a problem, but it could
be that these are lowlevel functions that are only ever called from within
higher-level APIs that do suitable locking; I don't know, does anyone else?



2005-07-27  Dave Korn  <dave.korn@artimi.com>

tcl/

	* win/tclWin32Dll.c (ESP, EBP, _except_checkstackspace_handler): Add
  'used' attribute to prevent optimisation from discarding.
	* win/tclWinChan.c (ESP, EBP, _except_makefilechannel_handler):
  Likewise.
	* win/tclWinFCmd.c ( _except_dorenamefile_handler): Likewise.


    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....

[-- Attachment #2: cyg-tcl-sehfix.diff --]
[-- Type: application/octet-stream, Size: 2524 bytes --]

Index: tcl/win/tclWin32Dll.c
===================================================================
RCS file: /cvs/src/src/tcl/win/tclWin32Dll.c,v
retrieving revision 1.9
diff -p -u -r1.9 tclWin32Dll.c
--- tcl/win/tclWin32Dll.c	21 Jan 2003 19:40:22 -0000	1.9
+++ tcl/win/tclWin32Dll.c	26 Jul 2005 15:55:47 -0000
@@ -38,8 +38,8 @@ static HINSTANCE hInstance;	/* HINSTANCE
 static int platformId;		/* Running under NT, or 95/98? */
 
 #ifdef HAVE_NO_SEH
-static void *ESP;
-static void *EBP;
+static void *ESP __attribute__ ((used));
+static void *EBP __attribute__ ((used));
 #endif /* HAVE_NO_SEH */
 
 /*
@@ -393,7 +393,7 @@ TclpCheckStackSpace()
 }
 #ifdef HAVE_NO_SEH
 static
-__attribute__ ((cdecl))
+__attribute__ ((cdecl)) __attribute__ ((used))
 EXCEPTION_DISPOSITION
 _except_checkstackspace_handler(
     struct _EXCEPTION_RECORD *ExceptionRecord,
Index: tcl/win/tclWinChan.c
===================================================================
RCS file: /cvs/src/src/tcl/win/tclWinChan.c,v
retrieving revision 1.5
diff -p -u -r1.5 tclWinChan.c
--- tcl/win/tclWinChan.c	21 Jan 2003 19:40:22 -0000	1.5
+++ tcl/win/tclWinChan.c	26 Jul 2005 15:55:47 -0000
@@ -122,8 +122,8 @@ static Tcl_ChannelType fileChannelType =
 };
 
 #ifdef HAVE_NO_SEH
-static void *ESP;
-static void *EBP;
+static void *ESP __attribute__ ((used));
+static void *EBP __attribute__ ((used));
 #endif /* HAVE_NO_SEH */
 
 \f
@@ -1106,7 +1106,7 @@ Tcl_MakeFileChannel(rawHandle, mode)
 }
 #ifdef HAVE_NO_SEH
 static
-__attribute__ ((cdecl))
+__attribute__ ((cdecl)) __attribute__ ((used))
 EXCEPTION_DISPOSITION
 _except_makefilechannel_handler(
     struct _EXCEPTION_RECORD *ExceptionRecord,
Index: tcl/win/tclWinFCmd.c
===================================================================
RCS file: /cvs/src/src/tcl/win/tclWinFCmd.c,v
retrieving revision 1.6
diff -p -u -r1.6 tclWinFCmd.c
--- tcl/win/tclWinFCmd.c	7 Feb 2003 19:52:00 -0000	1.6
+++ tcl/win/tclWinFCmd.c	26 Jul 2005 15:55:47 -0000
@@ -469,7 +469,7 @@ DoRenameFile(
 }
 #ifdef HAVE_NO_SEH
 static
-__attribute__ ((cdecl))
+__attribute__ ((cdecl)) __attribute__ ((used))
 EXCEPTION_DISPOSITION
 _except_dorenamefile_handler(
     struct _EXCEPTION_RECORD *ExceptionRecord,
@@ -651,7 +651,7 @@ DoCopyFile(
 }
 #ifdef HAVE_NO_SEH
 static
-__attribute__ ((cdecl))
+__attribute__ ((cdecl)) __attribute__ ((used))
 EXCEPTION_DISPOSITION
 _except_docopyfile_handler(
     struct _EXCEPTION_RECORD *ExceptionRecord,

                 reply	other threads:[~2005-07-26 16:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SERRANODh08nt9fDUyD00000746@SERRANO.CAM.ARTIMI.COM \
    --to=dave.korn@artimi.com \
    --cc=insight@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).