This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, 2/4] Enable libstdc++ as a DLL on windows platforms.


  This is patch #2 in the series.  It adds autoconf tests for libstdc++
support wrapper functions present in the Cygwin DLL, and adds an option (only
present for Cygwin and defaulted according to the autoconf test) to make the
compiler invoke the wrappers when linking.

gcc/ChangeLog:

	* configure.ac (USE_CYGWIN_LIBSTDCXX_WRAPPERS): Define to reflect
	status of AC_CHECK_FUNC for Cygwin DLL libstdc++ support wrappers.
	* configure: Regenerate.
	* config.in: Regenerate.

	* config/i386/cygwin.h (CXX_WRAP_SPEC_LIST): Define list of --wrap
	options for Cygwin DLL listdc++ support wrappers.
	(CXX_WRAP_SPEC_OPT): Define spec to use wrappers or not by default
	according to status of USE_CYGWIN_LIBSTDCXX_WRAPPERS.
	(LINK_SPEC): Include CXX_WRAP_SPEC_OPT.
	* config/i386/cygming.opt (muse-libstdc-wrappers): New option for
	Cygwin targets.

  Ok?

    cheers,
      DaveK
gcc/ChangeLog:

	* configure.ac (USE_CYGWIN_LIBSTDCXX_WRAPPERS): Define to reflect
	status of AC_CHECK_FUNC for Cygwin DLL libstdc++ support wrappers.
	* configure: Regenerate.
	* config.in: Regenerate.

	* config/i386/cygwin.h (CXX_WRAP_SPEC_LIST): Define list of --wrap
	options for Cygwin DLL listdc++ support wrappers.
	(CXX_WRAP_SPEC_OPT): Define spec to use wrappers or not by default
	according to status of USE_CYGWIN_LIBSTDCXX_WRAPPERS.
	(LINK_SPEC): Include CXX_WRAP_SPEC_OPT.
	* config/i386/cygming.opt (muse-libstdc-wrappers): New option for
	Cygwin targets.

Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 149338)
+++ gcc/configure.ac	(working copy)
@@ -2976,6 +2976,19 @@ changequote(,)dnl
   i[34567]86-*-* | x86_64-*-*)
 changequote([,])dnl
     case $target_os in
+      cygwin*)
+	# Full C++ conformance when using a shared libstdc++-v3 requires some
+	# support from the Cygwin DLL, which in more recent versions exports
+	# wrappers to aid in interposing and redirecting operators new, delete,
+	# etc., as per n2800 #17.6.4.6 [replacement.functions].  Check if we
+	# are configuring for a version of Cygwin that exports the wrappers.
+	AC_CHECK_FUNC([__wrap__Znaj],[gcc_ac_cygwin_dll_wrappers=yes],[gcc_ac_cygwin_dll_wrappers=no])
+	AC_DEFINE_UNQUOTED(USE_CYGWIN_LIBSTDCXX_WRAPPERS,
+	  [`if test $gcc_ac_cygwin_dll_wrappers = yes; then echo 1; else echo 0; fi`],
+	  [Define if you want to generate code by default that assumes that the
+	   Cygwin DLL exports wrappers to support libstdc++ function replacement.])
+    esac
+    case $target_os in
       cygwin* | pe | mingw32*)
 	# Recent binutils allows the three-operand form of ".comm" on PE.  This
 	# definition is used unconditionally to initialise the default state of
Index: gcc/config/i386/cygwin.h
===================================================================
--- gcc/config/i386/cygwin.h	(revision 149338)
+++ gcc/config/i386/cygwin.h	(working copy)
@@ -85,9 +85,38 @@ along with GCC; see the file COPYING3.  If not see
   %{mwindows:-lgdi32 -lcomdlg32} \
   -luser32 -lkernel32 -ladvapi32 -lshell32"
 
+/* To implement C++ function replacement we always wrap the cxx
+   malloc-like operators.  See N2800 #17.6.4.6 [replacement.functions] */
+#define CXX_WRAP_SPEC_LIST "\
+  --wrap _Znwj \
+  --wrap _Znaj \
+  --wrap _ZdlPv \
+  --wrap _ZdaPv \
+  --wrap _ZnwjRKSt9nothrow_t \
+  --wrap _ZnajRKSt9nothrow_t \
+  --wrap _ZdlPvRKSt9nothrow_t \
+  --wrap _ZdaPvRKSt9nothrow_t "
+
+#if defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS)
+
+#if USE_CYGWIN_LIBSTDCXX_WRAPPERS
+/* Default on, only explict -mno disables.  */
+#define CXX_WRAP_SPEC_OPT "!mno-use-libstdc-wrappers"
+#else
+/* Default off, only explict -m enables.  */
+#define CXX_WRAP_SPEC_OPT "muse-libstdc-wrappers"
+#endif
+
+#else /* !defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS)  */
+
+#define CXX_WRAP_SPEC_OPT ""
+
+#endif /* ?defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS) */
+
 #define LINK_SPEC "\
   %{mwindows:--subsystem windows} \
   %{mconsole:--subsystem console} \
+  %{" CXX_WRAP_SPEC_OPT ":" CXX_WRAP_SPEC_LIST "} \
   %{shared: %{mdll: %eshared and mdll are not compatible}} \
   %{shared: --shared} %{mdll:--dll} \
   %{static:-Bstatic} %{!static:-Bdynamic} \
Index: gcc/config/i386/cygming.opt
===================================================================
--- gcc/config/i386/cygming.opt	(revision 149338)
+++ gcc/config/i386/cygming.opt	(working copy)
@@ -1,6 +1,6 @@
 ; Cygwin- and MinGW-specific options.
 
-; Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+; Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc.
 ;
 ; This file is part of GCC.
 ;
@@ -49,3 +49,7 @@ Create GUI application
 mpe-aligned-commons
 Target Var(use_pe_aligned_common) Init(HAVE_GAS_ALIGNED_COMM)
 Use the GNU extension to the PE format for aligned common data
+
+muse-libstdc-wrappers
+Target C++ Condition({defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS)})
+Compile code that relies on Cygwin DLL wrappers to support C++ operator new/delete replacement

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