环境准备
pip
安装 docutils
时报错
(.venv) 🍺 /root/downloads/openssl ☞ git:(master) pip install docutils
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/docutils/
需要安装 OpenSSL
之后重新编译 Python
, 以安装 Python 3.10
为例,它对 OpenSSL
版本有要求,默认版本太低, 需要重新编译 OpenSSL
。其编译时依赖 perl
modules。
Could not build the ssl module!
Python requires a OpenSSL 1.1.1 or newer
(.venv) ➜ /root/downloads/openssl ☞ git:(master) yum install perl-core
(.venv) ➜ /root/downloads/openssl ☞ git:(master) ./Configure
(.venv) ➜ /root/downloads/openssl ☞ git:(master) make -j 8
(.venv) ➜ /root/downloads/openssl ☞ git:(master) make install
OpenSSL
相关的文件和动态链接库默认存放在 /usr/local/bin
/usr/local/lib64/
/usr/local/share/doc/openssl
/usr/local/ssl
/usr/local/include/openssl
等目录。
(.venv) 🍺 /root/downloads/openssl ☞ git:(master)ln -s /usr/local/lib64/libssl.so.3 /usr/lib64/libssl.so.3
(.venv) 🍺 /root/downloads/openssl ☞ git:(master)ln -s /usr/local/lib64/libcrypto.so.3 /usr/lib64/libcrypto.so.3
重新编译安装 Python 3.10
./configure --with-openssl=/usr/local --with-openssl-rpath=auto --enable-optimizations
make
make install
如果出现如下编译错误:
/root/downloads/Python-3.10.0/Modules/_ctypes/_ctypes.c:107:10: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^~~~~~~
compilation terminated.
安装 libffi
libffi-devel
(.venv) 🍺 /root/downloads/Python-3.10.0 ☞ sudo yum -y install libffi libffi-devel
在 Python 安装包下执行 make
时还是会报 Could not build the ssl module!
,查看 configure
文件和 setup.py
发现端倪,原来 configure
文件里在设置 OPENSSL_LDFLAGS
参数时默认是在你指定的目录下的 lib
文件中 查找,即 OPENSSL_LDFLAGS="-L$ssldir/lib"
,而手动编译的 OpenSSL
动态链接库安装在 /usr/local/lib64
下面,因此需要修改 configure
文件。然后重新编译即可。
OPENSSL_LDFLAGS="-L$ssldir/lib64"
编译 rdma-core
上面的环境准备就是为了修复如下错误
(.venv) 🍺 /root/go/src/github.com/linux-rdma/rdma-core ☞ git:(master) ./build.sh
-- Could NOT find pandoc (missing: PANDOC_EXECUTABLE PANDOC_VERSION_STRING)
-- Could NOT find rst2man (missing: RST2MAN_VERSION_STRING)
-- Missing Optional Items:
-- Compiler attribute symver NOT supported, can not use LTO
-- Valgrind memcheck.h NOT enabled
-- Valgrind drd.h NOT enabled
-- pandoc NOT found and NO prebuilt man pages. 'install' disabled
-- rst2man NOT found and NO prebuilt man pages. 'install' disabled
-- cython NOT found (disabling pyverbs)
-- Configuring done
-- Generating done
-- Build files have been written to: /root/go/src/github.com/linux-rdma/rdma-core/build
[ 1%] Creating man page vendstat.8
Traceback (most recent call last):
File "/bin/rst2man", line 21, in <module>
from docutils.core import publish_cmdline, default_description
ModuleNotFoundError: No module named 'docutils'
make[2]: *** [infiniband-diags/man/vendstat.8] Error 100
make[1]: *** [infiniband-diags/man/CMakeFiles/man-vendstat.8.dir/all] Error 2
make: *** [all] Error 2
编译
🍺 /root/go/src/github.com/linux-rdma/rdma-core ☞ git:(master) ./build.sh
🍺 /root/go/src/github.com/linux-rdma/rdma-core ☞ git:(master) yum install dnf
➜ /root/go/src/github.com/linux-rdma/rdma-core ☞ git:(master) dnf install 'dnf-command(builddep)'
🍺 /root/go/src/github.com/linux-rdma/rdma-core ☞ git:(master) dnf builddep redhat/rdma-core.spec
🍺 /root/go/src/github.com/linux-rdma/rdma-core/build ☞ git:(master) make install
如果 make install
报错
CMake Error at libibumad/man/cmake_install.cmake:100 (FILE):
file INSTALL cannot find
"/root/go/src/github.com/linux-rdma/rdma-core/buildlib/pandoc-prebuilt/41bbb0bed7a781be59e8c0dcd8b7278af2ce6882".
Call Stack (most recent call first):
cmake_install.cmake:43 (INCLUDE)
➜ /root/go/src/github.com/linux-rdma/rdma-core/build ☞ git:(master) yum install epel-release
🍺 /root/go/src/github.com/linux-rdma/rdma-core/build ☞ git:(master) yum install cmake3 ninja-build pandoc
发现 make install
还是报错。换成 ninja
编译后成功。
export EXTRA_CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=Debug -DENABLE_WERROR=1"
mkdir -p build && cd build
cmake -G Ninja CFLAGS="-O0 -g" -DCMAKE_INSTALL_PREFIX=/usr ..
ninja
ninja install
Ninja 延伸
Ninja
相对于 Makefile
这套工具更注重于编译速度。
- 可以生成编译依赖关系图,可以使用
dot
来生成图片。
🍺 /root/go/src/github.com/linux-rdma/rdma-core/build ☞ git:(master) ninja -t graph all
ninja
依赖于build.ninja
文件,根据CmakeLists.txt
运行cmake -G Ninja
来生成这个配置文件。通过执行
ninja -t list
可以查看ninja
中集成了哪些工具。
🍺 /root/go/src/github.com/linux-rdma/rdma-core/build ☞ git:(master) ninja -t list