This is the mail archive of the mailing list for the pthreas-win32 project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

MT exception support

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
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
-%{mthreads:-lmingwthrd} -lmingw32 -lgcc -lmoldname -lmsvcrt
+%{mthreads:-lmingwthrex} -lmingw32 -lgcc -lmoldname -lmsvcrt
 %{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.


#makefile for mingwm10ex.dll 
# These will need to changed to suit 
# Location of libgcc.a
# Location of mingwm10.dll src
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


MTHR_OBJS=mthr.o mthr_init.o


all: libmingwthrex.a

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

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

	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)

	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

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

_____________________________________________________________________________ - My Yahoo!
- Have news, stocks, weather, sports and more in one place.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]