pyMPI 构建失败:重定位 R_X86_64_32 错误 - 使用 -fPIC 重新编译

pyMPI build fails: relocation R_X86_64_32 error - recompile with -fPIC

我正在尝试安装 pyMPI 以便与 WARP package for some low resolution simulations that I can run on a regular desktop. The documentation 一起使用,因为 WARP 建议我使用pyMPI 的特定变体:

Warp has traditionally been used with pyMPI, but will also work with mpi4py. (Warp with python3 only works with mpi4py.) pyMPI can be obtained from git at NERSC. (The sourceforge version will not work with Warp.)

git clone http://portal.nersc.gov/project/warp/git/pyMPI.git

To build, run the following commands, modifying the installation path as appropriate.

./configure --prefix=/place/to/install
make install

但是,当我运行第一个命令时,配置失败,输出如下:

checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for ranlib... ranlib
checking host overrides... no
checking fatal error on cancel of isend (--with-bad-cancel)... no
checking Assume stdin is interactive (--with-isatty)... 
checking Append a newline to prompt (--with-prompt-nl)... 
checking for mpcc... no
checking for mpxlc... no
checking for mpiicc... no
checking for mpicc... mpicc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... yes
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether mpicc accepts -g... yes
checking for mpicc option to accept ANSI C... none needed
checking for style of include used by make... GNU
checking dependency style of mpicc... none
checking for an ANSI C-conforming const... yes
checking for mpicc is really C++... checking how to run the C preprocessor... mpicc -E
checking for egrep... grep -E
no
checking for sed... /usr/bin/sed
checking for grep... /usr/bin/grep
checking for mpiCC... no
checking for mpi++... no
checking for mpicC... no
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... none
checking for mpicc... /home/krishnadev/.mpich-install/bin/mpicc
checking for g++... /usr/lib64/ccache/g++
checking if /home/krishnadev/.mpich-install/bin/mpicc -E -w is a valid CPP... yes
checking how to run the C preprocessor... /home/krishnadev/.mpich-install/bin/mpicc -E -w
checking for --with-python... no
checking executable /usr/bin/python3.5m-x86_64-config... yes
checking for Python... /usr/bin/python3.5m-x86_64-config
checking for MPIRun.exe... no
checking for mpirun... /home/krishnadev/.mpich-install/bin/mpirun
checking for poe... no
checking Python version 2.2 or higher... Usage: /usr/bin/python3.5m-x86_64-config --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir
no
checking distutils?... Usage: /usr/bin/python3.5m-x86_64-config --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir
checking distutils works... no
Usage: /usr/bin/python3.5m-x86_64-config --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir
configure: error: Your python distribution is incomplete.  Perhaps there is no XXX/lib/python2.x/config

我正在 运行ning Fedora 25 Scientific(64 位),我还没有在其他系统上测试过。任何人都可以帮助我如何构建 pyMPI 吗?


更新:

我强迫它使用 Python 2.7 和

./configure --with-python=/usr/bin/python2.7

现在配置完成,但有一些警告:

checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for ranlib... ranlib
checking host overrides... no
checking fatal error on cancel of isend (--with-bad-cancel)... no
checking Assume stdin is interactive (--with-isatty)... 
checking Append a newline to prompt (--with-prompt-nl)... 
checking for mpcc... no
checking for mpxlc... no
checking for mpiicc... no
checking for mpicc... mpicc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether mpicc accepts -g... yes
checking for mpicc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of mpicc... none
checking for an ANSI C-conforming const... yes
checking for mpicc is really C++... checking how to run the C preprocessor... mpicc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
no
checking for sed... /usr/bin/sed
checking for grep... (cached) /usr/bin/grep
checking for mpiCC... no
checking for mpi++... no
checking for mpicC... no
checking for g++... g++
configure: WARNING: using cross tools not prefixed with host triplet
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... none
checking for mpicc... /home/krishnadev/.mpich-install/bin/mpicc
checking for g++... /usr/lib64/ccache/g++
checking if /home/krishnadev/.mpich-install/bin/mpicc -E -w is a valid CPP... yes
checking how to run the C preprocessor... /home/krishnadev/.mpich-install/bin/mpicc -E -w
checking for --with-python... yes
checking executable /usr/bin/python2.7... yes
checking for Python... /usr/bin/python2.7
checking for MPIRun.exe... no
checking for mpirun... /home/krishnadev/.mpich-install/bin/mpirun
checking for poe... no
checking Python version 2.2 or higher... yes
checking distutils?... yes
checking distutils works... yes
checking numpy?... yes
checking Numarray?... 
checking Python version string... 2.7
checking Prefix exists...... no
configure: WARNING: Prefix /home/krishnadev/.pyMPI-install does not exist
checking for python include location... /usr/include/python2.7
checking that include directory exists... yes
checking for python library location... /usr/lib/python2.7/site-packages
checking that lib directory is accessable... yes
checking Python library... /usr/lib64/python2.7
checking site.py... /usr/lib64/python2.7/site.py
checking site-packages... /usr/lib64/python2.7/site-packages
checking for python lib/config location... /usr/lib64/python2.7/config
checking that lib/config directory is accessable... yes
checking libpython2.7 is there... yes
checking configuration Makefile is there... yes
checking module configuration table is there... yes
checking original Python there... yes
checking for numy include location... /usr/lib64/python2.7/site-packages/numpy/core/include
checking that include directory exists... yes
checking for --with-includes... -I/home/krishnadev/.mpich-install/include/
checking for compiler based include directory... no
checking MPI_COMPILE_FLAGS... no
checking MPI_LD_FLAGS... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking mpi.h usability... yes
checking mpi.h presence... yes
checking for mpi.h... yes
checking Python.h usability... yes
checking Python.h presence... yes
checking for Python.h... yes
checking Python CC... gcc -pthread
checking Python CFLAGS... -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv  -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv
checking Python INCLUDEPY... /usr/include/python2.7
checking Python OPT... -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv
checking Python LDFLAGS... -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
checking Python LINKFORSHARED... -Xlinker -export-dynamic
checking Python LDSHARED... gcc -pthread -shared -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
checking Python BLDSHARED... gcc -pthread -shared -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
checking Python LOCALMODLIBS... 
checking Python BASEMODLIBS... 
checking Python LIBS... -lpthread -ldl  -lutil
checking Python LDLAST... 
checking Python library options...  -L/usr/lib64/python2.7/config -lpython2.7 -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Xlinker -export-dynamic   -lpthread -ldl  -lutil 
checking for --with-debug... no
checking python.exp file... no
checking sysconf(_SC_NPROCESSORS_CONF)... yes
checking for ANSI C header files... (cached) yes
checking local processor count for testing... 8
checking for --with-libs... -L /usr/lib64/python2.7/ -L/home/krishnadev/.mpich-install/lib/
checking for pow in -lm... no
checking for PyOS_StdioReadline... no
checking for setlinebuf... no
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking Python links as is... no
checking for -pthread... no
checking for gcc libraries... Found /usr/lib/gcc/x86_64-redhat-linux/6.3.1/libgcc.a
checking _eprintf bug workaround... no
configure: WARNING: Python doesn't seem to link.  Look at config.log.  You may need to add --with-libs or --with-includes or just hack the Makefile
checking for MPI capability... no
checking if adding -lmpi helps... no
configure: WARNING: MPI must need some more libraries...  Look at config.log.  You may need to add --with-libs info
checking for Py_ReadOnlyBytecodeFlag... no
checking for MPI_Initialized()... no
checking for MPI_Finalized()... no
checking for MPI File operations (ROMIO)... no
checking for AIX dynamic load... no
checking pm_util.h usability... no
checking pm_util.h presence... no
checking for pm_util.h... no
checking for mpc_flush... no
checking for mpc_isatty... no
checking for Electric Fence enabled?... no
configure: creating ./config.status
config.status: creating Makefile
config.status: WARNING:  'Makefile.in' seems to ignore the --datarootdir setting
config.status: creating unittest/run-all-tests
config.status: creating softload_setup.py
config.status: creating pyMPI_Config.h
config.status: executing depfiles commands
                         /|_|_|_\     )
     ~^^^~~~~~~~~^^^~~^^~~~~~^   \
    <vvvvvvvvvvvvvvvvvvvvvvvvvv>  |
     \ Putting the pie in MPI /   |
      \__\)\_________________/    |
          \ )  /        \__ _ _ _/
           )  /          \_|_|_|/

但是,我仍然无法成功构建和安装 - 最后出现以下错误:

/usr/bin/ld: libpyMPI.a(pyMPI_main.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
libpyMPI.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Makefile:506: recipe for target 'pyMPI' failed
make: *** [pyMPI] Error 1

应该是什么问题以及如何解决?


此外,我应该如何使用 mpi4py 而不是 pyMPI?文档说这是可能的:

Warp has traditionally been used with pyMPI, but will also work with mpi4py.

我通常会使用以下命令进行模拟:

mpirun -np 4 pyMPI warp_script.py

我使用 pip 安装了 mpi4py,但是谁能指导我使用它代替 pyMPI?

通过在配置时传递以下参数解决了该问题:

./configure --with-python=/usr/bin/python2.7 CFLAGS="-fPIC"

这强制使用Python 2.7,并且通过CFLAGS也消除了构建时的错误。