This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -fpic vs -fPIC
- To: kthomas at gwdg dot de (Philipp Thomas)
- Subject: Re: -fpic vs -fPIC
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Mon, 19 Apr 1999 11:48:07 -0600
- cc: egcs at cygnus dot com
- Reply-To: law at cygnus dot com
In message <3720a225.77123225@mailer.gwdg.de>you write:
> Could somebody please explain to me the different approaches gcc uses when
> given one or the other flag ? I only found the description in gcc.info that
> -fPIC overcomes a size limit but not how that's achieved.
Correct. On some targets -fpic can only address a certain amount of
position independent data in the static store. The actual amount of
data varies from machine to machine (and in some cases between different
versions of the linker).
> As the info says that -fPIC isn't needed for x86, I'm always changing
> libtoolin new packages I compile to use -fpic. But I was always unsure if
> this is the right thing to do and would like to know the implications i
> in order to base my doing on knowledge rather than guesswork.
Unless you know that the amount of data you're going to reference is always
small, I would recommend always using -fPIC for modules that you use to
build a shared library.
If you are going to put -fPIC compiled modules into an archive library
(and there are good reasons to do so), then you should always use -fPIC
for those modules so that when that archive library is linked into an
executable or other shared library, it won't be size limited.
Jeff