public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
* MT exception support
@ 2001-04-04 12:22 Danny Smith
  0 siblings, 0 replies; only message in thread
From: Danny Smith @ 2001-04-04 12:22 UTC (permalink / raw)
  To: Mingw, pthreads-win32

Hello all 
 

Following is an alternative way of implementing Franco Bez  idea to
put exception handling code in dll and and Thomas Pfaff's idea to combine
with mthread support.  Any comments/criticisms/suggestions are more
than welcome

The attached makefile builds mthread support dll (mingwm10ex.dll) that
contains the EH code from libgcc -- viz the C++ EH code (CXX _LIB2FUNCS
in gcc's makefile) plus the generic EH code in _eh.o --
with the code in mingwm10.dll.

libgcc.a remains unaltered.  To get mthread exception handling, link in
the import lib (libmingwthrex.a) for mingwm10ex.dll before libgcc.a

Note, the dll contains only EH code from libgcc.a  There may be good reason
export other libgcc functions from the dll but I've tried to keep this dll
as small as possible (~53k).

I get the big congratulations  message with this with pthreads-snap-2000-
12-29 testsuite, but need to make following change to GNUmakefile

at line 31 change

LD	= gcc -mdll
to
LD	= gcc -mdll -mthreads

To use, copy attched makefile to empty dir, edit  to reflect location
of libgcc.a and src for mingwm10.dll,
"make install", and change specs file  like so:

--- specs.orig	Wed Mar 28 11:49:04 2001
+++ specs	Wed Apr 04 21:35:41 2001
@@ -23,7 +23,7 @@
 %{pg:-lgmon} %{mwindows:-lgdi32 -lcomdlg32}                   -luser32
-lkernel32 -ladvapi32 -lshell32
 
 *libgcc:
-%{mthreads:-lmingwthrd} -lmingw32 -lgcc -lmoldname -lmsvcrt
+%{mthreads:-lmingwthrex} -lmingw32 -lgcc -lmoldname -lmsvcrt
 
 *startfile:
 %{shared|mdll:dllcrt2%O%s} %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s}


I have also tested with libodbc++.dll, which uses exceptions extensively
when communicating with database drivers, and with STLPort4.1b5 iostream
lib as dll.

Note, I have built and tested with NT4 and gcc 2.95.3 (with w32-specific
patches), but see no reason why it shouldn't work with 2.95.2-1.

Danny


#makefile for mingwm10ex.dll 
#=========================================================================
# These will need to changed to suit 
# Location of libgcc.a
PREFIX=D:/mingw
GCCLIBDIR=$(PREFIX)/lib/gcc-lib/mingw32/2.95.3
# Location of mingwm10.dll src
MINGWSRCDIR=D:/Users/Danny/src/winsup/mingw
SHELL=/bin/sh.exe
CP=cp -f
MV=mv -f

CXX_LIB2OBJS = tinfo.o tinfo2.o new.o opnew.o opnewnt.o opvnew.o \
	opvnewnt.o opdel.o opdelnt.o opvdel.o opvdelnt.o exception.o frame.o

EH_OBJS = $(CXX_LIB2OBJS) _eh.o

MTHR_OBJS=mthr.o mthr_init.o

EH_DEF=EH.def

all: libmingwthrex.a

install: all
	$(CP) libmingwthrex.a $(PREFIX)/mingw32/lib
	$(CP) mingwm10ex.dll $(PREFIX)/bin

cleanbin:
	$(RM) *.a *.dll

clean: cleanbin
	$(RM) *.o

libmingwthrex.a:  $(EH_DEF) $(EH_OBJS) $(MTHR_OBJS) CRTmt.o
	gcc -shared  -o mingwm10ex.dll -Wl,--out-implib,libmingwthrex.a \
	  -Wl,--image-base,0x6FBC0000 \
	   $(EH_DEF) $(EH_OBJS) $(MTHR_OBJS) CRTmt.o
	ar -rs libmingwthrex.a CRTmt.o

$(EH_DEF): $(EH_OBJS)
	dlltool --export-all --output-def $(EH_DEF).tmp  $(EH_OBJS)
#This gets rid of the comments, which ld doesn't like
	cut -f1 -d';' $(EH_DEF).tmp > $(EH_DEF)

$(EH_OBJS):$(GCCLIBDIR)/libgcc.a
	ar -x  $(GCCLIBDIR)/libgcc.a $(EH_OBJS)

mthr.o : $(MINGWSRCDIR)/mthr.c
	gcc -O2 -c -o mthr.o $(MINGWSRCDIR)/mthr.c

mthr_init.o : $(MINGWSRCDIR)/mthr_init.c
	gcc -O2 -c -o mthr_init.o $(MINGWSRCDIR)/mthr_init.c

CRTmt.o : $(MINGWSRCDIR)/CRTmt.c
	gcc -O0 -c -o CRTmt.o $(MINGWSRCDIR)/CRTmt.c



_____________________________________________________________________________
http://my.yahoo.com.au - My Yahoo!
- Have news, stocks, weather, sports and more in one place.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-04-04 12:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-04 12:22 MT exception support Danny Smith

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