繁体   English   中英

使用自定义 python 从源代码构建 gdb 10.1

[英]Building gdb 10.1 from source with custom python

我正在尝试从源代码构建最新的 gdb 10.1。

[我想要这样做的原因是我正在尝试调试一个链接到 Python 2.7.18 自定义构建的程序,并且我的系统 gdb 链接到我的 /lib64 目录中的 Python 2.7.5 构建,并且不适用于较新版本]。

通读自述文件后,我已使用以下方法进行配置:

../gdb-10.1/configure --with-python=<path to my 2.7.18 installation> --prefix=<path to where I want the new gdb to go>

...然后运行

make all install

...按照说明。 但是,每次构建尝试都会失败,并出现一系列以下形式的错误消息:

python/py-arch.o: In function `gdbarch_to_arch_object(gdbarch*)':
.../build/gdb/../../../gdb-10.1/gdb/python/py-arch.c:86: undefined reference to `_Py_RefTotal'
python/py-arch.o: In function `gdbpy_ref_policy<_object>::decref(_object*)':
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_RefTotal'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_NegativeRefcount'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_Dealloc'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_RefTotal'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_RefTotal'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_RefTotal'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_NegativeRefcount'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_Dealloc'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_RefTotal'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_Dealloc'
.../build/gdb/../../../gdb-10.1/gdb/python/py-ref.h:36: undefined reference to `_Py_NegativeRefcount'

在检查配置步骤的输出和 Makefile 本身时,我根本找不到我在配置时指定的 Python 安装的任何参考(并且我也将其放置在 LD_LIBRARY_PATH 的开头以确保编译器并且链接器可以在构建时找到它)。

我在这里缺少什么?

我最近做了类似的事情,也很挣扎,尽管是针对不同的问题。

我怀疑您的构建问题可能与您使用 LD_LIBRARY_PATH 或来自您的环境(PATH、CFLAGS、LDFLAGS 等)的其他内容有关。 您不应该在构建期间设置这些。

这是我所做的概述:

(1)对于gdb的构建,我使用了这样的方法:

export PATH=/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin
unset LD_LIBRARY_PATH 
../gdb-10.1/configure --prefix=/opt/gdb-10.1  --with-python=/opt/conda-py2.7.18 
make         &> make.log
make install &> make-install.log

PATH 的设置和 LD_LIBRARY_PATH 的未设置旨在净化环境。 这确保构建只能使用--with-python来定位 python (它本身在bin/python ,在 python 前缀下)。 (CFLAGS 和 LDFLAGS 也没有设置,也没有设置任何 PYTHON 变量。)

我保留了 make 阶段的输出。 如果您查看那里,您应该会看到with-python选项被选中。

这一切都很好。

(2) 要调用调试器(并在 /opt 下使用我的 python),我需要一个额外的步骤:设置 LD_LIBRARY_PATH 以便使用我的 pythons libpython:

export LD_LIBRARY_PATH=/opt/conda-py2.7.18/lib
/opt/gdb-10.1/bin/gdb
(gdb) python import sys; print(sys.version)
2.7.18 | Anaconda, Inc.

找到一种方法来避免这种设置 LD_LIBRARY_PATH 的需要会很好; 这可能需要静态链接 libpython,或引入一些构建标志,例如,使用 rpath。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM