From patchwork Tue Mar 7 12:11:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nitish Kumar Mishra X-Patchwork-Id: 19451 Received: (qmail 75076 invoked by alias); 7 Mar 2017 12:12:04 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 75047 invoked by uid 89); 7 Mar 2017 12:12:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=flex, Mishra, Motivation, mishra X-HELO: mail-pg0-f54.google.com Received: from mail-pg0-f54.google.com (HELO mail-pg0-f54.google.com) (74.125.83.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 07 Mar 2017 12:11:59 +0000 Received: by mail-pg0-f54.google.com with SMTP id 187so24498008pgb.3 for ; Tue, 07 Mar 2017 04:12:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=zXo/dTO1tH0hLLoBJrd0iTIAUispmFYW3B3Qy1D9SuM=; b=p1X85dT2AOWOqLZ5m8ceklI3GAVBBbm74r70/Ap2WMi/nYJSbVCZMObS7NS78XXA19 8lhiLm0mYmsHRXd6Ey7JZm3KzoyHcfRJizKDFNhzVdInyOoKnHxEnNhA0Qh8DAxi/4uM DAUqg7C6feeJwwLF35WQxy6nIwqvTnk+fYvS+L9Szs3qEz8ik5yDlmApiofe3Ylc7pc2 HYKLsqYViyRBZfcQYOEQiKD/KAV85HxhFPVFWJtKjAamFQfg25bVHoUr1di7H7PUzUS+ 7PpocZz5YG1aUU66SpkT/OXET767xBM1qg8OF5gbnbQV0X2bDVobIJH08n0x/nKYuQzQ 36xQ== X-Gm-Message-State: AMke39lfQrp/r1t2ihq3pHwoSIasjfSksyX65/XDYFtuu/dd39YwQp9sQ8vXRSdsrUIS8j4s2Zdev+PML34jZQ== X-Received: by 10.84.224.3 with SMTP id r3mr34293929plj.6.1488888718880; Tue, 07 Mar 2017 04:11:58 -0800 (PST) MIME-Version: 1.0 Received: by 10.100.178.131 with HTTP; Tue, 7 Mar 2017 04:11:58 -0800 (PST) From: Nitish Kumar Mishra Date: Tue, 7 Mar 2017 17:41:58 +0530 Message-ID: Subject: [PATCH] [PR build/21187] Static linking of libstdc++ and libgcc with GDB leads to broken exception handling on AIX platform To: gdb-patches@sourceware.org X-IsSubscribed: yes Hello, This patch is for the defect 21187 ( https://sourceware.org/bugzilla/show_bug.cgi?id=21187 ). I am attaching the patch to configure.ac file in which I have provided a configure option "--disable-staticlib" to link libstdc++ and libgcc library to GCC dynamically. ==== Motivation for the change ==== When linked statically with libstdc++ and libgcc on AIX platform, GDB is facing broken exception handling issues. Following is the error output when GDB is linked statically with mentioned libraries: (GDB-7.12.1, built with GCC-6.2, 64 bit mode, AIX platform): # ./gdb GNU gdb (GDB) 7.12.1 Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "powerpc64-ibm-aix7.2.0.0". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word". (gdb) kill terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR' IOT/Abort trap (core dumped) ==== Testing ==== I have manually built and tested GDB-7.12.1 with this patch on AIX-7.2 and Ubuntu-16.04 with GCC-6.2 and GCC-4.8.5. On both operating system GDB is working fine with the patch. Output on AIX-7.2: # ./gdb GNU gdb (GDB) 7.12.1 Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "powerpc64-ibm-aix7.2.0.0". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word". (gdb) kill The program is not being run. ==== Context ==== The issue came in picture in November and have discussed here: https://sourceware.org/ml/gdb/2017-02/msg00047.html I have tested the issue on GDB-7.12.1 built with GCC-4.8.5, both 32 and 64 bit object mode on AIX platform. The 64 bit mode does NOT have this issue, but 32 bit mode has broken exception handling. The issue is same with GDB-7.12.1 built with GCC-6.2, 64 bit mode on AIX platform. GCC is not able to handle the exceptions properly and GDB is leading to core dump. On Ubuntu-16.04, and other platforms, there is no such issue. I believe this issue is specifically for AIX. Please find the attachment for patch and ChangeLog. Thanks and Regards, Nitish K Mishra 2016-03-01 Nitish K Mishra * configure.ac: Include one more option "--disable-staticlib" to link libstdc++ and libgcc dynamically. diff --git a/configure.ac b/configure.ac index 3ec86c1..c400251 100644 --- a/configure.ac +++ b/configure.ac @@ -140,7 +140,7 @@ host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktr # binutils, gas and ld appear in that order because it makes sense to run # "make check" in that particular order. # If --enable-gold is used, "gold" may replace "ld". -host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gotools" +host_tools="flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gotools" # libgcj represents the runtime libraries only used by gcj. libgcj="target-libffi \ @@ -337,7 +337,7 @@ case "${ENABLE_GOLD}" in *-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux* \ | *-*-linux* | *-*-gnu* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \ | *-*-netbsd* | *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* \ - | *-*-solaris2* | *-*-nto* | *-*-nacl* | *-*-fuchsia*) + | *-*-solaris2* | *-*-nto* | *-*-nacl*) case "${target}" in *-*-linux*aout* | *-*-linux*oldld*) ;; @@ -471,6 +471,13 @@ ENABLE_LIBSTDCXX=default) noconfigdirs="$noconfigdirs target-libstdc++-v3" fi] +AC_ARG_ENABLE(staticlib, +AS_HELP_STRING([--disable-staticlib], + [do not link libstdc++ and libgcc library statically, default is static linking]), +ENABLE_STATICLIB=$enableval, +ENABLE_STATICLIB=yes) + + # If this is accelerator compiler and its target is intelmic we enable # target liboffloadmic by default. If this is compiler with offloading # for intelmic we enable host liboffloadmic by default. Otherwise @@ -1406,9 +1413,10 @@ if test -z "$LD"; then fi fi -# Check whether -static-libstdc++ -static-libgcc is supported. +# If ENABLE_STATICLIB is set for configuration, check whether -static-libstdc++ -static-libgcc is supported have_static_libs=no -if test "$GCC" = yes; then +if test "$ENABLE_STATICLIB" = yes; then + if test "$GCC" = yes; then saved_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc" @@ -1424,6 +1432,7 @@ int main() {}], AC_LANG_POP(C++) LDFLAGS="$saved_LDFLAGS" + fi fi ACX_PROG_GNAT @@ -1741,6 +1750,9 @@ AC_ARG_WITH(stage1-ldflags, # trust that they are doing what they want. if test "$stage1_libs" = "" -a "$have_static_libs" = yes; then stage1_ldflags="-static-libstdc++ -static-libgcc" + else + # If static lib is disabled. + stage1_ldflags="" fi]) AC_SUBST(stage1_ldflags) @@ -1768,8 +1780,11 @@ AC_ARG_WITH(boot-ldflags, # In stages 2 and 3, default to linking libstdc++ and libgcc # statically. But if the user explicitly specified the libraries to # use, trust that they are doing what they want. - if test "$poststage1_libs" = ""; then + if test "$poststage1_libs" = "" -a "$have_static_libs" = yes; then poststage1_ldflags="-static-libstdc++ -static-libgcc" + else + # If static library linking is disabled. + poststage1_ldflags="" fi]) AC_SUBST(poststage1_ldflags)