This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Is -static a link-only switch?
- From: Ian Lance Taylor <ian at airs dot com>
- To: "Gary Funck" <gary at intrepid dot com>
- Cc: "Gcc Mailing List" <gcc at gcc dot gnu dot org>
- Date: 12 May 2005 11:49:49 -0400
- Subject: Re: Is -static a link-only switch?
- References: <JCEPIPKHCJGDMPOHDOIGIEGKCOAA.gary@intrepid.com>
"Gary Funck" <gary@intrepid.com> writes:
> Does the -static switch play any role during compilation, or is it
> a link-only switch?
It is a link-only switch.
> A quick review of gcc.c, indicates that -static
> may play a role on some targets:
>
> /* %{static:} simply prevents an error message if the target machine
> doesn't handle -static. */
That comment is above LINK_COMMAND_SPEC, which is how gcc invokes the
linker. It means that if the target does not provide any handling for
-static in the target specific LINK_SPEC, gcc will simply ignore
-static. It doesn't affect code-generation, only how the linker is
invoked.
> I can think of target OS's that might define a different ABI for
> procedure calls for programs compiled with -static asserted, than
> when compiled for a dynamic linking environment, but can't quite
> tell if in fact -static has any effect during compilation.
In fact many targets compile code differently depending upon whether
the code is to be put into a shared library or not, but this is
controlled via options like -fpic, not -static.
Ian