[mpich2-dev] CFLAGS=-fPIC not passed down to MPE ?

Lisandro Dalcin dalcinl at gmail.com
Sun Aug 5 19:26:54 CDT 2012


This is with trunk updated yesterday. I've explicitly passed
CFLAGS=-fPIC FFLAGS=-fPIC to configure:

$ mpich2version
MPICH2 Version:    	1.5b2
MPICH2 Release date:	unreleased development copy
MPICH2 Device:    	ch3:nemesis
MPICH2 configure: 	--prefix=/home/devel/mpi/mpich2-dev --enable-shared
CFLAGS=-fPIC FFLAGS=-fPIC --enable-g=all
MPICH2 CC: 	gcc -fPIC   -g -O2
MPICH2 CXX: 	c++   -g -O2
MPICH2 F77: 	gfortran -fPIC  -g -O2
MPICH2 FC: 	gfortran   -g -O2

However, after trying to link-in libmpe.a to build a shared library on
Linux x86_64, I get the usual relocation errors related to non-PIC
code:

/home/devel/mpi/mpich2-dev/bin/mpicc -shared -Wl,-z,relro
build/temp.linux-x86_64-2.7/src/pmpi-mpe.o -o
build/lib.linux-x86_64-2.7/mpi4py/lib-pmpi/libmpe.so
-Wl,-whole-archive -llmpe -Wl,-no-whole-archive -lmpe -lpthread
/usr/bin/ld: /home/devel/mpi/mpich2-dev/lib/liblmpe.a(log_mpi_util.o):
relocation R_X86_64_32 against `.rodata' can not be used when making a
shared object; recompile with -fPIC
/home/devel/mpi/mpich2-dev/lib/liblmpe.a(log_mpi_util.o): could not
read symbols: Bad value
collect2: error: ld returned 1 exit status
warning: build_clib: building library "mpe" failed


PS: Will MPICH2 ever provide lib[l]mpe.so in POSIX platforms? Getting
trace files without a recompile is really handy:

# generate libmpe.so
$ mpicc -shared -o libmpe.so -Wl,-whole-archive -llmpe
-Wl,-no-whole-archive -lmpe

# compile without MPE and run
$ mpicc helloworld.c
./a.out
Hello, World! I am process 0 of 1 on trantor.

# enable MPE at runtime
$LD_PRELOAD=./libmpe.so ./a.out
Hello, World! I am process 0 of 1 on trantor.
Writing logfile....
Enabling the Default clock synchronization...
Finished writing logfile ./a.out.clog2.


-- 
Lisandro Dalcin
---------------
CIMEC (INTEC/CONICET-UNL)
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
3000 Santa Fe, Argentina
Tel: +54-342-4511594 (ext 1011)
Tel/Fax: +54-342-4511169


More information about the mpich2-dev mailing list