public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug python/26832] New: Fix detection for embedded libpython.a with python3
@ 2020-11-02 15:15 romain.geissler at amadeus dot com
  2020-11-02 23:43 ` [Bug python/26832] " romain.geissler at amadeus dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: romain.geissler at amadeus dot com @ 2020-11-02 15:15 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26832

            Bug ID: 26832
           Summary: Fix detection for embedded libpython.a with python3
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: python
          Assignee: unassigned at sourceware dot org
          Reporter: romain.geissler at amadeus dot com
  Target Milestone: ---

Hi,

I build gdb on Linux with a statically embedded libpython.a rather than the
recommanded .so way. It seems like the resulting gdb fails to load any module
using dynamic link, like for example "import math".

It's clear that the "problem" is the fact of using -rdynamic vs --dynamic-list.
Actually this "problem" was fixed a long time ago, and we can see in
configure.ac something like:

     AC_RUN_IFELSE(
       [AC_LANG_PROGRAM(
         [#include "Python.h"],
         [int err;
          Py_Initialize ();
          err = PyRun_SimpleString ("import itertools\n");
          Py_Finalize ();
          return err == 0 ? 0 : 1;])],
       [dynamic_list=true], [], [true])

to check whether python can import something without "-rdynamic". However with
python 3 (at least in my case it was python 3.9, but I could also check with
another python 3.4 that it was also the case) itertools seems to be a builtin,
so doesn't actually load any.so.

Do you think this "import itertools" shall be replaced by another module which
we know is a real dynamic python module on both python 2 and python 3 ? I
propose to replace it by "import ctypes" instead which seems to be a modules in
both major python releases.

Cheers,
Romain

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug python/26832] Fix detection for embedded libpython.a with python3
  2020-11-02 15:15 [Bug python/26832] New: Fix detection for embedded libpython.a with python3 romain.geissler at amadeus dot com
@ 2020-11-02 23:43 ` romain.geissler at amadeus dot com
  2020-11-03  1:12 ` simark at simark dot ca
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: romain.geissler at amadeus dot com @ 2020-11-02 23:43 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26832

--- Comment #1 from Romain Geissler <romain.geissler at amadeus dot com> ---
FYI: I tested the following patch, which worked for me (I tested only a
statically linked libpython, using python 3.9 and gdb 10 on Linux):

--- gdb/configure
+++ gdb/configure
@@ -16159,7 +16159,7 @@
 {
 int err;  
           Py_Initialize ();
-          err = PyRun_SimpleString ("import itertools\n");
+          err = PyRun_SimpleString ("import ctypes\n");
           Py_Finalize ();
           return err == 0 ? 0 : 1;
   ;
--- gdb/configure.ac
+++ gdb/configure.ac
@@ -1599,7 +1599,7 @@
          [#include "Python.h"],
          [int err;
           Py_Initialize ();
-          err = PyRun_SimpleString ("import itertools\n");
+          err = PyRun_SimpleString ("import ctypes\n");
           Py_Finalize ();
           return err == 0 ? 0 : 1;])],
        [dynamic_list=true], [], [true])


Cheers,
Romain

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug python/26832] Fix detection for embedded libpython.a with python3
  2020-11-02 15:15 [Bug python/26832] New: Fix detection for embedded libpython.a with python3 romain.geissler at amadeus dot com
  2020-11-02 23:43 ` [Bug python/26832] " romain.geissler at amadeus dot com
