Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Feb 2004 10:52:08 -0800
From:      Marcel Moolenaar <marcel@xcllnt.net>
To:        freebsd-amd64@freebsd.org
Subject:   Re: CFLAGS+= -fPIC per default?
Message-ID:  <20040222185208.GA53610@dhcp01.pn.xcllnt.net>
In-Reply-To: <200402220033.01795.peter@wemm.org>
References:  <BD6DAE5F-64A6-11D8-ACAA-000A95BAD088@raisdorf.net> <c195u3$2q5s$1@kemoauc.mips.inka.de> <4CC57F17-64E9-11D8-ACAA-000A95BAD088@raisdorf.net> <200402220033.01795.peter@wemm.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Feb 22, 2004 at 12:33:01AM -0800, Peter Wemm wrote:
> On Saturday 21 February 2004 07:43 pm, Hendrik Scholz wrote:
> > On Feb 21, 2004, at 9:59 PM, Christian Weisgerber wrote:
> > > Why are these shared objects not built with -fPIC in the first
> > > place?
> >
> > Ask the authors of the third party applications :)
> > Most architectures don't need -fPIC and/or it slows them down (thanks
> > for the
> > comment Peter!).
> 
> Yes, exactly.  Some folks thought it would be an idea to add a flag to 
> libtool to force it to link non-pic code into shared libraries.  
> Essentially this reduces the sharability since we do relocations on the 
> text segment, but the flipside is that its faster on i386 and on some 
> libraries they figured it was worth burning extra memory that would be 
> wasted by not using -fPIC.

Not to mention that people generally attach -fPIC to the kind of
library they are making and thus do not build with -fPIC if they
create an archive library (the BSD make infrastructure has this
too). This most of the time works, but not when the archive library
is subsequently linked *into* a shared library later on. So, the
use of -fPIC is determined by how the object files are eventually
used to make up a process and that's not always known to the person
writing the libraries, let alone some (in)convenience tools like
libtool or automake/autoconf.

With shared libraries the norm, the safest default would be -fPIC
on some archs (amd64 and ia64 for example). The group of people
that build archive only libraries and complete executables for
performance reasons, a pretty small group, know how to fiddle with
options to get the compiler/linker emit the best code for their
purpose and a -fNOPIC doesn't add to the hazzle.

I think it was Christian who asked why -fPIC was not the default
and I think it's a good question. Although it should be compiler
default, not some make logic to add to CFLAGS...

-- 
 Marcel Moolenaar	  USPA: A-39004		 marcel@xcllnt.net



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040222185208.GA53610>