From: "Paul Pluzhnikov via gdb-patches" <gdb-patches@sourceware.org>
To: gdb-patches ml <gdb-patches@sourceware.org>
Subject: [patch] Fix BZ 11420 -- configure uses incorrect link order when testing libpython
Date: Tue, 17 Apr 2018 15:53:00 -0000 [thread overview]
Message-ID: <CALoOobNRZ+w6-wNZGULfuqQwKT+kFWFR+79Bt273OF1fFS+9sg@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 823 bytes --]
Greetings,
https://stackoverflow.com/a/49868387
https://sourceware.org/bugzilla/show_bug.cgi?id=11420
Configure uses "gcc -o conftest -g ... conftest.c -ldl -lncurses -lm -ldl
... -lpthread ... -lpython2.7" when deciding whether give libpython is
usable.
That of course is the wrong link order, and only works for shared libraries
(mostly by accident), and only on some systems.
Attached patch fixes this.
I am not sure about this part of the patch:
- LIBS="$LIBS $new_LIBS"
+ LIBS="$new_LIBS $LIBS"
I think it's always better to prepend new libraries.
Thanks,
2018-04-17 Paul Pluzhnikov <ppluzhnikov@google.com>
PR gdb/11420
* gdb/configure.ac: Prepend libpython.
* gdb/python/python-config.py: Likewise.
* gdb/configure: Regenerate.
--
Paul Pluzhnikov
[-- Attachment #2: gdb-bz11420-20180417.txt --]
[-- Type: text/plain, Size: 2385 bytes --]
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 698fc7b834..e1f630cd38 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -732,7 +732,7 @@ AC_DEFUN([AC_TRY_LIBPYTHON],
save_CPPFLAGS=$CPPFLAGS
save_LIBS=$LIBS
CPPFLAGS="$CPPFLAGS $new_CPPFLAGS"
- LIBS="$LIBS $new_LIBS"
+ LIBS="$new_LIBS $LIBS"
found_usable_python=no
AC_LINK_IFELSE(AC_LANG_PROGRAM([[#include "Python.h"]],
[[Py_Initialize ();]]),
@@ -922,19 +922,19 @@ else
elif test "${have_python_config}" != failed; then
if test "${have_libpython}" = no; then
AC_TRY_LIBPYTHON(python2.7, have_libpython,
- ${python_includes}, "${python_libs} -lpython2.7")
+ ${python_includes}, "-lpython2.7 ${python_libs}")
fi
if test "${have_libpython}" = no; then
AC_TRY_LIBPYTHON(python2.6, have_libpython,
- ${python_includes}, "${python_libs} -lpython2.6")
+ ${python_includes}, "-lpython2.6 ${python_libs}")
fi
if test ${have_libpython} = no; then
AC_TRY_LIBPYTHON(python2.5, have_libpython,
- ${python_includes}, "${python_libs} -lpython2.5")
+ ${python_includes}, "-lpython2.5 ${python_libs}")
fi
if test ${have_libpython} = no; then
AC_TRY_LIBPYTHON(python2.4, have_libpython,
- ${python_includes}, "${python_libs} -lpython2.4")
+ ${python_includes}, "-lpython2.4 ${python_libs}")
fi
fi
if test "${have_libpython}" = python2.7 -o "${have_libpython}" = python27; then
diff --git a/gdb/python/python-config.py b/gdb/python/python-config.py
index c2b2969c39..0d38ed50c0 100644
--- a/gdb/python/python-config.py
+++ b/gdb/python/python-config.py
@@ -58,12 +58,11 @@ for opt in opt_flags:
print (to_unix_path(' '.join(flags)))
elif opt in ('--libs', '--ldflags'):
- libs = []
+ libs = ['-lpython'+pyver + abiflags]
if getvar('LIBS') is not None:
libs.extend(getvar('LIBS').split())
if getvar('SYSLIBS') is not None:
libs.extend(getvar('SYSLIBS').split())
- libs.append('-lpython'+pyver + abiflags)
# add the prefix/lib/pythonX.Y/config dir, but only if there is no
# shared library in prefix/lib/.
if opt == '--ldflags':
next reply other threads:[~2018-04-17 15:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-17 15:53 Paul Pluzhnikov via gdb-patches [this message]
2018-05-03 15:56 ` Paul Pluzhnikov via gdb-patches
2018-05-04 14:12 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CALoOobNRZ+w6-wNZGULfuqQwKT+kFWFR+79Bt273OF1fFS+9sg@mail.gmail.com \
--to=gdb-patches@sourceware.org \
--cc=ppluzhnikov@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).