This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
target-specific contents for libstdc++: how to? [with actual patch!]
- From: gkeating at apple dot com (Geoffrey Keating)
- To: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 18 Aug 2005 21:53:53 -0700 (PDT)
- Subject: target-specific contents for libstdc++: how to? [with actual patch!]
Due to the timing of Apple's Tiger release, we used a simpler method
of making all the libgcc functions be hidden. Unfortunately, the
simpler method worked for everything but libstdc++, and so libstdc++
ended up exporting __eprintf in Tiger. (This was especially annoying
since __eprintf is probably the last symbol from libgcc.a that we'd want
it to export.) However, we're stuck with it now, and so if you want
to build a libstdc++ for Darwin you need to include __eprintf somehow.
It looks like other similar compatibility stuff goes in
src/compatibility.cc. Is that right? More generally, is this patch
right? (The ugly bit is at the end.) If not right, how should this
be done?
--
- Geoffrey Keating <geoffk@apple.com>
===File ~/patches/libstdc++-darwin-eprintf.patch============
2005-08-18 Geoffrey Keating <geoffk@apple.com>
* config/os/bsd/darwin/eprintf.ver: New.
* src/Makefile.am (libstdc++-symbol.ver): Move outside conditionals,
and make dependent on port symbol files.
(libstdc++-symbol.explist): Use the generated .ver file, not
the template.
* src/compatibility.cc [APPLE] (__eprintf): New.
Index: config/os/bsd/darwin/eprintf.ver
===================================================================
RCS file: config/os/bsd/darwin/eprintf.ver
diff -N config/os/bsd/darwin/eprintf.ver
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config/os/bsd/darwin/eprintf.ver 19 Aug 2005 01:59:34 -0000
@@ -0,0 +1 @@
+ __eprintf;
Index: src/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/Makefile.am,v
retrieving revision 1.151
diff -u -p -u -p -r1.151 Makefile.am
--- src/Makefile.am 17 Aug 2005 02:14:20 -0000 1.151
+++ src/Makefile.am 19 Aug 2005 01:59:34 -0000
@@ -28,10 +28,11 @@ include $(top_srcdir)/fragment.am
toolexeclib_LTLIBRARIES = libstdc++.la
# Symbol versioning for shared libraries.
-if ENABLE_SYMVERS_GNU
-version_arg = -Wl,--version-script=libstdc++-symbol.ver
-version_dep = libstdc++-symbol.ver
-libstdc++-symbol.ver: ${glibcxx_srcdir}/$(SYMVER_MAP)
+# This could be conditional on
+# ENABLE_SYMVERS_GNU || ENABLE_SYMVERS_DARWIN_EXPORT
+# but automake doesn't support OR operations in conditionals.
+libstdc++-symbol.ver: ${glibcxx_srcdir}/$(SYMVER_MAP) \
+ $(port_specific_symbol_files)
cp ${glibcxx_srcdir}/$(SYMVER_MAP) ./libstdc++-symbol.ver
if test "x$(port_specific_symbol_files)" != x; then \
sed -n '1,/DO NOT DELETE/p' $@ > tmp.top; \
@@ -39,15 +40,19 @@ libstdc++-symbol.ver: ${glibcxx_srcdir}
cat tmp.top $(port_specific_symbol_files) tmp.bottom > $@; \
rm tmp.top tmp.bottom; \
fi
+
+if ENABLE_SYMVERS_GNU
+version_arg = -Wl,--version-script=libstdc++-symbol.ver
+version_dep = libstdc++-symbol.ver
else
if ENABLE_SYMVERS_DARWIN_EXPORT
version_arg = -Wl,-exported_symbols_list,libstdc++-symbol.explist
version_dep = libstdc++-symbol.explist
-libstdc++-symbol.explist : ${glibcxx_srcdir}/$(SYMVER_MAP) \
+libstdc++-symbol.explist : libstdc++-symbol.ver \
${glibcxx_srcdir}/scripts/make_exports.pl \
$(libstdc___la_OBJECTS) $(libstdc___la_LIBADD)
perl ${glibcxx_srcdir}/scripts/make_exports.pl \
- ${glibcxx_srcdir}/$(SYMVER_MAP) \
+ libstdc++-symbol.ver \
$(libstdc___la_OBJECTS:%.lo=.libs/%.o) \
`echo $(libstdc___la_LIBADD) | \
sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
@@ -169,7 +174,6 @@ libstdc___la_DEPENDENCIES = ${version_de
libstdc___la_LDFLAGS = \
-version-info $(libtool_VERSION) ${version_arg} -lm
-
# Use special rules for the deprecated source files so that they find
# deprecated include files.
GLIBCXX_INCLUDE_DIR=$(glibcxx_builddir)/include
Index: src/compatibility.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/compatibility.cc,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 compatibility.cc
--- src/compatibility.cc 17 Aug 2005 02:14:20 -0000 1.4
+++ src/compatibility.cc 19 Aug 2005 01:59:34 -0000
@@ -361,3 +361,28 @@ namespace std
#undef _GLIBCXX_APPLY_SYMVER
#endif
+
+#ifdef __APPLE__
+#if (defined(__ppc__) || defined (__ppc64__)) && defined (PIC)
+/* __eprintf shouldn't have been made visible from libstdc++, or
+ anywhere, but on Mac OS X 10.4 it was defined in
+ libstdc++.6.0.3.dylib; so on that platform we have to keep defining
+ it to keep binary compatibility. We can't just put the libgcc
+ version in the export list, because that doesn't work; once a
+ symbol is marked as hidden, it stays that way. */
+
+#include <cstdio>
+#include <cstdlib>
+
+using namespace std;
+
+extern "C" void
+__eprintf (const char *string, const char *expression,
+ unsigned int line, const char *filename)
+{
+ fprintf (stderr, string, expression, line, filename);
+ fflush (stderr);
+ abort ();
+}
+#endif
+#endif /* __APPLE__ */
============================================================