From: "David Edelsohn" <dje.gcc@gmail.com>
To: "GCC Patches" <gcc-patches@gcc.gnu.org>
Subject: [PATCH] G++ static linking on AIX (PR target/26397)
Date: Wed, 05 Nov 2008 01:44:00 -0000 [thread overview]
Message-ID: <303e1d290811041743w79a08319p8ac3b79fe5bc310c@mail.gmail.com> (raw)
AIX permits static linking against a shared library (without the benefits
of granularity of a normal archive of object files). When building
libstdc++, some functions are omitted from the shared object that
are included in the static archive. When linking against shared
libraries, these functions normally are provided by libgcc_s.so.
The combination of -static-libgcc and the libstdc++ shared
library encounter problems on AIX because neither provides
the missing symbols.
On AIX one needs to add libsupc++ when linking statically to
provide the additional symbols for exception handling -- specifically
to rethrow exceptions across library boundaries.
This patch adds a LIBSTDCXX_STATIC macro to cp/g++spec.c
that defaults to the normal "-lstdc++" but is overridden on AIX.
The new macro is used when G++ is invoked with -static or
-static-libgcc.
Okay?
Thanks, David
PR target/26397
* g++spec.c (LIBSTDCXX_STATIC): New.
(lang_spec_driver): Use LIBSTDCXX_STATIC when not shared_libgcc.
* config/rs6000/aix.h (LIBSTDCXX_STATIC): Define.
Index: cp/g++spec.c
===================================================================
--- cp/g++spec.c (revision 141264)
+++ cp/g++spec.c (working copy)
@@ -44,6 +44,9 @@
#ifndef LIBSTDCXX_PROFILE
#define LIBSTDCXX_PROFILE LIBSTDCXX
#endif
+#ifndef LIBSTDCXX_STATIC
+#define LIBSTDCXX_STATIC LIBSTDCXX
+#endif
void
lang_specific_driver (int *in_argc, const char *const **in_argv,
@@ -315,7 +318,8 @@
/* Add `-lstdc++' if we haven't already done so. */
if (library > 0)
{
- arglist[j] = saw_profile_flag ? LIBSTDCXX_PROFILE : LIBSTDCXX;
+ arglist[j] = shared_libgcc == 0 ? LIBSTDCXX_STATIC
+ : saw_profile_flag ? LIBSTDCXX_PROFILE : LIBSTDCXX;
if (arglist[j][0] != '-' || arglist[j][1] == 'l')
added_libraries++;
j++;
Index: config/rs6000/aix.h
===================================================================
--- config/rs6000/aix.h (revision 141264)
+++ config/rs6000/aix.h (working copy)
@@ -155,6 +155,9 @@
#define LIB_SPEC "%{pg:-L/lib/profiled -L/usr/lib/profiled}\
%{p:-L/lib/profiled -L/usr/lib/profiled} %{!shared:%{g*:-lg}} -lc"
+/* Static linking with shared libstdc++ requires libsupc++ as well. */
+#define LIBSTDCXX_STATIC "-lstdc++ -lsupc++"
+
/* This now supports a natural alignment mode. */
/* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints. */
#define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
next reply other threads:[~2008-11-05 1:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-05 1:44 David Edelsohn [this message]
2008-11-05 15:47 ` Ian Lance Taylor
2009-06-16 15:31 David Edelsohn
2009-06-16 16:31 ` Ian Lance Taylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=303e1d290811041743w79a08319p8ac3b79fe5bc310c@mail.gmail.com \
--to=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).