public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
@ 2010-05-13 13:27 Jan Kratochvil
  2010-05-13 15:47 ` H.J. Lu
  0 siblings, 1 reply; 19+ messages in thread
From: Jan Kratochvil @ 2010-05-13 13:27 UTC (permalink / raw)
  To: gdb-patches

Hi,

gdb currently has needlessly huge .dynsym and thus even huge the (on-demand
loaded) LOAD segment.  With the attached patch it gets smaller:

-rwxr-xr-x 1 4524488 gdb-7.1-19.fc13.x86_64/usr/bin/gdb
-rwxr-xr-x 1 4266728 gdb-7.1-19dynamiclist.fc13.x86_64/usr/bin/gdb
-rw-r--r-- 1 2364656 gdb-7.1-19.fc13.x86_64.rpm
-rw-r--r-- 1 2274300 gdb-7.1-19dynamiclist.fc13.x86_64.rpm

I am not sure with the gdbserver/Makefile.in new CDEPS there.  I have not
found it defined anywhere while it is used as the gdbserver target dependency.

I hope on the build hosts where -rdynamic was supported even
-Wl,--dynamic-list must be supported.

ps_get_thread_area is not always defined while the proc-service.list file
lists it.  GNU ld does not seem to be concerned by undefined symbols.

No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.


Thanks,
Jan


gdb/
2010-05-13  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (SFILES): Add proc-service.list.
	* config/alpha/alpha-linux.mh (NAT_CDEPS): New.
	(LOADLIBES): Replace -rdynamic by -Wl,--dynamic-list=(...).
	* config/arm/linux.mh: Likewise.
	* config/i386/linux.mh: Likewise.
	* config/i386/linux64.mh: Likewise.
	* config/ia64/linux.mh: Likewise.
	* config/m32r/linux.mh: Likewise.
	* config/m68k/linux.mh: Likewise.
	* config/mips/linux.mh: Likewise.
	* config/pa/linux.mh: Likewise.
	* config/powerpc/linux.mh: Likewise.
	* config/powerpc/ppc64-linux.mh: Likewise.
	* config/s390/s390.mh: Likewise.
	* config/sparc/linux.mh: Likewise.
	* config/sparc/linux64.mh: Likewise.
	* config/xtensa/linux.mh: Likewise.
	* proc-service.list: New.

gdb/gdbserver/
2010-05-13  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (INTERNAL_CFLAGS): Change the subst to @DYNAMIC_LIST@.
	(SFILES): Add $(srcdir)/proc-service.list.
	(CDEPS): New.
	* configure.ac: Change RDYNAMIC to DYNAMIC_LIST.  Change the test to
	-Wl,--dynamic-list.
	* configure: Regenerate.
	* proc-service.list: New.

--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -683,7 +683,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
 	objc-exp.y objc-lang.c \
 	objfiles.c osabi.c observer.c osdata.c \
 	p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \
-	progspace.c \
+	proc-service.list progspace.c \
 	prologue-value.c psymtab.c \
 	regcache.c reggroups.c remote.c remote-fileio.c reverse.c \
 	scm-exp.c scm-lang.c scm-valprint.c \
--- a/gdb/config/alpha/alpha-linux.mh
+++ b/gdb/config/alpha/alpha-linux.mh
@@ -3,10 +3,11 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o corelow.o alpha-linux-nat.o \
 	fork-child.o proc-service.o linux-thread-db.o \
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
 # The dynamically loaded libthread_db needs access to symbols in the
 # gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
 
 # doublest.c currently assumes some properties of FP arithmetic
 # on the host which require this.
--- a/gdb/config/arm/linux.mh
+++ b/gdb/config/arm/linux.mh
@@ -3,5 +3,6 @@
 NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o arm-linux-nat.o \
 	proc-service.o linux-thread-db.o linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
-LOADLIBES= -ldl -rdynamic
+LOADLIBES= -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/i386/linux.mh
+++ b/gdb/config/i386/linux.mh
@@ -5,7 +5,8 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
 	i386-nat.o i386-linux-nat.o \
 	proc-service.o linux-thread-db.o \
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
 # The dynamically loaded libthread_db needs access to symbols in the
 # gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/i386/linux64.mh
+++ b/gdb/config/i386/linux64.mh
@@ -3,7 +3,8 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
 	i386-nat.o amd64-nat.o amd64-linux-nat.o linux-nat.o \
 	proc-service.o linux-thread-db.o linux-fork.o
 NAT_FILE= config/nm-linux.h
+NAT_CDEPS = $(srcdir)/proc-service.list
 
 # The dynamically loaded libthread_db needs access to symbols in the
 # gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/ia64/linux.mh
+++ b/gdb/config/ia64/linux.mh
@@ -4,5 +4,6 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o corelow.o \
 	core-regset.o ia64-linux-nat.o \
 	proc-service.o linux-thread-db.o linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/m32r/linux.mh
+++ b/gdb/config/m32r/linux.mh
@@ -4,5 +4,6 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o corelow.o	\
 	m32r-linux-nat.o proc-service.o linux-thread-db.o	\
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
-LOADLIBES= -ldl -rdynamic
+LOADLIBES= -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/m68k/linux.mh
+++ b/gdb/config/m68k/linux.mh
@@ -4,7 +4,8 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o \
 	corelow.o m68klinux-nat.o \
 	proc-service.o linux-thread-db.o linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
 # The dynamically loaded libthread_db needs access to symbols in the
 # gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/mips/linux.mh
+++ b/gdb/config/mips/linux.mh
@@ -3,5 +3,6 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o mips-linux-nat.o \
 	linux-thread-db.o proc-service.o \
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/pa/linux.mh
+++ b/gdb/config/pa/linux.mh
@@ -3,5 +3,6 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o corelow.o \
 	hppa-linux-nat.o proc-service.o linux-thread-db.o linux-nat.o \
 	linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/powerpc/linux.mh
+++ b/gdb/config/powerpc/linux.mh
@@ -6,5 +6,6 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o \
 	ppc-linux-nat.o proc-service.o linux-thread-db.o \
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/powerpc/ppc64-linux.mh
+++ b/gdb/config/powerpc/ppc64-linux.mh
@@ -6,6 +6,7 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o \
 	ppc-linux-nat.o proc-service.o linux-thread-db.o \
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
 # The PowerPC has severe limitations on TOC size, and uses them even
 # for non-PIC code.  GDB overflows those tables when compiling with
@@ -15,4 +16,4 @@ MH_CFLAGS= -mminimal-toc
 
 # The dynamically loaded libthread_db needs access to symbols in the
 # gdb executable.
-LOADLIBES= -ldl -rdynamic
+LOADLIBES= -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/s390/s390.mh
+++ b/gdb/config/s390/s390.mh
@@ -2,4 +2,5 @@
 NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o corelow.o s390-nat.o \
 	linux-thread-db.o proc-service.o linux-nat.o linux-fork.o
-LOADLIBES = -ldl -rdynamic
+NAT_CDEPS = $(srcdir)/proc-service.list
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/sparc/linux.mh
+++ b/gdb/config/sparc/linux.mh
@@ -4,7 +4,8 @@ NATDEPFILES= sparc-nat.o sparc-linux-nat.o \
 	corelow.o core-regset.o fork-child.o inf-ptrace.o \
 	proc-service.o linux-thread-db.o \
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
 # The dynamically loaded libthread_db needs access to symbols in the
 # gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/sparc/linux64.mh
+++ b/gdb/config/sparc/linux64.mh
@@ -5,7 +5,8 @@ NATDEPFILES= sparc-nat.o sparc64-nat.o sparc64-linux-nat.o \
 	fork-child.o inf-ptrace.o \
 	proc-service.o linux-thread-db.o \
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
 # The dynamically loaded libthread_db needs access to symbols in the
 # gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/xtensa/linux.mh
+++ b/gdb/config/xtensa/linux.mh
@@ -4,5 +4,6 @@ NAT_FILE= config/nm-linux.h
 
 NATDEPFILES= inf-ptrace.o fork-child.o xtensa-linux-nat.o \
 	linux-thread-db.o proc-service.o linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -95,12 +95,13 @@ INTERNAL_CFLAGS =  $(WARN_CFLAGS) ${CFLAGS} ${GLOBAL_CFLAGS} \
 # LDFLAGS is specifically reserved for setting from the command line
 # when running make.
 LDFLAGS = @LDFLAGS@
-INTERNAL_LDFLAGS = $(LDFLAGS) @RDYNAMIC@
+INTERNAL_LDFLAGS = $(LDFLAGS) @DYNAMIC_LIST@
 
 # All source files that go into linking GDB remote server.
 
 SFILES=	$(srcdir)/gdbreplay.c $(srcdir)/inferiors.c \
-	$(srcdir)/mem-break.c $(srcdir)/proc-service.c $(srcdir)/regcache.c \
+	$(srcdir)/mem-break.c $(srcdir)/proc-service.c \
+	$(srcdir)/proc-service.list $(srcdir)/regcache.c \
 	$(srcdir)/remote-utils.c $(srcdir)/server.c $(srcdir)/target.c \
 	$(srcdir)/thread-db.c $(srcdir)/utils.c \
 	$(srcdir)/linux-arm-low.c $(srcdir)/linux-cris-low.c \
@@ -133,6 +134,7 @@ OBS = inferiors.o regcache.o remote-utils.o server.o signals.o target.o \
 GDBREPLAY_OBS = gdbreplay.o version.o
 GDBSERVER_LIBS = @GDBSERVER_LIBS@
 XM_CLIBS = @LIBS@
+CDEPS = $(srcdir)/proc-service.list
 
 # XML files to compile in to gdbserver, if any.
 XML_DIR = $(srcdir)/../features
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -189,9 +189,12 @@ if test "$srv_linux_thread_db" = "yes"; then
   if test "$ac_cv_lib_dl_dlopen" = "yes"; then
     srv_libs="-ldl"
     old_LDFLAGS="$LDFLAGS"
-    LDFLAGS="$LDFLAGS -rdynamic"
-    AC_TRY_LINK([], [], [RDYNAMIC=-rdynamic], [RDYNAMIC=])
-    AC_SUBST(RDYNAMIC)
+    DYNAMIC_LIST="-Wl,--dynamic-list=${srcdir}/proc-service.list"
+    LDFLAGS="$LDFLAGS $DYNAMIC_LIST"
+    AC_TRY_LINK([], [],
+		[DYNAMIC_LIST='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
+		[DYNAMIC_LIST=])
+    AC_SUBST(DYNAMIC_LIST)
     LDFLAGS="$old_LDFLAGS"
   else
     srv_libs="-lthread_db"
--- /dev/null
+++ b/gdb/gdbserver/proc-service.list
@@ -0,0 +1,30 @@
+/* -Wl,--dynamic-list symbols exported for libthread_db.
+
+   Copyright (C) 2010 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+{
+  ps_get_thread_area;
+  ps_getpid;
+  ps_lgetfpregs;
+  ps_lgetregs;
+  ps_lsetfpregs;
+  ps_lsetregs;
+  ps_pdread;
+  ps_pdwrite;
+  ps_pglobal_lookup;
+};
--- /dev/null
+++ b/gdb/proc-service.list
@@ -0,0 +1,40 @@
+/* -Wl,--dynamic-list symbols exported for libthread_db.
+
+   Copyright (C) 2010 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+{
+  ps_get_thread_area;
+  ps_getpid;
+  ps_lcontinue;
+  ps_lgetfpregs;
+  ps_lgetregs;
+  ps_lgetxregs;
+  ps_lgetxregsize;
+  ps_lsetfpregs;
+  ps_lsetregs;
+  ps_lsetxregs;
+  ps_lstop;
+  ps_pcontinue;
+  ps_pdread;
+  ps_pdwrite;
+  ps_pglobal_lookup;
+  ps_plog;
+  ps_pstop;
+  ps_ptread;
+  ps_ptwrite;
+};

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-05-13 13:27 [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list Jan Kratochvil
@ 2010-05-13 15:47 ` H.J. Lu
  2010-05-16 21:08   ` Jan Kratochvil
  0 siblings, 1 reply; 19+ messages in thread
From: H.J. Lu @ 2010-05-13 15:47 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

On Thu, May 13, 2010 at 6:18 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> Hi,
>
> gdb currently has needlessly huge .dynsym and thus even huge the (on-demand
> loaded) LOAD segment.  With the attached patch it gets smaller:
>
> -rwxr-xr-x 1 4524488 gdb-7.1-19.fc13.x86_64/usr/bin/gdb
> -rwxr-xr-x 1 4266728 gdb-7.1-19dynamiclist.fc13.x86_64/usr/bin/gdb
> -rw-r--r-- 1 2364656 gdb-7.1-19.fc13.x86_64.rpm
> -rw-r--r-- 1 2274300 gdb-7.1-19dynamiclist.fc13.x86_64.rpm
>
> I am not sure with the gdbserver/Makefile.in new CDEPS there.  I have not
> found it defined anywhere while it is used as the gdbserver target dependency.
>
> I hope on the build hosts where -rdynamic was supported even
> -Wl,--dynamic-list must be supported.
>
> ps_get_thread_area is not always defined while the proc-service.list file
> lists it.  GNU ld does not seem to be concerned by undefined symbols.
>
> No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.
>
>

FWIW, --dynamic-list was added in Sept., 2006 and a bug was fixed in Oct., 2006.


-- 
H.J.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-05-13 15:47 ` H.J. Lu
@ 2010-05-16 21:08   ` Jan Kratochvil
  2010-05-27 19:58     ` Tom Tromey
  2010-06-13 19:58     ` [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list Andreas Schwab
  0 siblings, 2 replies; 19+ messages in thread
From: Jan Kratochvil @ 2010-05-16 21:08 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gdb-patches

On Thu, 13 May 2010 15:26:47 +0200, H.J. Lu wrote:
> On Thu, May 13, 2010 at 6:18 AM, Jan Kratochvil <jan.kratochvil@redhat.com> wrote:
> > I hope on the build hosts where -rdynamic was supported even
> > -Wl,--dynamic-list must be supported.
> 
> FWIW, --dynamic-list was added in Sept., 2006

Oops, thanks, therefore it now still fallbacks to -rdynamic.  It is
reproducible on RHEL-4.8 (+derivations).


> and a bug was fixed in Oct., 2006.

You refer probably to:
	[PATCH] Fix --dynamic-list
	http://sourceware.org/ml/binutils/2006-10/msg00064.html
	commit 5bab058dff8c0ff134868cc6fdcbe6afe58d7ebc
	Author: Jakub Jelinek <jakub@redhat.com>
	Date:   Wed Oct 11 14:58:19 2006 +0000

I have tested this fix on ppc64 and it has no effect on the build with binutils
from that GIT hash.  lang_append_dynamic_list gets called only once with all
the symbols at once:
Breakpoint 1, lang_append_dynamic_list (dynamic=0x1020a140) at ldlang.c:6961
6961      if (link_info.dynamic)
(gdb) p *dynamic
$1 = {next = 0x1020a0f0, pattern = 0x1020a120 ".ps_ptwrite", symbol = 0x1020a170 ".ps_ptwrite", symver = 0, script = 0, mask = 1}
(gdb) p *dynamic->next
$2 = {next = 0x1020a080, pattern = 0x1020a0d0 "ps_ptwrite", symbol = 0x1020a0d0 "ps_ptwrite", symver = 0, script = 0, mask = 1}
(gdb) p *dynamic->next->next
$3 = {next = 0x1020a030, pattern = 0x1020a060 ".ps_ptread", symbol = 0x1020a0b0 ".ps_ptread", symver = 0, script = 0, mask = 1}


Tested it on:
OpenSolaris 2009.06 snv_111b X86
gcc (GCC) 3.4.3 (csl-sol210-3_4-20050802)
$ gcc -rdynamic
gcc: unrecognized option `-rdynamic'
$ gcc -Wl,-export-dynamic ...
ld: fatal: entry point symbol `xport-dynamic' is undefined
$ gcc -Wl,--export-dynamic ...
usage: ld [-6:abc:d:e:f:h:il:mo:p:rstu:z:B:CD:F:GI:L:M:N:P:Q:R:S:VW:Y:?] file(s)
$ /usr/sfw/libexec/gcc/i386-pc-solaris2.11/3.4.3/collect2 --version
ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1652
$ ld --help|grep export-dynamic
GNU ld version 2.15
  -E, --export-dynamic        Export all dynamic symbols

But no special option is needed for threads debugging there; there also isn't
any one available for the Sun-provided gcc build.  I can remove the Solaris
host simplification
	* configure.ac (solaris*): Replace -Wl,-export-dynamic by $RDYNAMIC.
if there are any concerns.  The patch replaces -Wl,-export-dynamic by -rdynamic.
it could also test -Wl,-export-dynamic as a second fallback after current
-rdynamic.  -rdynamic was already used directly in linux .mh config/ files.

I do not have sparc solaris available to test the gdbserver change on solaris.
gdbserver is not supported on x86* solaris.


> > I am not sure with the gdbserver/Makefile.in new CDEPS there.  I have not
> > found it defined anywhere while it is used as the gdbserver target dependency.

No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.


Thanks,
Jan


gdb/
2010-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (RDYNAMIC): New.
	(SFILES): Add proc-service.list.
	* config/alpha/alpha-linux.mh (NAT_CDEPS): New.
	(LOADLIBES): Replace -rdynamic by $(RDYNAMIC).
	* config/arm/linux.mh: Likewise.
	* config/i386/linux.mh: Likewise.
	* config/i386/linux64.mh: Likewise.
	* config/ia64/linux.mh: Likewise.
	* config/m32r/linux.mh: Likewise.
	* config/m68k/linux.mh: Likewise.
	* config/mips/linux.mh: Likewise.
	* config/pa/linux.mh: Likewise.
	* config/powerpc/linux.mh: Likewise.
	* config/powerpc/ppc64-linux.mh: Likewise.
	* config/s390/s390.mh: Likewise.
	* config/sparc/linux.mh: Likewise.
	* config/sparc/linux64.mh: Likewise.
	* config/xtensa/linux.mh: Likewise.
	* configure.ac: New RDYNAMIC on native host and GCC.
	(solaris*): Replace -Wl,-export-dynamic by $RDYNAMIC.
	* configure: Regenerate.
	* proc-service.list: New.

gdb/gdbserver/
2010-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (SFILES): Add $(srcdir)/proc-service.list.
	(CDEPS): New.
	* configure.ac (RDYNAMIC): New AC_MSG_CHECKING wrapping.  Test also
	-Wl,--dynamic-list.
	* configure: Regenerate.
	* proc-service.list: New.

--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -157,6 +157,8 @@ GDB_WERROR_CFLAGS = $(WERROR_CFLAGS)
 
 GDB_WARN_CFLAGS_NO_FORMAT = `echo " $(GDB_WARN_CFLAGS) " | sed "s/ -Wformat-nonliteral / /g"`
 
+RDYNAMIC = @RDYNAMIC@
+
 # Where is the INTL library?  Typically in ../intl.
 INTL = @LIBINTL@
 INTL_DEPS = @LIBINTL_DEP@
@@ -683,7 +685,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
 	objc-exp.y objc-lang.c \
 	objfiles.c osabi.c observer.c osdata.c \
 	p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \
-	progspace.c \
+	proc-service.list progspace.c \
 	prologue-value.c psymtab.c \
 	regcache.c reggroups.c remote.c remote-fileio.c reverse.c \
 	scm-exp.c scm-lang.c scm-valprint.c \
--- a/gdb/config/alpha/alpha-linux.mh
+++ b/gdb/config/alpha/alpha-linux.mh
@@ -3,10 +3,11 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o corelow.o alpha-linux-nat.o \
 	fork-child.o proc-service.o linux-thread-db.o \
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
 # The dynamically loaded libthread_db needs access to symbols in the
 # gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl $(RDYNAMIC)
 
 # doublest.c currently assumes some properties of FP arithmetic
 # on the host which require this.
--- a/gdb/config/arm/linux.mh
+++ b/gdb/config/arm/linux.mh
@@ -3,5 +3,6 @@
 NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o arm-linux-nat.o \
 	proc-service.o linux-thread-db.o linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
-LOADLIBES= -ldl -rdynamic
+LOADLIBES= -ldl $(RDYNAMIC)
--- a/gdb/config/i386/linux.mh
+++ b/gdb/config/i386/linux.mh
@@ -5,7 +5,8 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
 	i386-nat.o i386-linux-nat.o \
 	proc-service.o linux-thread-db.o \
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
 # The dynamically loaded libthread_db needs access to symbols in the
 # gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl $(RDYNAMIC)
--- a/gdb/config/i386/linux64.mh
+++ b/gdb/config/i386/linux64.mh
@@ -3,7 +3,8 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
 	i386-nat.o amd64-nat.o amd64-linux-nat.o linux-nat.o \
 	proc-service.o linux-thread-db.o linux-fork.o
 NAT_FILE= config/nm-linux.h
+NAT_CDEPS = $(srcdir)/proc-service.list
 
 # The dynamically loaded libthread_db needs access to symbols in the
 # gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl $(RDYNAMIC)
--- a/gdb/config/ia64/linux.mh
+++ b/gdb/config/ia64/linux.mh
@@ -4,5 +4,6 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o corelow.o \
 	core-regset.o ia64-linux-nat.o \
 	proc-service.o linux-thread-db.o linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl $(RDYNAMIC)
--- a/gdb/config/m32r/linux.mh
+++ b/gdb/config/m32r/linux.mh
@@ -4,5 +4,6 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o corelow.o	\
 	m32r-linux-nat.o proc-service.o linux-thread-db.o	\
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
-LOADLIBES= -ldl -rdynamic
+LOADLIBES= -ldl $(RDYNAMIC)
--- a/gdb/config/m68k/linux.mh
+++ b/gdb/config/m68k/linux.mh
@@ -4,7 +4,8 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o \
 	corelow.o m68klinux-nat.o \
 	proc-service.o linux-thread-db.o linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
 # The dynamically loaded libthread_db needs access to symbols in the
 # gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl $(RDYNAMIC)
--- a/gdb/config/mips/linux.mh
+++ b/gdb/config/mips/linux.mh
@@ -3,5 +3,6 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o mips-linux-nat.o \
 	linux-thread-db.o proc-service.o \
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl $(RDYNAMIC)
--- a/gdb/config/pa/linux.mh
+++ b/gdb/config/pa/linux.mh
@@ -3,5 +3,6 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o corelow.o \
 	hppa-linux-nat.o proc-service.o linux-thread-db.o linux-nat.o \
 	linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl $(RDYNAMIC)
--- a/gdb/config/powerpc/linux.mh
+++ b/gdb/config/powerpc/linux.mh
@@ -6,5 +6,6 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o \
 	ppc-linux-nat.o proc-service.o linux-thread-db.o \
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl $(RDYNAMIC)
--- a/gdb/config/powerpc/ppc64-linux.mh
+++ b/gdb/config/powerpc/ppc64-linux.mh
@@ -6,6 +6,7 @@ NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o \
 	ppc-linux-nat.o proc-service.o linux-thread-db.o \
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
 # The PowerPC has severe limitations on TOC size, and uses them even
 # for non-PIC code.  GDB overflows those tables when compiling with
@@ -15,4 +16,4 @@ MH_CFLAGS= -mminimal-toc
 
 # The dynamically loaded libthread_db needs access to symbols in the
 # gdb executable.
-LOADLIBES= -ldl -rdynamic
+LOADLIBES= -ldl $(RDYNAMIC)
--- a/gdb/config/s390/s390.mh
+++ b/gdb/config/s390/s390.mh
@@ -2,4 +2,5 @@
 NAT_FILE= config/nm-linux.h
 NATDEPFILES= inf-ptrace.o fork-child.o corelow.o s390-nat.o \
 	linux-thread-db.o proc-service.o linux-nat.o linux-fork.o
-LOADLIBES = -ldl -rdynamic
+NAT_CDEPS = $(srcdir)/proc-service.list
+LOADLIBES = -ldl $(RDYNAMIC)
--- a/gdb/config/sparc/linux.mh
+++ b/gdb/config/sparc/linux.mh
@@ -4,7 +4,8 @@ NATDEPFILES= sparc-nat.o sparc-linux-nat.o \
 	corelow.o core-regset.o fork-child.o inf-ptrace.o \
 	proc-service.o linux-thread-db.o \
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
 # The dynamically loaded libthread_db needs access to symbols in the
 # gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl $(RDYNAMIC)
--- a/gdb/config/sparc/linux64.mh
+++ b/gdb/config/sparc/linux64.mh
@@ -5,7 +5,8 @@ NATDEPFILES= sparc-nat.o sparc64-nat.o sparc64-linux-nat.o \
 	fork-child.o inf-ptrace.o \
 	proc-service.o linux-thread-db.o \
 	linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
 # The dynamically loaded libthread_db needs access to symbols in the
 # gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl $(RDYNAMIC)
--- a/gdb/config/xtensa/linux.mh
+++ b/gdb/config/xtensa/linux.mh
@@ -4,5 +4,6 @@ NAT_FILE= config/nm-linux.h
 
 NATDEPFILES= inf-ptrace.o fork-child.o xtensa-linux-nat.o \
 	linux-thread-db.o proc-service.o linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list
 
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl $(RDYNAMIC)
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1312,6 +1312,30 @@ dnl Note that we only want this if we are both native (host == target),
 dnl and not doing a canadian cross build (build == host).
 
 if test ${build} = ${host} -a ${host} = ${target} ; then
+   if test "$GCC" = "yes" ; then
+      # The dynamically loaded libthread_db needs access to symbols in the gdb
+      # executable.  Older GNU ld supports --export-dynamic but --dynamic-list
+      # may not be supported there.
+      AC_MSG_CHECKING(for the dynamic export flag)
+      old_LDFLAGS="$LDFLAGS"
+      # Older GNU ld supports --export-dynamic but --dynamic-list it does not.
+      RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
+      LDFLAGS="$LDFLAGS $RDYNAMIC"
+      AC_TRY_LINK([], [],
+		  [found="-Wl,--dynamic-list"
+		   RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
+		  [RDYNAMIC="-rdynamic"
+		   LDFLAGS="$old_LDFLAGS $RDYNAMIC"
+		   AC_TRY_LINK([], [],
+			       [found="-rdynamic"],
+			       [found="no"
+				# Error on its usage by .mh file.
+				RDYNAMIC="no-rdynamic-available"])])
+      AC_SUBST(RDYNAMIC)
+      LDFLAGS="$old_LDFLAGS"
+      AC_MSG_RESULT($found)
+   fi
+
    case ${host_os} in
    hpux*)
       AC_MSG_CHECKING(for HPUX/OSF thread support)
@@ -1342,19 +1366,7 @@ if test ${build} = ${host} -a ${host} = ${target} ; then
          CONFIG_OBS="${CONFIG_OBS} sol-thread.o"
          CONFIG_SRCS="${CONFIG_SRCS} sol-thread.c"
          AC_CHECK_LIB(dl, dlopen)
-         if test "$GCC" = "yes" ; then
-            # The GNU linker requires the -export-dynamic option to make
-            # all symbols visible in the dynamic symbol table.
-            hold_ldflags=$LDFLAGS
-            AC_MSG_CHECKING(for the ld -export-dynamic flag)
-            LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
-            AC_TRY_LINK(, [int i;], found=yes, found=no)
-            LDFLAGS=$hold_ldflags
-            AC_MSG_RESULT($found)
-            if test $found = yes; then
-               CONFIG_LDFLAGS="${CONFIG_LDFLAGS} -Wl,-export-dynamic"
-            fi
-         fi
+	 CONFIG_LDFLAGS="${CONFIG_LDFLAGS} $RDYNAMIC"
 	 # Sun randomly tweaked the prototypes in <proc_service.h>
 	 # at one point.
 	 AC_MSG_CHECKING(if <proc_service.h> is old)
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -100,7 +100,8 @@ INTERNAL_LDFLAGS = $(LDFLAGS) @RDYNAMIC@
 # All source files that go into linking GDB remote server.
 
 SFILES=	$(srcdir)/gdbreplay.c $(srcdir)/inferiors.c \
-	$(srcdir)/mem-break.c $(srcdir)/proc-service.c $(srcdir)/regcache.c \
+	$(srcdir)/mem-break.c $(srcdir)/proc-service.c \
+	$(srcdir)/proc-service.list $(srcdir)/regcache.c \
 	$(srcdir)/remote-utils.c $(srcdir)/server.c $(srcdir)/target.c \
 	$(srcdir)/thread-db.c $(srcdir)/utils.c \
 	$(srcdir)/linux-arm-low.c $(srcdir)/linux-cris-low.c \
@@ -133,6 +134,7 @@ OBS = inferiors.o regcache.o remote-utils.o server.o signals.o target.o \
 GDBREPLAY_OBS = gdbreplay.o version.o
 GDBSERVER_LIBS = @GDBSERVER_LIBS@
 XM_CLIBS = @LIBS@
+CDEPS = $(srcdir)/proc-service.list
 
 # XML files to compile in to gdbserver, if any.
 XML_DIR = $(srcdir)/../features
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -188,11 +188,24 @@ USE_THREAD_DB=
 if test "$srv_linux_thread_db" = "yes"; then
   if test "$ac_cv_lib_dl_dlopen" = "yes"; then
     srv_libs="-ldl"
+    AC_MSG_CHECKING(for the dynamic export flag)
     old_LDFLAGS="$LDFLAGS"
-    LDFLAGS="$LDFLAGS -rdynamic"
-    AC_TRY_LINK([], [], [RDYNAMIC=-rdynamic], [RDYNAMIC=])
+    # Older GNU ld supports --export-dynamic but --dynamic-list may not be
+    # supported there.
+    RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
+    LDFLAGS="$LDFLAGS $RDYNAMIC"
+    AC_TRY_LINK([], [],
+		[found="-Wl,--dynamic-list"
+		 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
+		[RDYNAMIC="-rdynamic"
+		 LDFLAGS="$old_LDFLAGS $RDYNAMIC"
+		 AC_TRY_LINK([], [],
+			     [found="-rdynamic"],
+			     [found="no"
+			      RDYNAMIC=""])])
     AC_SUBST(RDYNAMIC)
     LDFLAGS="$old_LDFLAGS"
+    AC_MSG_RESULT($found)
   else
     srv_libs="-lthread_db"
   fi
--- /dev/null
+++ b/gdb/gdbserver/proc-service.list
@@ -0,0 +1,30 @@
+/* -Wl,--dynamic-list symbols exported for libthread_db.
+
+   Copyright (C) 2010 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+{
+  ps_get_thread_area;
+  ps_getpid;
+  ps_lgetfpregs;
+  ps_lgetregs;
+  ps_lsetfpregs;
+  ps_lsetregs;
+  ps_pdread;
+  ps_pdwrite;
+  ps_pglobal_lookup;
+};
--- /dev/null
+++ b/gdb/proc-service.list
@@ -0,0 +1,40 @@
+/* -Wl,--dynamic-list symbols exported for libthread_db.
+
+   Copyright (C) 2010 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+{
+  ps_get_thread_area;
+  ps_getpid;
+  ps_lcontinue;
+  ps_lgetfpregs;
+  ps_lgetregs;
+  ps_lgetxregs;
+  ps_lgetxregsize;
+  ps_lsetfpregs;
+  ps_lsetregs;
+  ps_lsetxregs;
+  ps_lstop;
+  ps_pcontinue;
+  ps_pdread;
+  ps_pdwrite;
+  ps_pglobal_lookup;
+  ps_plog;
+  ps_pstop;
+  ps_ptread;
+  ps_ptwrite;
+};

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-05-16 21:08   ` Jan Kratochvil
@ 2010-05-27 19:58     ` Tom Tromey
  2010-05-28 23:11       ` Jan Kratochvil
  2010-06-13 19:58     ` [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list Andreas Schwab
  1 sibling, 1 reply; 19+ messages in thread
From: Tom Tromey @ 2010-05-27 19:58 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: H.J. Lu, gdb-patches

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> gdb/
Jan> 2010-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

Jan> 	* Makefile.in (RDYNAMIC): New.
Jan> 	(SFILES): Add proc-service.list.
Jan> 	* config/alpha/alpha-linux.mh (NAT_CDEPS): New.
Jan> 	(LOADLIBES): Replace -rdynamic by $(RDYNAMIC).
Jan> 	* config/arm/linux.mh: Likewise.
Jan> 	* config/i386/linux.mh: Likewise.
Jan> 	* config/i386/linux64.mh: Likewise.
Jan> 	* config/ia64/linux.mh: Likewise.
Jan> 	* config/m32r/linux.mh: Likewise.
Jan> 	* config/m68k/linux.mh: Likewise.
Jan> 	* config/mips/linux.mh: Likewise.
Jan> 	* config/pa/linux.mh: Likewise.
Jan> 	* config/powerpc/linux.mh: Likewise.
Jan> 	* config/powerpc/ppc64-linux.mh: Likewise.
Jan> 	* config/s390/s390.mh: Likewise.
Jan> 	* config/sparc/linux.mh: Likewise.
Jan> 	* config/sparc/linux64.mh: Likewise.
Jan> 	* config/xtensa/linux.mh: Likewise.
Jan> 	* configure.ac: New RDYNAMIC on native host and GCC.
Jan> 	(solaris*): Replace -Wl,-export-dynamic by $RDYNAMIC.
Jan> 	* configure: Regenerate.
Jan> 	* proc-service.list: New.

Jan> gdb/gdbserver/
Jan> 2010-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>

Jan> 	* Makefile.in (SFILES): Add $(srcdir)/proc-service.list.
Jan> 	(CDEPS): New.
Jan> 	* configure.ac (RDYNAMIC): New AC_MSG_CHECKING wrapping.  Test also
Jan> 	-Wl,--dynamic-list.
Jan> 	* configure: Regenerate.
Jan> 	* proc-service.list: New.

This is ok.  Thanks.

Tom

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-05-27 19:58     ` Tom Tromey
@ 2010-05-28 23:11       ` Jan Kratochvil
  2010-06-05  2:48         ` Doug Evans
  0 siblings, 1 reply; 19+ messages in thread
