3

I'm trying to build gdb with python 2.7.12 installed by pyenv. Python install command was

pyenv install 2.7.12 -k

Then I executed commands like below to build gdb.

wget ftp://sourceware.org/pub/gdb/releases/gdb-8.1.tar.gz
tar xvf gdb-8.1.tar.gz
cd gdb-8.1
./configure  --with-python=$(pyenv which python) --prefix=/usr/local CFLAGS="-g -O2 -Wno-string-plus-int"
make

But it failed and I got these errors.

configure: WARNING: MPFR is missing or unusable; some features may be unavailable.
checking whether to use python... /home/useraccount/.pyenv/versions/2.7.12/bin/python
checking for python2.7... no
configure: error: no usable python found at /home/useraccount/.pyenv/versions/2.7.12/bin/python
Makefile:9096: recipe for target 'configure-gdb' failed
make[1]: *** [configure-gdb] Error 1
make[1]: Leaving directory '/tmp/tmp.GE0OV8nAxG/gdb-8.1'
Makefile:849: recipe for target 'all' failed
make: *** [all] Error 2

Build commands work when I link gdb to system python.

./configure  --with-python=/usr/bin/python --prefix=/usr/local CFLAGS="-g -O2 -Wno-string-plus-int"
make

I want to use cygdb to debug my cython program but because of this, I cannot run cygdb properly.

Any help will be very appriciated.

Environment

  • Ubuntu 16.04 x64

gdb/config.log

configure:10391: gcc -o conftest -g -O2 -Wno-string-plus-int  -I/home/useraccount/.pyenv/versions/2.7.12/include/python2.7 -I/home/useraccount/.pyenv/versions/2.7.12/include/python2.7 -static-libstdc++ -static-libgcc  conftest.c -ldl -lncurses -lm -ldl  -L/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic >&5
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_tmpnam':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/posixmodule.c:7631: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_tempnam':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/posixmodule.c:7578: warning: the use of `tempnam' is dangerous, better use `mkstemp'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(signalmodule.o): In function `timeval_from_double':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/signalmodule.c:112: undefined reference to `floor'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/signalmodule.c:113: undefined reference to `fmod'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/signalmodule.c:112: undefined reference to `floor'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/signalmodule.c:113: undefined reference to `fmod'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(complexobject.o): In function `_Py_c_abs':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:214: undefined reference to `hypot'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(complexobject.o): In function `complex_remainder':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:616: undefined reference to `floor'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(complexobject.o): In function `complex_divmod':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:642: undefined reference to `floor'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(complexobject.o): In function `_Py_c_pow':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:143: undefined reference to `hypot'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:144: undefined reference to `pow'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:145: undefined reference to `atan2'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:147: undefined reference to `sincos'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:148: undefined reference to `exp'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:149: undefined reference to `log'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:143: undefined reference to `hypot'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:144: undefined reference to `pow'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:145: undefined reference to `atan2'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:145: undefined reference to `sincos'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(complexobject.o): In function `_Py_c_abs':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/complexobject.c:214: undefined reference to `hypot'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_is_integer':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:996: undefined reference to `floor'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_divmod':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:760: undefined reference to `fmod'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:786: undefined reference to `floor'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:760: undefined reference to `fmod'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_rem':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:728: undefined reference to `fmod'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:728: undefined reference to `fmod'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_divmod':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:760: undefined reference to `fmod'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:786: undefined reference to `floor'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:760: undefined reference to `fmod'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_as_integer_ratio':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:1748: undefined reference to `floor'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_pow':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:863: undefined reference to `fmod'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:873: undefined reference to `fmod'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:922: undefined reference to `pow'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:888: undefined reference to `floor'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:898: undefined reference to `fmod'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `_Py_double_round':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:1103: undefined reference to `round'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:1142: undefined reference to `floor'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/floatobject.c:1156: undefined reference to `fmod'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(longobject.o): In function `PyLong_FromString':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Objects/longobject.c:1869: undefined reference to `log'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(dynload_shlib.o): In function `_PyImport_GetDynLoadFunc':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/dynload_shlib.c:94: undefined reference to `dlsym'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/dynload_shlib.c:130: undefined reference to `dlopen'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/dynload_shlib.c:141: undefined reference to `dlsym'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/dynload_shlib.c:133: undefined reference to `dlerror'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_acquire_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:324: undefined reference to `sem_wait'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_release_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:350: undefined reference to `sem_post'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_start_new_thread':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:194: undefined reference to `pthread_create'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:210: undefined reference to `pthread_detach'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:184: undefined reference to `pthread_attr_setstacksize'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_allocate_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:269: undefined reference to `sem_init'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_free_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:294: undefined reference to `sem_destroy'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_acquire_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:326: undefined reference to `sem_trywait'
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:324: undefined reference to `sem_wait'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_release_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:350: undefined reference to `sem_post'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `_pythread_pthread_set_stacksize':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:497: undefined reference to `pthread_attr_setstacksize'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_allocate_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:269: undefined reference to `sem_init'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_acquire_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:324: undefined reference to `sem_wait'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_release_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:350: undefined reference to `sem_post'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_acquire_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:324: undefined reference to `sem_wait'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_release_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:350: undefined reference to `sem_post'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(thread.o): In function `PyThread_allocate_lock':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/Python/thread_pthread.h:269: undefined reference to `sem_init'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_forkpty':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/posixmodule.c:4012: undefined reference to `forkpty'
/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_openpty':
/home/useraccount/.pyenv/sources/2.7.12/Python-2.7.12/./Modules/posixmodule.c:3952: undefined reference to `openpty'
collect2: error: ld returned 1 exit status
1

1 Answer 1

4

The bug appears to be in the configure script. In particular, this command:

gcc -o conftest -g ... conftest.c -ldl -lncurses -lm -ldl  \
  -L/home/useraccount/.pyenv/versions/2.7.12/lib/python2.7/config \
  -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic

is backwards (libpython2.7 depends on libpthread, and so should precede it on the command line).

I checked my config.log from current git head, and it has the same problem.

Looking further, GDB runs python python/python-config.py --ldflags when configureing.

Applying this patch:

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':

and re-running configure should fix this for you.

Sign up to request clarification or add additional context in comments.

1 Comment

This bug has been reported upstream 8 years ago! sourceware.org/bugzilla/show_bug.cgi?id=11420

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.