@ 2020-11-03  1:12 ` simark at simark dot ca
  2020-11-06 18:02 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: simark at simark dot ca @ 2020-11-03  1:12 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26832

Simon Marchi <simark at simark dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simark at simark dot ca

--- Comment #2 from Simon Marchi <simark at simark dot ca> ---
Thanks.  Note that we don't do patch review on Bugzilla, so if you'd like your
patch to be considered for merging, please send it to the gdb-patches mailing
list following the guidelines here:

https://sourceware.org/gdb/wiki/ContributionChecklist

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug python/26832] Fix detection for embedded libpython.a with python3
  2020-11-02 15:15 [Bug python/26832] New: Fix detection for embedded libpython.a with python3 romain.geissler at amadeus dot com
  2020-11-02 23:43 ` [Bug python/26832] " romain.geissler at amadeus dot com
  2020-11-03  1:12 ` simark at simark dot ca
@ 2020-11-06 18:02 ` cvs-commit at gcc dot gnu.org
  2020-11-06 18:03 ` cvs-commit at gcc dot gnu.org
  2020-12-05 13:00 ` romain.geissler at amadeus dot com
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-11-06 18:02 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26832

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Burgess <aburgess@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3fed4c0b7adeae7b2bfd9aa59818bb8f3f381031

commit 3fed4c0b7adeae7b2bfd9aa59818bb8f3f381031
Author: Romain Geissler <romain.geissler@amadeus.com>
Date:   Fri Nov 6 17:47:21 2020 +0000

    gdb: better static python detection in configure machinery

    In python 3, itertools is a builtin module, so whether or not the
    python you link against is a shared or a static one, importing it
    works.

    Change the import test to use ctypes which is a dynamic module in both
    python 2 and 3.

    gdb/ChangeLog:

            PR python/26832
            * configure: Regenerate.
            * configure.ac: Check for python modules ctypes instead of
            itertools.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug python/26832] Fix detection for embedded libpython.a with python3
  2020-11-02 15:15 [Bug python/26832] New: Fix detection for embedded libpython.a with python3 romain.geissler at amadeus dot com
                   ` (2 preceding siblings ...)
  2020-11-06 18:02 ` cvs-commit at gcc dot gnu.org
@ 2020-11-06 18:03 ` cvs-commit at gcc dot gnu.org
  2020-12-05 13:00 ` romain.geissler at amadeus dot com
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-11-06 18:03 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26832

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-10-branch branch has been updated by Andrew Burgess
<aburgess@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=60714c0fc0cc7cc873440b4b9362c11f28daf585

commit 60714c0fc0cc7cc873440b4b9362c11f28daf585
Author: Romain Geissler <romain.geissler@amadeus.com>
Date:   Fri Nov 6 17:47:21 2020 +0000

    gdb: better static python detection in configure machinery

    In python 3, itertools is a builtin module, so whether or not the
    python you link against is a shared or a static one, importing it
    works.

    Change the import test to use ctypes which is a dynamic module in both
    python 2 and 3.

    gdb/ChangeLog:

            PR python/26832
            * configure: Regenerate.
            * configure.ac: Check for python modules ctypes instead of
            itertools.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug python/26832] Fix detection for embedded libpython.a with python3
  2020-11-02 15:15 [Bug python/26832] New: Fix detection for embedded libpython.a with python3 romain.geissler at amadeus dot com
                   ` (3 preceding siblings ...)
  2020-11-06 18:03 ` cvs-commit at gcc dot gnu.org
@ 2020-12-05 13:00 ` romain.geissler at amadeus dot com
  4 siblings, 0 replies; 6+ messages in thread
From: romain.geissler at amadeus dot com @ 2020-12-05 13:00 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26832

Romain Geissler <romain.geissler at amadeus dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Romain Geissler <romain.geissler at amadeus dot com> ---
Fixed in the master branch + cherry-picked in the gdb 10 branch.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2020-12-05 13:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-02 15:15 [Bug python/26832] New: Fix detection for embedded libpython.a with python3 romain.geissler at amadeus dot com
2020-11-02 23:43 ` [Bug python/26832] " romain.geissler at amadeus dot com
2020-11-03  1:12 ` simark at simark dot ca
2020-11-06 18:02 ` cvs-commit at gcc dot gnu.org
2020-11-06 18:03 ` cvs-commit at gcc dot gnu.org
2020-12-05 13:00 ` romain.geissler at amadeus dot com

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