public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* How to add a flag to a tool if a particular define is present on the driver command line (using spec files)
       [not found] <BANLkTi=ooKL8UyedZ3x=K2upW_-adq5SMg@mail.gmail.com>
@ 2011-05-11 18:07 ` asharif
  2011-05-11 18:52   ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: asharif @ 2011-05-11 18:07 UTC (permalink / raw)
  To: gcc-help

Up until http://gcc.gnu.org/viewcvs?view=revision&revision=163770, you
could have a line like this in the gcc driver spec file:

cc1:
%(cc1_cpu) %{profile:-p} %{DFOO: -foo}

This would detect if -DFOO was given on the driver command line and
would pass in -foo to cc1.

However, after r163770 this stopped working.

Is there a way to do this using current trunk (i.e., add a flag to a
tool if a particular define is present on the gcc driver command
line)? Was the old way broken or was there a bug introduced with
revision r163770?

Here is a small test script to test a gcc driver binary to see if it
supports specfile modification like the above. This script returns 0
at revision r163770 and returns 1 before that (-foo is not passed to
cc1 at that revision and beyond). Use it like:

$script_file <path_to_gcc_driver_binary>

#!/bin/bash
my_gcc=$1
specs=$($my_gcc -dumpspecs)
new_specs=$(echo "$specs" | sed -e '/cc1:/,+1 {/cc1:/b; s/$/ %{DFOO: -foo}/}')
new_specs_file=$(mktemp)
echo "$new_specs" > $new_specs_file
echo 'int main(){return 0;}' | $my_gcc -specs $new_specs_file -o
/dev/null -v -DFOO -x c -
exit $?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to add a flag to a tool if a particular define is present on the driver command line (using spec files)
  2011-05-11 18:07 ` How to add a flag to a tool if a particular define is present on the driver command line (using spec files) asharif
@ 2011-05-11 18:52   ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2011-05-11 18:52 UTC (permalink / raw)
  To: asharif; +Cc: gcc-help

asharif <asharif@gcc.gnu.org> writes:

> Up until http://gcc.gnu.org/viewcvs?view=revision&revision=163770, you
> could have a line like this in the gcc driver spec file:
>
> cc1:
> %(cc1_cpu) %{profile:-p} %{DFOO: -foo}
>
> This would detect if -DFOO was given on the driver command line and
> would pass in -foo to cc1.
>
> However, after r163770 this stopped working.
>
> Is there a way to do this using current trunk (i.e., add a flag to a
> tool if a particular define is present on the gcc driver command
> line)? Was the old way broken or was there a bug introduced with
> revision r163770?

This doesn't work when preprocessing and compiling are separated, which
means that it doesn't work with distcc or ccache.  I don't see any way
to fix that, so I don't think we're likely to resurrect this
functionality.

Ian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-05-11 18:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <BANLkTi=ooKL8UyedZ3x=K2upW_-adq5SMg@mail.gmail.com>
2011-05-11 18:07 ` How to add a flag to a tool if a particular define is present on the driver command line (using spec files) asharif
2011-05-11 18:52   ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).