From: Jan Kratochvil @ 2010-05-28 23:11 UTC (permalink / raw)
  To: Tom Tromey; +Cc: H.J. Lu, gdb-patches

On Thu, 27 May 2010 21:54:34 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> 
> Jan> gdb/
> Jan> 2010-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>
> Jan> gdb/gdbserver/
> Jan> 2010-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>
> This is ok.  Thanks.

Checked-in:
	http://sourceware.org/ml/gdb-cvs/2010-05/msg00247.html


Thanks,
Jan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-05-28 23:11       ` Jan Kratochvil
@ 2010-06-05  2:48         ` Doug Evans
  2010-06-05 12:45           ` Jan Kratochvil
  2012-01-12 19:28           ` [patch] -Wl,--dynamic-list: Test also PYTHON_LIBS, not just PYTHON_CFLAGS [Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list] Jan Kratochvil
  0 siblings, 2 replies; 19+ messages in thread
From: Doug Evans @ 2010-06-05  2:48 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Tom Tromey, gdb-patches

On Fri, May 28, 2010 at 11:52 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Thu, 27 May 2010 21:54:34 +0200, Tom Tromey wrote:
>> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
>>
>> Jan> gdb/
>> Jan> 2010-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>
>> Jan> gdb/gdbserver/
>> Jan> 2010-05-16  Jan Kratochvil  <jan.kratochvil@redhat.com>
>> This is ok.  Thanks.
>
> Checked-in:
>        http://sourceware.org/ml/gdb-cvs/2010-05/msg00247.html

