public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Georg Lay <avr@gjlay.de>
To: gcc@gcc.gnu.org
Subject: How to write a SPEC function that gets all arguments passed?
Date: Thu, 02 Sep 2010 14:15:00 -0000	[thread overview]
Message-ID: <4C7FB183.1070008@gjlay.de> (raw)

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

             reply	other threads:[~2010-09-02 14:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-02 14:15 Georg Lay [this message]
2010-09-08  0:23 ` Ian Lance Taylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C7FB183.1070008@gjlay.de \
    --to=avr@gjlay.de \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).