[gmx-developers] nonPIC code in liblammpio.a

Erik Lindahl lindahl at sbc.su.se
Mon Nov 21 19:29:03 CET 2005


Hi Jack,



On Nov 21, 2005, at 4:23 PM, Jack Howarth wrote:

>    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...

We rely completely on GNU libtool to abstract away the mess with  
shared libraries on different architectures.

We never ever set any flags ourselves - GNU libtool builds separate  
object files with/without PIC code as needed (with flags depending on  
the compiler), and creates the necessary libraries.

This sounds either like something in the LAM-MPI package, or a bug on  
GNU libtool.


>
> 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.

Agreed, but if we start adding flags in Gromacs to fix it we would  
end up replicating all of libtool. I actually wrote the Fortran77  
libtool support several years ago, and after that experience I try to  
stay away from the gory details of it...

Remember there are dozens of possible OS/CPU/compiler combinations  
that people use for Gromacs, and on some there is a slight  
performance hit with PIC.

>
> 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.

Our policy is to leave that to GNU libtool and not worry about  
it :-)  However, on Linux it shouldn't cause any major performance  
concerns, so you are more than welcome to force it for fink packages!


Cheers,

Erik

-----------------------------------------------------------
Erik Lindahl  <lindahl at sbc.su.se>
Assistant Professor, Stockholm Bioinformatics Center
Stockholm University, SE 106 91 Stockholm
Phone: +46 8 5537 8564     Fax: +46 8 5537 8214







More information about the gromacs.org_gmx-developers mailing list