From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15992 invoked by alias); 5 Nov 2008 01:44:35 -0000 Received: (qmail 15946 invoked by uid 22791); 5 Nov 2008 01:44:34 -0000 X-Spam-Check-By: sourceware.org Received: from fg-out-1718.google.com (HELO fg-out-1718.google.com) (72.14.220.152) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 05 Nov 2008 01:43:56 +0000 Received: by fg-out-1718.google.com with SMTP id e21so3088605fga.28 for ; Tue, 04 Nov 2008 17:43:52 -0800 (PST) Received: by 10.86.72.15 with SMTP id u15mr428805fga.5.1225849431997; Tue, 04 Nov 2008 17:43:51 -0800 (PST) Received: by 10.86.94.6 with HTTP; Tue, 4 Nov 2008 17:43:51 -0800 (PST) Message-ID: <303e1d290811041743w79a08319p8ac3b79fe5bc310c@mail.gmail.com> Date: Wed, 05 Nov 2008 01:44:00 -0000 From: "David Edelsohn" To: "GCC Patches" Subject: [PATCH] G++ static linking on AIX (PR target/26397) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2008-11/txt/msg00144.txt.bz2 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) \