Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v1] Fix wrong build tree in python.exp path on AIX
@ 2026-07-30  5:48 Aditya Vidyadhar Kamath
  2026-08-21 15:43 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Aditya Vidyadhar Kamath @ 2026-07-30  5:48 UTC (permalink / raw)
  To: ulrich.weigand, simon.marchi, tom
  Cc: gdb-patches, Aditya.Kamath1, sangamesh.swamy, PRAJWAL.B.MEHENDARKAR

From: Aditya Kamath <Aditya.Kamath1@ibm.com>

Python records the path to the export file in LINKFORSHARED sysconfig
variable as a build tree relative path: -Wl,bE:Modules/python.exp

But this will fail in AIX. When configure runs python-config.py --ldflags to test for
libpython, the linker cannot find Modules/python.exp, the link test
fails, and GDB is built without Python support.

So in this patch we fix the same by replacing the relative path with LIBPL/python.exp (e.g.
/opt/freeware/lib64/python3.12/config-3.12/python.exp) on AIX only,
where LIBPL is the installed config directory that already contains
the file.
---
 gdb/python/python-config.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/gdb/python/python-config.py b/gdb/python/python-config.py
index 061eae1ac64..7190f799b0a 100644
--- a/gdb/python/python-config.py
+++ b/gdb/python/python-config.py
@@ -78,5 +78,16 @@ for opt in opt_flags:
                 elif os.name == "nt":
                     libs.insert(0, "-L" + os.path.normpath(sys.prefix) + "/libs")
             if getvar("LINKFORSHARED") is not None:
-                libs.extend(getvar("LINKFORSHARED").split())
+                linkforshared = getvar("LINKFORSHARED")
+                # On AIX, LINKFORSHARED contains "-Wl,-bE:Modules/python.exp"
+                # where "Modules/python.exp" is a build-tree-relative path that
+                # does not exist on installed systems.  Replace it with the
+                # absolute installed path using LIBPL, which always points to
+                # the pythonX.Y/config-X.Y directory where python.exp is kept.
+                if sys.platform.startswith("aix") and getvar("LIBPL") is not None:
+                    linkforshared = linkforshared.replace(
+                        "Modules/python.exp",
+                        getvar("LIBPL") + "/python.exp",
+                    )
+                libs.extend(linkforshared.split())
         print(to_unix_path(" ".join(libs)))
-- 
2.51.2


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

* Re: [PATCH v1] Fix wrong build tree in python.exp path on AIX
  2026-07-30  5:48 [PATCH v1] Fix wrong build tree in python.exp path on AIX Aditya Vidyadhar Kamath
@ 2026-08-21 15:43 ` Tom Tromey
  2026-08-24  6:48   ` Aditya Kamath
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2026-08-21 15:43 UTC (permalink / raw)
  To: Aditya Vidyadhar Kamath
  Cc: ulrich.weigand, simon.marchi, tom, gdb-patches, Aditya.Kamath1,
	sangamesh.swamy, PRAJWAL.B.MEHENDARKAR

>>>>> Aditya Vidyadhar Kamath <akamath996@gmail.com> writes:

> From: Aditya Kamath <Aditya.Kamath1@ibm.com>
> Python records the path to the export file in LINKFORSHARED sysconfig
> variable as a build tree relative path: -Wl,bE:Modules/python.exp

> But this will fail in AIX. When configure runs python-config.py --ldflags to test for
> libpython, the linker cannot find Modules/python.exp, the link test
> fails, and GDB is built without Python support.

> So in this patch we fix the same by replacing the relative path with LIBPL/python.exp (e.g.
> /opt/freeware/lib64/python3.12/config-3.12/python.exp) on AIX only,
> where LIBPL is the installed config directory that already contains
> the file.

Thanks for the patch.

I don't really understand this, but (1) I didn't see any other
commentary on it and (2) it seems to be AIX-specific.

So, I think it is ok.  I appreciate the comment in there.

It's fine if you want to apply this to the gdb-18 branch as well.

Approved-By: Tom Tromey <tom@tromey.com>

Tom

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

* RE: [PATCH v1] Fix wrong build tree in python.exp path on AIX
  2026-08-21 15:43 ` Tom Tromey
@ 2026-08-24  6:48   ` Aditya Kamath
  0 siblings, 0 replies; 3+ messages in thread
From: Aditya Kamath @ 2026-08-24  6:48 UTC (permalink / raw)
  To: Tom Tromey, Aditya Vidyadhar Kamath
  Cc: Ulrich Weigand, simon.marchi, tom, gdb-patches,
	SANGAMESH MALLAYYA, PRAJWAL B MEHENDARKAR

[-- Attachment #1: Type: text/plain, Size: 1646 bytes --]


Hi Tom and community members,


>I don't really understand this, but (1) I didn't see any other
>commentary on it and (2) it seems to be AIX-specific.
>So, I think it is ok.  I appreciate the comment in there.
>It's fine if you want to apply this to the gdb-18 branch as well.
>Approved-By: Tom Tromey <tom@tromey.com>

Thank you for the approval. I have pushed the same.
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=7063b767cc9c2774e7ead41144e5613bacad6a0d

So, the problem is LINKFORSHARED in AIX also tries to search for Modules/python.exp file. This file tells the AIX linker all the symbols exported from the libpython3.12.a(libpython3.12.so) shared library for symbols resolution. If we do not use this export file AIX Linker thinks nothing is exported from that library and then symbols are not found and python is not linked when GDB binary uses functions from python library.

In this case we do not have the python.exp file in “Modules” path. We have it in /opt/freeware/lib64/python3.12/config-3.12/

# ls -l /opt/freeware/lib64/python3.12/config-3.12/python.exp
-rw-r--r-- 1 root system 52887 Jun 30 01:43 /opt/freeware/lib64/python3.12/config-3.12/python.exp


bash-5.3# head -7 /opt/freeware/lib64/python3.12/config-3.12/python.exp
#!libpython3.12.a(libpython3.12.so)
PyAIter_Check
PyAST_Check
PyAST_mod2obj
PyAST_obj2mod
PyAnextAwaitable_New
PyArg_Parse

So we need to get GDB to understand where /opt/freeware/lib64/python3.12/config-3.12/python.exp is which is done by LIBPL/python.exp and then GDB in AIX compiles with python.

Hope this helps.

Thanks and regards,
Aditya,

[-- Attachment #2: Type: text/html, Size: 5006 bytes --]

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

end of thread, other threads:[~2026-08-24  6:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-30  5:48 [PATCH v1] Fix wrong build tree in python.exp path on AIX Aditya Vidyadhar Kamath
2026-08-21 15:43 ` Tom Tromey
2026-08-24  6:48   ` Aditya Kamath

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