From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25592 invoked by alias); 2 Sep 2010 14:15:43 -0000 Received: (qmail 25560 invoked by uid 22791); 2 Sep 2010 14:15:42 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mo-p00-ob.rzone.de (HELO mo-p00-ob.rzone.de) (81.169.146.162) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Sep 2010 14:15:34 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT2k715jHQaJercGObUOFkj18odoYNahU4Q== X-RZG-CLASS-ID: mo00 Received: from [192.168.0.22] (business-188-111-022-002.static.arcor-ip.net [188.111.22.2]) by post.strato.de (mrclete mo46) (RZmta 23.5) with ESMTP id D041a0m82CgvQU for ; Thu, 2 Sep 2010 16:15:32 +0200 (MEST) Message-ID: <4C7FB183.1070008@gjlay.de> Date: Thu, 02 Sep 2010 14:15:00 -0000 From: Georg Lay User-Agent: Thunderbird 2.0.0.24 (X11/20100302) MIME-Version: 1.0 To: gcc@gcc.gnu.org Subject: How to write a SPEC function that gets all arguments passed? Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2010-09/txt/msg00018.txt.bz2 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