I've been playing with this a bit and got the following:

 "ImportError: /usr/grte/v1/k8-linux/lib/python2.4/lib-dynload/itertools.so:
undefined symbol: PyExc_StopIteration"

when I did "import itertools".

I was statically linking libpythonX.Y.a.

I'm not sure what the right fix is.  IWBN if the python folks have
anticipated this and provide something like proc-service.list for
python.
I don't know all the python symbols that need to be exported ... maybe
there's a simple regexp (or a small number of them) that could find
them all.
[OTOH it might be a bit too fragile.]
Alternatively, one could disable this feature when python is being
linked statically.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-06-05  2:48         ` Doug Evans
@ 2010-06-05 12:45           ` Jan Kratochvil
  2010-06-08 15:23             ` Doug Evans
  2012-01-12 19:28           ` [patch] -Wl,--dynamic-list: Test also PYTHON_LIBS, not just PYTHON_CFLAGS [Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list] Jan Kratochvil
  1 sibling, 1 reply; 19+ messages in thread
From: Jan Kratochvil @ 2010-06-05 12:45 UTC (permalink / raw)
  To: Doug Evans; +Cc: Tom Tromey, gdb-patches

On Sat, 05 Jun 2010 04:48:33 +0200, Doug Evans wrote:
>  "ImportError: /usr/grte/v1/k8-linux/lib/python2.4/lib-dynload/itertools.so:
> undefined symbol: PyExc_StopIteration"
> 
> when I did "import itertools".
> 
> I was statically linking libpythonX.Y.a.
> 
> I'm not sure what the right fix is.

