I had some problems building the cygwin1.dll after i changed gcc to use
sjlj exceptions. The resulting dll was unusable.
I have discovered that this is due to the fact that cygwin1 is linked
against libstdc++. The only reasons why cygwin1 is linked against stdc++
are the operators new and delete and __cxa_pure_virtual.
IMHO this is not acceptable because the new and new[] operators will throw
exceptions if the memory allocation has failed. C programs will terminate
via abort because the exception is not caught, C++ programs might behave
unpredictable.
A possible solution might be to use the nothrow new operators, i think
that the cleanest way is to define own operators. As a side effect the
cygwin1 dll can be build with an sjlj gcc and the dll is
significantly smaller.
Thomas
2002-11-26 Thomas Pfaff <[EMAIL PROTECTED]>
* cxx.cc: New file. Implement new, new[], delete and delete[]
operators. Implement __cxa_pure_virtual.
* Makefile.in (DLL_OFILES): Add cxx.o.
Remove libstdc++.a from cygwin1.dll link step.
diff -urpN src.old/winsup/cygwin/Makefile.in src/winsup/cygwin/Makefile.in
--- src.old/winsup/cygwin/Makefile.in 2002-10-21 03:03:32.000000000 +0200
+++ src/winsup/cygwin/Makefile.in 2002-11-26 11:09:38.000000000 +0100
@@ -124,7 +124,7 @@ MALLOC_OFILES=@MALLOC_OFILES@
DLL_IMPORTS:=$(w32api_lib)/libkernel32.a
# Please maintain this list in sorted order, with maximum files per 80 col line
-DLL_OFILES:=assert.o autoload.o cygheap.o cygserver_client.o \
+DLL_OFILES:=assert.o autoload.o cxx.o cygheap.o cygserver_client.o \
cygserver_transport.o cygserver_transport_pipes.o \
cygserver_transport_sockets.o cygthread.o dcrt0.o debug.o \
delqueue.o dir.o dlfcn.o dll_init.o dtable.o environ.o errno.o \
@@ -263,7 +263,7 @@ maintainer-clean realclean: clean
new-$(DLL_NAME): $(LDSCRIPT) $(DLL_OFILES) $(DEF_FILE) $(DLL_IMPORTS) $(LIBC) $(LIBM)
$(API_VER) Makefile winver_stamp
$(CXX) $(CXXFLAGS) -nostdlib -Wl,-T$(firstword $^) -Wl,--out-implib,cygdll.a
-shared -o $@ \
-e $(DLL_ENTRY) $(DEF_FILE) $(DLL_OFILES) version.o winver.o \
- $(MALLOC_OBJ) $(LIBM) -lstdc++ $(LIBC) \
+ $(MALLOC_OBJ) $(LIBM) $(LIBC) \
-lgcc $(DLL_IMPORTS)
# Rule to build libcygwin.a
diff -urpN src.old/winsup/cygwin/cxx.cc src/winsup/cygwin/cxx.cc
--- src.old/winsup/cygwin/cxx.cc 1970-01-01 01:00:00.000000000 +0100
+++ src/winsup/cygwin/cxx.cc 2002-11-26 11:28:32.000000000 +0100
@@ -0,0 +1,45 @@
+/* cxx.cc
+
+ Copyright 2002 Red Hat, Inc.
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#include "winsup.h"
+#include <stdlib.h>
+
+void *
+operator new (size_t s)
+{
+ void *p = malloc (s);
+ if (p)
+ memset (p,0,s);
+ return p;
+}
+
+void
+operator delete (void *p)
+{
+ free (p);
+}
+
+void *
+operator new[] (size_t s)
+{
+ return ::operator new (s);
+}
+
+void
+operator delete[] (void *p)
+{
+ ::operator delete (p);
+}
+
+extern "C" void
+__cxa_pure_virtual (void)
+{
+ api_fatal ("pure virtual method called");
+}