On Sun, Apr 17, 2005 at 07:48:53PM -0700, Gary Funck wrote:
> This usage of a null substitution came up while I was trying to use
> this form of spec. for a different switch, but the following illustrates
> the problem using the existing gcc compiler as built for Redhat Linux
> running on an SGI Altix:
>
>
> Given a spec of this form,
> %{S:X} substitutes X, if the -S switch was given to CC.
>
> And a switch definition for -static:
>
> /* %{static:} simply prevents an error message if the target machine
> doesn't handle -static. */
>
> And the resulting link command spec:
>
> *link_command:
> %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S: %(linker) %l %{pie:-pie} %X
> %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r} %{s} %{t}
> %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}} %{static:}
> %{L*} %(link_libgcc) %o
> %{fprofile-arcs|fprofile-generate:-lgcov}
> %{!nostdlib:%{!nodefaultlibs:%(link_gcc_c_sequence)}}
> %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}
Take a look at your %(link) in the same file.
> I haven't followed the logic in detail, but should the spec.
> %{static:} above erase the explicit -static switch that was
> passed to gcc?
No. See the documentation in gcc/gcc.c for what you want:
%<S remove all occurrences of -S from the command line.
Note - this command is position dependent. % commands in the
spec string before this one will see -S, % commands in the
spec string after this one will not.
%{static:} prevents the compiler from issuing an error, if a target
does not include any other references to -static in its specs.
--
Daniel Jacobowitz
CodeSourcery, LLC