How to add a flag to a tool if a particular define is present on the driver command line (using spec files)
asharif
asharif@gcc.gnu.org
Wed May 11 18:07:00 GMT 2011
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 $?
More information about the Gcc-help
mailing list