This is an open Python bug: http://bugs.python.org/issue4434
(I was not aware of it.)

I doubt how useful is to depend on .so modules while having .a libpython
linked in but I understand my patch broke compatibility with such case.

With libpythonX.Y.so.1.0 the problem does not happen as all the symbols are
present in its .dynsym.  There is an inefficiency Python-2.6.4/Include/pyport.h
uses dllimport and dllimport declarations for the API but it has no support
for gcc __attribute__((visibility)) there and thus libpythonX.Y.so.1.0's
.dynsym is excessively large there.

I was unable to test it as Fedora (13) does not ship libpythonX.Y.a (and it
failed to build one when I tried to).  Could you test it, please?

If some existing python tests were already broken I can drop this new one.

No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu.


Thanks,
Jan


gdb/
2010-06-05  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* configure.ac <"${have_libpython}" != no>: New workaround of
	python#4434.
	* configure: Regenerate.

gdb/testsuite/
2010-06-05  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.python/python.exp (pythonX.Y/lib-dynload/*.so): New.

--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1470,16 +1470,39 @@ if test ${build} = ${host} -a ${host} = ${target} ; then
       # Older GNU ld supports --export-dynamic but --dynamic-list it does not.
       RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
       LDFLAGS="$LDFLAGS $RDYNAMIC"
-      AC_TRY_LINK([], [],
-		  [found="-Wl,--dynamic-list"
-		   RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
-		  [RDYNAMIC="-rdynamic"
-		   LDFLAGS="$old_LDFLAGS $RDYNAMIC"
-		   AC_TRY_LINK([], [],
-			       [found="-rdynamic"],
-			       [found="no"
-				# Error on its usage by .mh file.
-				RDYNAMIC="no-rdynamic-available"])])
+      dynamic_list=false
+      if test "${have_libpython}" = no; then
+	AC_TRY_LINK([], [], [dynamic_list=true])
+      else
+	# Workaround http://bugs.python.org/issue4434 where static
+	# libpythonX.Y.a would get its symbols required for
+	# pythonX.Y/lib-dynload/*.so modules hidden by -Wl,--dynamic-list.
+	# Problem does not happen for the recommended libpythonX.Y.so linkage.
+	old_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS $PYTHON_CFLAGS"
+	AC_RUN_IFELSE(
+	  AC_LANG_PROGRAM(
+	    [#include "]${have_libpython}[/Python.h"],
+	    [int err;
+	     Py_Initialize ();
+	     err = PyRun_SimpleString ("import itertools\n");
+	     Py_Finalize ();
+	     return err == 0 ? 0 : 1;]),
+	  [dynamic_list=true], [], [true])
+	CFLAGS="$old_CFLAGS"
+      fi
+      if $dynamic_list;then
+	found="-Wl,--dynamic-list"
+	RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'
+      else
+	RDYNAMIC="-rdynamic"
+	LDFLAGS="$old_LDFLAGS $RDYNAMIC"
+	AC_TRY_LINK([], [],
+		    [found="-rdynamic"],
+		    [found="no"
+		     # Error on its usage by .mh file.
+		     RDYNAMIC="no-rdynamic-available"])
+      fi
       AC_SUBST(RDYNAMIC)
       LDFLAGS="$old_LDFLAGS"
       AC_MSG_RESULT($found)
--- a/gdb/configure
+++ b/gdb/configure
@@ -14199,7 +14199,9 @@ $as_echo_n "checking for the dynamic export flag... " >&6; }
       # Older GNU ld supports --export-dynamic but --dynamic-list it does not.
       RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
       LDFLAGS="$LDFLAGS $RDYNAMIC"
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+      dynamic_list=false
+      if test "${have_libpython}" = no; then
+	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
@@ -14211,12 +14213,51 @@ main ()
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  found="-Wl,--dynamic-list"
-		   RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'
+  dynamic_list=true
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+      else
+	# Workaround http://bugs.python.org/issue4434 where static
+	# libpythonX.Y.a would get its symbols required for
+	# pythonX.Y/lib-dynload/*.so modules hidden by -Wl,--dynamic-list.
+	# Problem does not happen for the recommended libpythonX.Y.so linkage.
+	old_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS $PYTHON_CFLAGS"
+	if test "$cross_compiling" = yes; then :
+  true
 else
-  RDYNAMIC="-rdynamic"
-		   LDFLAGS="$old_LDFLAGS $RDYNAMIC"
-		   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include "${have_libpython}/Python.h"
+int
+main ()
+{
+int err;
+	     Py_Initialize ();
+	     err = PyRun_SimpleString ("import itertools\n");
+	     Py_Finalize ();
+	     return err == 0 ? 0 : 1;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  dynamic_list=true
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+	CFLAGS="$old_CFLAGS"
+      fi
+      if $dynamic_list;then
+	found="-Wl,--dynamic-list"
+	RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'
+      else
+	RDYNAMIC="-rdynamic"
+	LDFLAGS="$old_LDFLAGS $RDYNAMIC"
+	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
@@ -14231,14 +14272,12 @@ if ac_fn_c_try_link "$LINENO"; then :
   found="-rdynamic"
 else
   found="no"
-				# Error on its usage by .mh file.
-				RDYNAMIC="no-rdynamic-available"
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
+		     # Error on its usage by .mh file.
+		     RDYNAMIC="no-rdynamic-available"
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
+      fi
 
       LDFLAGS="$old_LDFLAGS"
       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $found" >&5
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -80,3 +80,6 @@ gdb_test "source $srcdir/$subdir/source2.py" "yes"
 
 gdb_test "python print gdb.current_objfile()" "None"
 gdb_test "python print gdb.objfiles()" "\\\[\\\]"
+
+# Test http://bugs.python.org/issue4434 workaround in configure.ac
+gdb_test "python import itertools; print 'IMPOR'+'TED'" "IMPORTED" "pythonX.Y/lib-dynload/*.so"

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-06-05 12:45           ` Jan Kratochvil
@ 2010-06-08 15:23             ` Doug Evans
  2010-06-08 16:08               ` Jan Kratochvil
  0 siblings, 1 reply; 19+ messages in thread
From: Doug Evans @ 2010-06-08 15:23 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Tom Tromey, gdb-patches

On Sat, Jun 5, 2010 at 5:45 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> I was unable to test it as Fedora (13) does not ship libpythonX.Y.a (and it
> failed to build one when I tried to).  Could you test it, please?
>
> If some existing python tests were already broken I can drop this new one.
>
> No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu.
>
>
> Thanks,
> Jan
>
>
> gdb/
> 2010-06-05  Jan Kratochvil  <jan.kratochvil@redhat.com>
>
>        * configure.ac <"${have_libpython}" != no>: New workaround of
>        python#4434.
>        * configure: Regenerate.
>
> gdb/testsuite/
> 2010-06-05  Jan Kratochvil  <jan.kratochvil@redhat.com>
>
>        * gdb.python/python.exp (pythonX.Y/lib-dynload/*.so): New.

I tested this and it fixes things.  Thanks.

There is the issue of using AC_RUN_IFELSE and cross-compilation.
Python doesn't have good support for cross-compilation anyways, so
it's fine with me to punt on this for now.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-06-08 15:23             ` Doug Evans
@ 2010-06-08 16:08               ` Jan Kratochvil
  2010-06-08 16:12                 ` Doug Evans
  0 siblings, 1 reply; 19+ messages in thread
From: Jan Kratochvil @ 2010-06-08 16:08 UTC (permalink / raw)
  To: Doug Evans; +Cc: Tom Tromey, gdb-patches

On Tue, 08 Jun 2010 17:22:54 +0200, Doug Evans wrote:
> On Sat, Jun 5, 2010 at 5:45 AM, Jan Kratochvil <jan.kratochvil@redhat.com> wrote:
> > gdb/
> >        * configure.ac <"${have_libpython}" != no>: New workaround of
> >        python#4434.
> >        * configure: Regenerate.
> > gdb/testsuite/
> >        * gdb.python/python.exp (pythonX.Y/lib-dynload/*.so): New.
> 
> I tested this and it fixes things.  Thanks.

Considering it as your check-in approval, going to check it in in a moment.


> There is the issue of using AC_RUN_IFELSE and cross-compilation.
> Python doesn't have good support for cross-compilation anyways, so
> it's fine with me to punt on this for now.

In this case the current code fallbacks to the larger but more compatible
-rdynamic (and thus this my recent optimization does not take place).

+         [dynamic_list=true], [], [true])
->                                 ^^^^^^
+       if test "$cross_compiling" = yes; then :
+  true
->
kept there the pre-set value:
	dynamic_list=false


Thanks,
Jan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-06-08 16:08               ` Jan Kratochvil
@ 2010-06-08 16:12                 ` Doug Evans
  2010-06-08 17:37                   ` Jan Kratochvil
  0 siblings, 1 reply; 19+ messages in thread
From: Doug Evans @ 2010-06-08 16:12 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Tom Tromey, gdb-patches

On Tue, Jun 8, 2010 at 9:07 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Tue, 08 Jun 2010 17:22:54 +0200, Doug Evans wrote:
>> On Sat, Jun 5, 2010 at 5:45 AM, Jan Kratochvil <jan.kratochvil@redhat.com> wrote:
>> > gdb/
>> >        * configure.ac <"${have_libpython}" != no>: New workaround of
>> >        python#4434.
>> >        * configure: Regenerate.
>> > gdb/testsuite/
>> >        * gdb.python/python.exp (pythonX.Y/lib-dynload/*.so): New.
>>
>> I tested this and it fixes things.  Thanks.
>
> Considering it as your check-in approval, going to check it in in a moment.

Yep.

>> There is the issue of using AC_RUN_IFELSE and cross-compilation.
>> Python doesn't have good support for cross-compilation anyways, so
>> it's fine with me to punt on this for now.
>
> In this case the current code fallbacks to the larger but more compatible
> -rdynamic (and thus this my recent optimization does not take place).
>
> +         [dynamic_list=true], [], [true])
> ->                                 ^^^^^^
> +       if test "$cross_compiling" = yes; then :
> +  true
> ->
> kept there the pre-set value:
>        dynamic_list=false

Yeah, saw that. "works for me".

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-06-08 16:12                 ` Doug Evans
@ 2010-06-08 17:37                   ` Jan Kratochvil
  0 siblings, 0 replies; 19+ messages in thread
From: Jan Kratochvil @ 2010-06-08 17:37 UTC (permalink / raw)
  To: Doug Evans; +Cc: Tom Tromey, gdb-patches

On Tue, 08 Jun 2010 18:12:39 +0200, Doug Evans wrote:
> On Tue, Jun 8, 2010 at 9:07 AM, Jan Kratochvil
> > Considering it as your check-in approval, going to check it in in a moment.
> 
> Yep.

Checked-in:
	http://sourceware.org/ml/gdb-cvs/2010-06/msg00069.html


Thanks,
Jan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-05-16 21:08   ` Jan Kratochvil
  2010-05-27 19:58     ` Tom Tromey
@ 2010-06-13 19:58     ` Andreas Schwab
  2010-06-13 20:17       ` Andreas Schwab
  1 sibling, 1 reply; 19+ messages in thread
From: Andreas Schwab @ 2010-06-13 19:58 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: H.J. Lu, gdb-patches

Jan Kratochvil <jan.kratochvil@redhat.com> writes:

> --- a/gdb/configure.ac
> +++ b/gdb/configure.ac
> @@ -1312,6 +1312,30 @@ dnl Note that we only want this if we are both native (host == target),
>  dnl and not doing a canadian cross build (build == host).
>  
>  if test ${build} = ${host} -a ${host} = ${target} ; then
> +   if test "$GCC" = "yes" ; then
> +      # The dynamically loaded libthread_db needs access to symbols in the gdb
> +      # executable.  Older GNU ld supports --export-dynamic but --dynamic-list
> +      # may not be supported there.
> +      AC_MSG_CHECKING(for the dynamic export flag)

Why only for non-canadian-cross builds?  Previously -rdynamic was used
for any native configuration, now you can no longer cross-build a
working gdb.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-06-13 19:58     ` [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list Andreas Schwab
@ 2010-06-13 20:17       ` Andreas Schwab
  2010-06-15 17:31         ` Tom Tromey
  0 siblings, 1 reply; 19+ messages in thread
From: Andreas Schwab @ 2010-06-13 20:17 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: H.J. Lu, gdb-patches

Tested on ppc-linux.

Andreas.

2010-06-13  Andreas Schwab  <schwab@linux-m68k.org>

	* configure.ac: Check for RDYNAMIC also for cross builds.
	* configure: Regenerate.

--- configure.ac.~1.122.~	2010-06-12 23:13:19.000000000 +0200
+++ configure.ac	2010-06-13 22:09:54.000000000 +0200
@@ -1453,14 +1453,7 @@ aix*)
   ;;
 esac
 
-
-dnl For certain native configurations, we need to check whether thread
-dnl support can be built in or not.
-dnl
-dnl Note that we only want this if we are both native (host == target),
-dnl and not doing a canadian cross build (build == host).
-
-if test ${build} = ${host} -a ${host} = ${target} ; then
+if test "${gdb_native}" = yes; then
    if test "$GCC" = "yes" ; then
       # The dynamically loaded libthread_db needs access to symbols in the gdb
       # executable.  Older GNU ld supports --export-dynamic but --dynamic-list
@@ -1507,7 +1500,15 @@ if test ${build} = ${host} -a ${host} =
       LDFLAGS="$old_LDFLAGS"
       AC_MSG_RESULT($found)
    fi
+fi
 
+dnl For certain native configurations, we need to check whether thread
+dnl support can be built in or not.
+dnl
+dnl Note that we only want this if we are both native (host == target),
+dnl and not doing a canadian cross build (build == host).
+
+if test ${build} = ${host} -a ${host} = ${target} ; then
    case ${host_os} in
    hpux*)
       AC_MSG_CHECKING(for HPUX/OSF thread support)

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-06-13 20:17       ` Andreas Schwab
@ 2010-06-15 17:31         ` Tom Tromey
  2010-06-15 19:09           ` Jan Kratochvil
  2010-06-15 20:36           ` Jan Kratochvil
  0 siblings, 2 replies; 19+ messages in thread
From: Tom Tromey @ 2010-06-15 17:31 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Jan Kratochvil, H.J. Lu, gdb-patches

>>>>> "Andreas" == Andreas Schwab <schwab@linux-m68k.org> writes:

Andreas> 2010-06-13  Andreas Schwab  <schwab@linux-m68k.org>
Andreas> 	* configure.ac: Check for RDYNAMIC also for cross builds.
Andreas> 	* configure: Regenerate.

This is ok.  Thanks.

Tom

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-06-15 17:31         ` Tom Tromey
@ 2010-06-15 19:09           ` Jan Kratochvil
  2010-06-15 20:36           ` Jan Kratochvil
  1 sibling, 0 replies; 19+ messages in thread
From: Jan Kratochvil @ 2010-06-15 19:09 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Andreas Schwab, H.J. Lu, gdb-patches

On Tue, 15 Jun 2010 19:31:01 +0200, Tom Tromey wrote:
> >>>>> "Andreas" == Andreas Schwab <schwab@linux-m68k.org> writes:
> 
> Andreas> 2010-06-13  Andreas Schwab  <schwab@linux-m68k.org>
> Andreas> 	* configure.ac: Check for RDYNAMIC also for cross builds.
> Andreas> 	* configure: Regenerate.
> 
> This is ok.  Thanks.

I am preparing a modification of this patch but this patch is already
a regression fix, just incomplete.  I will post the second part as a second
patch on top of it.


Thanks,
Jan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-06-15 17:31         ` Tom Tromey
  2010-06-15 19:09           ` Jan Kratochvil
@ 2010-06-15 20:36           ` Jan Kratochvil
  2010-06-21 18:26             ` Tom Tromey
  1 sibling, 1 reply; 19+ messages in thread
From: Jan Kratochvil @ 2010-06-15 20:36 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Andreas Schwab, H.J. Lu, gdb-patches

On Tue, 15 Jun 2010 19:31:01 +0200, Tom Tromey wrote:
> >>>>> "Andreas" == Andreas Schwab <schwab@linux-m68k.org> writes:
> 
> Andreas> 2010-06-13  Andreas Schwab  <schwab@linux-m68k.org>
> Andreas> 	* configure.ac: Check for RDYNAMIC also for cross builds.
> Andreas> 	* configure: Regenerate.
> 
> This is ok.  Thanks.

A patch on top of this one is attached.

Original code had `-rdynamic' hardcoded in the .mh files.  .mh files get
included iff we have ${gdb_native}.  It means two things:

(1) The `-rdynamic' upgrade to `-Wl,--dynamic-list' makes sense only iff
    we have ${gdb_native}.

(2) Iff we have ${gdb_native} we should always provide at least `-rdynamic'.
    Current code with my change for non-$GCC configurations provided empty
    RDYNAMIC and thus breaking non-$GCC threading support.
    (OTOH there is a notice -rdynamic' is required only for $GCC thus probably
    nothing got broken.)

Moreover as the functionality is really tested (by either AC_RUN_IFELSE or
AC_TRY_LINK) it should not be needed to check $GCC.  On non-$GCC the
functionality test should always fail anyway.  Removed the $GCC check.

This patch is more a cleanup only / safer change from the original code before
`-Wl,--dynamic-list' introduction.  I am not aware on which configuration this
patch below can change anything.  No problem dropping it.

Tested build on x86_64-fedora13-linux-gnu and x86_64-rhel4-linux-gnu.


Thanks,
Jan


2010-06-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* configure.ac: Always set RDYNAMIC at least as `-rdynamic'.
	* configure: Regenerate.

--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1453,54 +1453,47 @@ aix*)
   ;;
 esac
 
+AC_MSG_CHECKING(for the dynamic export flag)
+dynamic_list=false
 if test "${gdb_native}" = yes; then
-   if test "$GCC" = "yes" ; then
-      # The dynamically loaded libthread_db needs access to symbols in the gdb
-      # executable.  Older GNU ld supports --export-dynamic but --dynamic-list
-      # may not be supported there.
-      AC_MSG_CHECKING(for the dynamic export flag)
-      old_LDFLAGS="$LDFLAGS"
-      # Older GNU ld supports --export-dynamic but --dynamic-list it does not.
-      RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
-      LDFLAGS="$LDFLAGS $RDYNAMIC"
-      dynamic_list=false
-      if test "${have_libpython}" = no; then
-	AC_TRY_LINK([], [], [dynamic_list=true])
-      else
-	# Workaround http://bugs.python.org/issue4434 where static
-	# libpythonX.Y.a would get its symbols required for
-	# pythonX.Y/lib-dynload/*.so modules hidden by -Wl,--dynamic-list.
-	# Problem does not happen for the recommended libpythonX.Y.so linkage.
-	old_CFLAGS="$CFLAGS"
-	CFLAGS="$CFLAGS $PYTHON_CFLAGS"
-	AC_RUN_IFELSE(
-	  AC_LANG_PROGRAM(
-	    [#include "]${have_libpython}[/Python.h"],
-	    [int err;
-	     Py_Initialize ();
-	     err = PyRun_SimpleString ("import itertools\n");
-	     Py_Finalize ();
-	     return err == 0 ? 0 : 1;]),
-	  [dynamic_list=true], [], [true])
-	CFLAGS="$old_CFLAGS"
-      fi
-      if $dynamic_list;then
-	found="-Wl,--dynamic-list"
-	RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'
-      else
-	RDYNAMIC="-rdynamic"
-	LDFLAGS="$old_LDFLAGS $RDYNAMIC"
-	AC_TRY_LINK([], [],
-		    [found="-rdynamic"],
-		    [found="no"
-		     # Error on its usage by .mh file.
-		     RDYNAMIC="no-rdynamic-available"])
-      fi
-      AC_SUBST(RDYNAMIC)
-      LDFLAGS="$old_LDFLAGS"
-      AC_MSG_RESULT($found)
+   # The dynamically loaded libthread_db needs access to symbols in the gdb
+   # executable.  Older GNU ld supports --export-dynamic but --dynamic-list
+   # may not be supported there.
+   old_LDFLAGS="$LDFLAGS"
+   # Older GNU ld supports --export-dynamic but --dynamic-list it does not.
+   RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
+   LDFLAGS="$LDFLAGS $RDYNAMIC"
+   if test "${have_libpython}" = no; then
+     AC_TRY_LINK([], [], [dynamic_list=true])
+   else
+     # Workaround http://bugs.python.org/issue4434 where static
+     # libpythonX.Y.a would get its symbols required for
+     # pythonX.Y/lib-dynload/*.so modules hidden by -Wl,--dynamic-list.
+     # Problem does not happen for the recommended libpythonX.Y.so linkage.
+     old_CFLAGS="$CFLAGS"
+     CFLAGS="$CFLAGS $PYTHON_CFLAGS"
+     AC_RUN_IFELSE(
+       AC_LANG_PROGRAM(
+         [#include "]${have_libpython}[/Python.h"],
+         [int err;
+          Py_Initialize ();
+          err = PyRun_SimpleString ("import itertools\n");
+          Py_Finalize ();
+          return err == 0 ? 0 : 1;]),
+       [dynamic_list=true], [], [true])
+     CFLAGS="$old_CFLAGS"
    fi
+   LDFLAGS="$old_LDFLAGS"
+fi
+if $dynamic_list; then
+  found="-Wl,--dynamic-list"
+  RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'
+else
+  found="-rdynamic"
+  RDYNAMIC="-rdynamic"
 fi
+AC_SUBST(RDYNAMIC)
+AC_MSG_RESULT($found)
 
 dnl For certain native configurations, we need to check whether thread
 dnl support can be built in or not.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-06-15 20:36           ` Jan Kratochvil
@ 2010-06-21 18:26             ` Tom Tromey
  2010-06-23 10:13               ` Jan Kratochvil
  0 siblings, 1 reply; 19+ messages in thread
From: Tom Tromey @ 2010-06-21 18:26 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Andreas Schwab, H.J. Lu, gdb-patches

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> 2010-06-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan> 	* configure.ac: Always set RDYNAMIC at least as `-rdynamic'.
Jan> 	* configure: Regenerate.

This is ok.  Thanks.

Tom

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list
  2010-06-21 18:26             ` Tom Tromey
@ 2010-06-23 10:13               ` Jan Kratochvil
  0 siblings, 0 replies; 19+ messages in thread
From: Jan Kratochvil @ 2010-06-23 10:13 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Andreas Schwab, H.J. Lu, gdb-patches

On Mon, 21 Jun 2010 20:26:30 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> 
> Jan> 2010-06-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
> Jan> 	* configure.ac: Always set RDYNAMIC at least as `-rdynamic'.
> Jan> 	* configure: Regenerate.
> 
> This is ok.  Thanks.

Checked-in:
	http://sourceware.org/ml/gdb-cvs/2010-06/msg00155.html


Thanks,
Jan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [patch] -Wl,--dynamic-list: Test also PYTHON_LIBS, not just PYTHON_CFLAGS  [Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list]
  2010-06-05  2:48         ` Doug Evans
  2010-06-05 12:45           ` Jan Kratochvil
@ 2012-01-12 19:28           ` Jan Kratochvil
  1 sibling, 0 replies; 19+ messages in thread
From: Jan Kratochvil @ 2012-01-12 19:28 UTC (permalink / raw)
  To: Doug Evans; +Cc: Tom Tromey, gdb-patches

Hello Doug,

On Sat, 05 Jun 2010 04:48:33 +0200, Doug Evans wrote:
> I've been playing with this a bit and got the following:
> 
>  "ImportError: /usr/grte/v1/k8-linux/lib/python2.4/lib-dynload/itertools.so:
> undefined symbol: PyExc_StopIteration"
> 
> when I did "import itertools".
> 
> I was statically linking libpythonX.Y.a.

I found current FSF GDB HEAD always uses -rdynamic with libpython as it
falsely thinks -Wl,--dynamic-list is incompatible:

configure:14652: gcc -o conftest -m64 -ggdb2 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4  -fno-strict-aliasing -DNDEBUG -fwrapv    -lmcheck -Wl,--dynamic-list=./proc-service.list conftest.c -ldl -lncurses -lz -lm    >&5
/tmp/ccgMCqKR.o: In function `main':
/home/jkratoch/redhat/gdb-clean/gdb/conftest.c:212: undefined reference to `Py_Initialize'
/home/jkratoch/redhat/gdb-clean/gdb/conftest.c:213: undefined reference to `PyRun_SimpleStringFlags'
/home/jkratoch/redhat/gdb-clean/gdb/conftest.c:214: undefined reference to `Py_Finalize'

It does not make a difference now as with Python it would use -Xlinker
-export-dynamic on top of it anyway due to Python issue10112.  But after it
gets fixed in Python GDB could become smaller (+its ld and ld.so faster) with
this patch.

It is mostly obvious it should use all the PYTHON_* compilation flags and not
just PYTHON_CFLAGS.  But I would welcome a test on your static libpython.a
config if it does not break anything.


Thanks,
Jan


2012-01-12  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* configure.ac [${gdb_native} && ${have_libpython}]: Use also
	PYTHON_CPPFLAGS and PYTHON_LIBS.
	* configure: Regenerate.

--- gdb/configure	2 Jan 2012 02:28:56 -0000	1.336
+++ gdb/configure	12 Jan 2012 18:43:25 -0000
@@ -14631,6 +14631,10 @@ rm -f core conftest.err conftest.$ac_obj
      # Problem does not happen for the recommended libpythonX.Y.so linkage.
      old_CFLAGS="$CFLAGS"
      CFLAGS="$CFLAGS $PYTHON_CFLAGS"
+     old_CPPFLAGS="$CPPFLAGS"
+     CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
+     old_LIBS="$LIBS"
+     LIBS="$LIBS $PYTHON_LIBS"
      if test "$cross_compiling" = yes; then :
   true
 else
@@ -14657,6 +14661,8 @@ rm -f core *.core core.conftest.* gmon.o
 fi
 
      CFLAGS="$old_CFLAGS"
+     CPPFLAGS="$old_CPPFLAGS"
+     LIBS="$old_LIBS"
    fi
    LDFLAGS="$old_LDFLAGS"
 fi
--- gdb/configure.ac	4 Jan 2012 08:17:00 -0000	1.152
+++ gdb/configure.ac	12 Jan 2012 18:43:27 -0000
@@ -1576,6 +1576,10 @@ if test "${gdb_native}" = yes; then
      # Problem does not happen for the recommended libpythonX.Y.so linkage.
      old_CFLAGS="$CFLAGS"
      CFLAGS="$CFLAGS $PYTHON_CFLAGS"
+     old_CPPFLAGS="$CPPFLAGS"
+     CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
+     old_LIBS="$LIBS"
+     LIBS="$LIBS $PYTHON_LIBS"
      AC_RUN_IFELSE(
        AC_LANG_PROGRAM(
          [#include "]${have_libpython}[/Python.h"],
@@ -1586,6 +1590,8 @@ if test "${gdb_native}" = yes; then
           return err == 0 ? 0 : 1;]),
        [dynamic_list=true], [], [true])
      CFLAGS="$old_CFLAGS"
+     CPPFLAGS="$old_CPPFLAGS"
+     LIBS="$old_LIBS"
    fi
    LDFLAGS="$old_LDFLAGS"
 fi

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2012-01-12 18:48 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-13 13:27 [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list Jan Kratochvil
2010-05-13 15:47 ` H.J. Lu
2010-05-16 21:08   ` Jan Kratochvil
2010-05-27 19:58     ` Tom Tromey
2010-05-28 23:11       ` Jan Kratochvil
2010-06-05  2:48         ` Doug Evans
2010-06-05 12:45           ` Jan Kratochvil
2010-06-08 15:23             ` Doug Evans
2010-06-08 16:08               ` Jan Kratochvil
2010-06-08 16:12                 ` Doug Evans
2010-06-08 17:37                   ` Jan Kratochvil
2012-01-12 19:28           ` [patch] -Wl,--dynamic-list: Test also PYTHON_LIBS, not just PYTHON_CFLAGS [Re: [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list] Jan Kratochvil
2010-06-13 19:58     ` [patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list Andreas Schwab
2010-06-13 20:17       ` Andreas Schwab
2010-06-15 17:31         ` Tom Tromey
2010-06-15 19:09           ` Jan Kratochvil
2010-06-15 20:36           ` Jan Kratochvil
2010-06-21 18:26             ` Tom Tromey
2010-06-23 10:13               ` Jan Kratochvil

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).