Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA PATCH] Fix --dynamic-list test's workaround for http://bugs.python.org/issue4434.
@ 2013-03-07 23:14 Pedro Alves
  2013-03-11 18:14 ` Jan Kratochvil
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2013-03-07 23:14 UTC (permalink / raw)
  To: gdb-patches

After a chat on IRC, I noticed that my gdb binary was linking with
-Wl,--export-dynamic instead of the better -Wl,--dynamic-list.

Turns out the link/run test that checks for static python has a bug:

    configure:11856: checking for the dynamic export flag
    configure:11909: gcc -o conftest -g3 -O0 -fno-strict-aliasing -DNDEBUG -fwrapv -static-libstdc++ -static-libgcc -Wl,--dynamic-list=../../src/gdb/proc-service.list conftest.c -ldl -lncurses -lz -lm >&5
    /tmp/ccHIJn3p.o: In function `main':
    /home/pedro/gdb/mygit/build/gdb/conftest.c:173: undefined reference to `Py_Initialize'
    /home/pedro/gdb/mygit/build/gdb/conftest.c:174: undefined reference to `PyRun_SimpleStringFlags'
    /home/pedro/gdb/mygit/build/gdb/conftest.c:175: undefined reference to `Py_Finalize'
    collect2: error: ld returned 1 exit status
    configure:11909: $? = 1
    configure: program exited with status 1
    configure: failed program was:

... it doesn't actually link with -lpython.

This looks to me to be the correct fix.  I now get:

    configure:11856: checking for the dynamic export flag
    configure:11910: gcc -o conftest -g3 -O0  -fno-strict-aliasing -DNDEBUG -fwrapv   -static-libstdc++ -static-libgcc  -Wl,--dynamic-list=../../src/gdb/proc-service.list -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic conftest.c -ldl -lncurses -lz -lm    >&5
    configure:11910: $? = 0
    configure:11910: ./conftest
    configure:11910: $? = 0
    configure:11929: result: -Wl,--dynamic-list

OK?

gdb/
2013-03-07  Pedro Alves  <palves@redhat.com>

	* configure: Regenerate.
	* configure.ac (check dynamic export flag): Link python test with
	$PYTHON_LIBS.
---
 gdb/configure    |    1 +
 gdb/configure.ac |    1 +
 2 files changed, 2 insertions(+)

diff --git a/gdb/configure b/gdb/configure
index c54709c..68cd436 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -11888,6 +11888,7 @@ rm -f core conftest.err conftest.$ac_objext \
      # Problem does not happen for the recommended libpythonX.Y.so linkage.
      old_CFLAGS="$CFLAGS"
      CFLAGS="$CFLAGS $PYTHON_CFLAGS"
+     LDFLAGS="$LDFLAGS $PYTHON_LIBS"
      if test "$cross_compiling" = yes; then :
   true
 else
diff --git a/gdb/configure.ac b/gdb/configure.ac
index e501766..71c5efb 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1687,6 +1687,7 @@ if test "${gdb_native}" = yes; then
      # Problem does not happen for the recommended libpythonX.Y.so linkage.
      old_CFLAGS="$CFLAGS"
      CFLAGS="$CFLAGS $PYTHON_CFLAGS"
+     LDFLAGS="$LDFLAGS $PYTHON_LIBS"
      AC_RUN_IFELSE(
        AC_LANG_PROGRAM(
          [#include "]${have_libpython}[/Python.h"],


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

* Re: [RFA PATCH] Fix --dynamic-list test's workaround for http://bugs.python.org/issue4434.
  2013-03-07 23:14 [RFA PATCH] Fix --dynamic-list test's workaround for http://bugs.python.org/issue4434 Pedro Alves
@ 2013-03-11 18:14 ` Jan Kratochvil
  2013-03-11 18:35   ` Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2013-03-11 18:14 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Fri, 08 Mar 2013 00:14:00 +0100, Pedro Alves wrote:
> After a chat on IRC, I noticed that my gdb binary was linking with
> -Wl,--export-dynamic instead of the better -Wl,--dynamic-list.

I agree with this fix (with the bit LDFLAGS -> LIBS).

But in practice it does not change anything as the full linking commandline
also contains
	LINKFORSHARED=-Xlinker -export-dynamic
from
	/usr/lib/python2.7/config/Makefile
which overrides it:
	../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a  ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a    -ldl -ldl -lncurses -lz -lm    -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic -lexpat -llzma ../libiberty/libiberty.a  build-gnulib/import/libgnu.a -ldl -Wl,--dynamic-list=./proc-service.list

The real fix to reduce the stripped GDB binary by 1MB of .dynsym back again
after it was regressed by Python would be to drop gdb/proc-service.list, add
gcc parameter -fvisibility=hidden and mark all the exported symbols (currently
in gdb/proc-service.list) by __attribute__ ((visibility ("default"))).

At least I hope that -fvisibility=hidden won't break Python on the other hand.


Thanks,
Jan


gdb/
2013-03-11  Pedro Alves  <palves@redhat.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	* configure: Regenerate.
	* configure.ac (check dynamic export flag): Link python test with
	$PYTHON_LIBS.

diff --git a/gdb/configure.ac b/gdb/configure.ac
index e501766..c17f587 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1687,6 +1687,8 @@ 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_LIBS="$LIBS"
+     LIBS="$LIBS $PYTHON_LIBS"
      AC_RUN_IFELSE(
        AC_LANG_PROGRAM(
          [#include "]${have_libpython}[/Python.h"],
@@ -1696,6 +1698,7 @@ if test "${gdb_native}" = yes; then
           Py_Finalize ();
           return err == 0 ? 0 : 1;]),
        [dynamic_list=true], [], [true])
+     LIBS="$old_LIBS"
      CFLAGS="$old_CFLAGS"
    fi
    LDFLAGS="$old_LDFLAGS"


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

* Re: [RFA PATCH] Fix --dynamic-list test's workaround for http://bugs.python.org/issue4434.
  2013-03-11 18:14 ` Jan Kratochvil
