This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
How to write a SPEC function that gets all arguments passed?
- From: Georg Lay <avr at gjlay dot de>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 02 Sep 2010 16:15:31 +0200
- Subject: How to write a SPEC function that gets all arguments passed?
Hi, when calling gcc with -frecord-gcc-switch the options passed to cc1
will differ depending on if -save-temps is present or not. E.g. if
calling gcc foo.c -I Z -DX=... -UY ...
in the forst case (with -save-temps) options_passed is: "-fpreprocessed
foo.i ..."
in the second case (without -save-temps) options_passed is: "-IZ
-isystem ... -iprefix ... -DX=... -UY foo.c ..."
What is relevant to the user is the second string because that is the
way he calls gcc. What's internally going on when -save-temps is present
should be transparent. Therefore, I am looking for a way to pass the
arguments from gcc to cc1 and tried to implement this with the help of
some spec function. But I could not find out how to actually write down
the specs.
My idea was to add a spec function to DRIVER_SELF_SPECS that collects
all options and passes them as a string to cc1, but there seem to be no
way to call the function like
%{*:%:my_record_switches(%*)}
or
%:my_record_switches(%(cpp_options))
I also tries to use the %Z that collects all options but eigher I get
NULL as input or the thing crashes.
What am I missing?
Moreover, there will be a problem because the C function that actually
implements my_record_switches must return a string starting with '-',
there is no way to return "" or NULL to indicate that the function won't
produce anything.
Would anyone guide me through that specs jungle?
Georg