Re: fPIC and its effect on BASIN dependencies

From: Doug Jones <dfj23@drexel.edu>
Date: Thu Nov 29 2007 - 21:08:42 EST

I just wanted to clarify something in my earlier message. When I
wrote amd64, I should have said any x86_64 system. I do not believe
that this problem is isolated to only AMD systems, but it exists on
any chip that is based on the x86_64 architecture.

~doug

On Nov 29, 2007, at 2:07 PM, Doug Jones wrote:

> Hi Basin Group,
>
> I've looked into the fPIC issue and how it relates to BASIN. I've
> listed
> my findings below. I plan to add this information to the wiki once we
> have the troubleshooting section created.
>
>
> A -fpic or -fPIC flag should be used when compiling source files that
> will eventually be included in a shared library.
>
> On normal x86 systems, -fpic should suffice for code compiled by gcc.
> The issue is that on amd64 systems, -fPIC (yes, the capital letters
> are
> the only difference) should be used to support that system's
> architecture.
>
> This information is important to Basin when it comes time to build our
> code and put it into shared libraries (which is the default mode for
> building basin).
>
> Thankfully, we are using libtool which takes care of the decision of
> what fpic flags to use. So far, it seems that the correct choice is
> made
> on the systems we build basin for.
>
> However, some dependencies of basin that are *static* libraries
> need to
> be taken into consideration when doing this.
>
> Namely, MPICH2 builds its C++ library as a static library. This means
> that on amd64 systems MPICH2 should compile its source using the -fPIC
> flag. It appears that the configure file for MPICH2 does not handle
> this
> automatically. Therefore, it is necessary to use something like the
> following to properly configure MPICH2 for shared libraries on amd64
> systems:
> CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure <options>
>
> If MPICH2 is *not* built using -fPIC on amd64, then it will only be
> possible to build *static* libraries for any source that relies on
> MPICH2, including basin.
>
> The situation becomes very complicated when you consider that packages
> such as HDF5 and FFTW rely on MPICH2 when they build. These packages
> will most likely default to building shared libraries, causing
> errors on
> amd64 systems using MPICH2 without fPIC.
>
> To make matters worse, an error will occur when the code that is
> building against MPICH2 tries to create a shared library. That means
> that you may see build errors when compiling HDF5, FFTW, or basin that
> are the result of an incorrectly built MPICH2 installation.
>
> So, on amd64 systems there are two general paths to follow.
>
> 1) Force MPICH2 to build with -fPIC flags as listed above. All
> packages
> can then build using their default options, which is likely a shared
> library.
>
> 2) Build only *static* libraries for anything that relies on MPICH2.
> This includes basin. To build the basin_kernel using static libraries
> one should do the following
> ./configure <options> --enable-shared=no
> Other packages that depend on MPICH2 will likely also need similar
> changes to their configure flags. However, the flag to use is not
> universal so the documentation for each package will need to be
> consulted to find the appropriate information.
>
>
Received on Thu Nov 29 20:52:16 2007

This archive was generated by hypermail 2.1.8 : Fri Aug 08 2008 - 19:25:03 EDT