@ 2013-03-11 18:35   ` Pedro Alves
  2013-03-11 18:52     ` [commit] " Jan Kratochvil
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2013-03-11 18:35 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

On 03/11/2013 06:14 PM, Jan Kratochvil wrote:
> On Fri, 08 Mar 2013 00:14:00 +0100, Pedro Alves wrote:
>> After a chat on IRC, I noticed that my gdb binary was linking with
>> -Wl,--export-dynamic instead of the better -Wl,--dynamic-list.
> 
> I agree with this fix (with the bit LDFLAGS -> LIBS).

Ah yes, LIBS, of course.  Please go ahead.

> 
> But in practice it does not change anything as the full linking commandline
> also contains
> 	LINKFORSHARED=-Xlinker -export-dynamic
> from
> 	/usr/lib/python2.7/config/Makefile
> which overrides it:
> 	../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a  ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a    -ldl -ldl -lncurses -lz -lm    -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic -lexpat -llzma ../libiberty/libiberty.a  build-gnulib/import/libgnu.a -ldl -Wl,--dynamic-list=./proc-service.list

Bummer.

> The real fix to reduce the stripped GDB binary by 1MB of .dynsym back again
> after it was regressed by Python would be to drop gdb/proc-service.list, add
> gcc parameter -fvisibility=hidden and mark all the exported symbols (currently
> in gdb/proc-service.list) by __attribute__ ((visibility ("default"))).
> 
> At least I hope that -fvisibility=hidden won't break Python on the other hand.

Did you try:

- RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'
+ RDYNAMIC='-Wl,--no-export-dynamic -Wl,--dynamic-list=$(srcdir)/proc-service.list'

?

-- 
Pedro Alves


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

* [commit] [RFA PATCH] Fix --dynamic-list test's workaround for http://bugs.python.org/issue4434.
  2013-03-11 18:35   ` Pedro Alves
@ 2013-03-11 18:52     ` Jan Kratochvil
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kratochvil @ 2013-03-11 18:52 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Mon, 11 Mar 2013 19:35:33 +0100, Pedro Alves wrote:
> Ah yes, LIBS, of course.  Please go ahead.

Checked in:
	http://sourceware.org/ml/gdb-cvs/2013-03/msg00095.html


> > 	../readline/libreadline.a ../opcodes/libopcodes.a ../bfd/libbfd.a  ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a    -ldl -ldl -lncurses -lz -lm    -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic -lexpat -llzma ../libiberty/libiberty.a  build-gnulib/import/libgnu.a -ldl -Wl,--dynamic-list=./proc-service.list
> 
> Bummer.
> 
> > The real fix to reduce the stripped GDB binary by 1MB of .dynsym back again
> > after it was regressed by Python would be to drop gdb/proc-service.list, add
> > gcc parameter -fvisibility=hidden and mark all the exported symbols (currently
> > in gdb/proc-service.list) by __attribute__ ((visibility ("default"))).
> > 
> > At least I hope that -fvisibility=hidden won't break Python on the other hand.
> 
> Did you try:
> 
> - RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'
> + RDYNAMIC='-Wl,--no-export-dynamic -Wl,--dynamic-list=$(srcdir)/proc-service.list'
> 
> ?

I did not try as that would break the Python's intention of LINKFORSHARED's
-export-dynamic.  While I hope -fvisibility=hidden would not break it as it
applies only to cc1 and not ld.

This is all sure primarily a Python bug breaking any app it links with it,
this discussion is just about how to workaround it when they were unable to
fix it in 2.5 years:
	http://bugs.python.org/issue10112


Jan


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

end of thread, other threads:[~2013-03-11 18:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-07 23:14 [RFA PATCH] Fix --dynamic-list test's workaround for http://bugs.python.org/issue4434 Pedro Alves
2013-03-11 18:14 ` Jan Kratochvil
2013-03-11 18:35   ` Pedro Alves
2013-03-11 18:52     ` [commit] " Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox