[gmx-developers] nonPIC code in liblammpio.a

Jack Howarth howarth at bromo.msbb.uc.edu
Mon Nov 21 16:23:05 CET 2005

   In creating the latest fink packaging for lam 7.1.1 and gromacs/
gromacs-mpi 3.3 for fink on MacOS X, I noticed that the lam build
creates a liblammpio.a with common symbols because it is built without
-fPIC. This liblammpio.a is silently linked in to gromacs-mpi's 
shared libraries by mpicc which seems a direct violation of Ulrich
Drepper's recommendations for building DSO's...

The most important recommendation is to always use -fpic or -fPIC
when generating code which ends up in DSOs. This applies to data as
well as code. Code which is not compiled this way almost certainly
will contain text relocations. For these there is no excuse. Text
relocations require extra work to apply in the dynamic linker. And
argumentation saying that the code is not shared because no other
process uses the DSO is invalid. In this case it is not useful to
use a DSO in the first place; the code should just be added to the
application code.

I also noticed that on Fedora Core 4, they have added -fPIC to
the RPM_OPT_FLAGS for x86_64 suggesting that this has in fact
caused problems. What are the views of the gromacs developers 
on this? To be safe shouldn't all arch's that build shared lib
lam and gromacs, use PIC code for liblammpio.a to be safe? I
know from working on linuxppc development that the non-PIC
code in shared libs can cause weird crashes that are hard to
diagnose. Thanks in advance for any advice.

More information about the gromacs.org_gmx-developers mailing list