amd64 and -fPIC
Kris Kennaway
kris at obsecurity.org
Tue Mar 7 19:07:02 UTC 2006
On Tue, Mar 07, 2006 at 07:56:24PM +0100, Roman Neuhauser wrote:
> > > > > If the package includes a library that might be used frequently and doesn't
> > > > > include a shared version please add -fPIC to the amd64 version of the port, for
> > > > > example for math/arpack (and feel free to commit this):
> > > >
> > > > The best solution is to make the port also build a shared version;
> > > > it's usually not that difficult to modify the makefile. That way you
> > > > don't have to add nasty hacks.
> > >
> > > That doesn't solve the problem, which is: the static library is
> > > almost useless, and users might actually want or need to use the
> > > static library.
> >
> > Why do you say it's useless? The point of a static library is for
> > static linking, and this works fine on amd64 or any other
> > architecture.
>
> I say so because I installed the library (using the port) to use it
> in a shared library. The link failed with relocation errors. As far
> as I'm concerned (on amd64, that is), the port is dead weight.
OK, so it just needs to be fixed to build a shared library too (as I
said above).
> > > net/libpcap only installs lib/libpcap.so if you install into /usr,
> > > probably because all the dependent ports would need to be taught
> > > to look in /usr/local/lib first.
> >
> > I don't know what you're saying here.
>
> /usr/lib is walked first, /usr/lib/libpcap.so.N will mask
> /usr/local/lib/libpcap.so.M
Yep, that's how it works. Again, what is your point?
> > > misc/ossp-uuid's ${PREFIX}/lib/libuuid.a (it configures with
> > > --disable-shared) cannot be used in shared libraries on amd64
> > > because the port doesn't use -fPIC on this platform.
> >
> > The bug is presumably the --disable-shared.
>
> I'd prefer to link in the .a even if there was a .so.
I don't care what your preference is, it's wrong to expect this to
work (see below).
> > > Ports that install static libraries *need* to use -fPIC on amd64.
> >
> > No, they need to also install shared libraries.
>
> Ok, to help me understand your view:
>
> Do you agree that it's a fact that static libraries installed
> without -fPIC can be used to create shared libraries on eg. i386?
By accident of the architecture, yes. The architectures on which this
works are in the minority.
> Do you agree that it's a fact that static libraries installed
> without -fPIC *cannot* be used to create shared libraries on eg.
> amd64?
Yes, relocatable code needs to be used in relocatable libraries on
amd64 and other architectures. Relocatable code should not be used in
non-relocatable libraries since the extra indirection makes it slower.
This sometimes *makes a measurable performance difference* that is
important when you are trying to optimize for performance. In fact,
chances are that the port in question is exactly such a case.
Kris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20060307/dc730041/attachment.bin
More information about the freebsd-ports
mailing list