This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Changes to gcc 3.x to invoke an external cpp



Earlier today, I sent in a change for invoking an external cpp during 
compilation.  However, the change listed below is preferable as it is 
a cleaner implementation.


Description:

As of gcc 3.x, cpp has been (partially) integrated into the compiler. I say
partially because there are exceptions: in gcc (-traditional/-save-temps) and
g++ (-save-temps) do not use the integrated cpp. For the past 10 years, we have
been developing concurrency software that piggy-backs on g++ (uC++). This
software uses an additional preprocessor to change the source text *after*
being processed by cpp. For the past 10 years, we have used the -B flag to
supply our own cpp driver that first invokes the standard cpp and then our cpp.
This mechanism is ideal because it uses the logic in g++ to parse and
understand all the command line flags and files, making our job as simple as
possible.  However, with the integrated cpp, we can no longer use this
mechanism as our user-supplied cpp in the -B directory is no longer invoked
unless the -save-temps flag is used, which produces unnecessary files so this
is not a clean solution. Therefore, we need a mechanism in g++ to invoke an
external preprocessor during a compilation, that is, we need the old behaviour
of the -B flag back. We could use -traditional-cpp and name our cpp "tradcpp",
but -traditional-cpp does not work with g++. Suffice it to say we are in a
major panic with respect to this new change because its effect on us is
extreme.

Given that the behaviour we need is largely still in place (via -traditional
and -save-temps), we would like to suggest the following change to bring back
the prior behaviour available through the -B flag. We added an additional flag
to gcc/g++ (similar to the -traditional-cpp flag) to force the use of the cpp
in the -B directory.  The temporary name for the flag is -zzzz-cpp.  We tried
-external-cpp, but this conflicts with the -e flag.  Perhaps someone who is
more familiar with flag naming-conventions can suggest an appropriate
name. Maybe -user-cpp or -fexternal-cpp. We don't care what it's called!

Now we are not experts at changing gcc, so there may be some details that still
need to be addressed, but these changes seem to give the desired result while
still preserving the semantics of the -traditional/-save-temps flags.


Testcases:

As the changes relate strictly to the command line interface, the testcases 
would simply invoke gcc/g++ with different combinations involving -zzzz-cpp,
-save-temps and -traditional.  I am not sure how to specify these types of
tests.  However, if you provide me with some guidance I can create some
testcases.


ChangeLog:

2001-11-29  Ashif Harji  <asharji@uwaterloo.ca>

	* gcc.c(static struct compiler default_compilers[]): added -zzzz-cpp flag 
               to invoke an external cpp during compilation.
          (struct option_map option_map[]): likewise
	* cp/lang-specs.h(static struct compiler default_compilers[]): added 
               -zzzz-cpp flag to invoke an external cpp during compilation.

Bootstrapping and Testing:

On i686-pc-linux-gnu:
   - bootstrap was successful
   - no changes in testsuite results when compared to original (gcc 3.0.2)



Patch:

1>@awk[108]% diff -c3p gcc-3.0.2/gcc/gcc.c test/gcc-3.0.2/gcc/gcc.c 
diff -c3p gcc-3.0.2/gcc/gcc.c test/gcc-3.0.2/gcc/gcc.c 
*** gcc-3.0.2/gcc/gcc.c Tue Oct  2 19:12:34 2001
--- test/gcc-3.0.2/gcc/gcc.c    Fri Nov 30 01:49:44 2001
*************** static struct compiler default_compilers
*** 756,762 ****
                tradcpp0 -lang-c %{ansi:-std=c89} %(cpp_options) %{!pipe:%g.i} |\n\
                    cc1 -fpreprocessed %{!pipe:%g.i} %(cc1_options)}\
            %{!traditional:%{!ftraditional:%{!traditional-cpp:\
!               cc1 -lang-c %{ansi:-std=c89} %(cpp_options) %(cc1_options)}}}}\
          %{!fsyntax-only:%(invoke_as)}}}}", 0},
    {"-",
     "%{!E:%e-E required when input is from standard input}\
--- 756,766 ----
                tradcpp0 -lang-c %{ansi:-std=c89} %(cpp_options) %{!pipe:%g.i} |\n\
                    cc1 -fpreprocessed %{!pipe:%g.i} %(cc1_options)}\
            %{!traditional:%{!ftraditional:%{!traditional-cpp:\
!               %{zzzz-cpp:\
!                   %(trad_capable_cpp) -lang-c %{ansi:-std=c89} %(cpp_options) %{!pipe:%g.i} |\n\
!                       cc1 -fpreprocessed %{!pipe:%g.i} %(cc1_options)}\
!               %{!zzzz-cpp:\
!                   cc1 -lang-c %{ansi:-std=c89} %(cpp_options) %(cc1_options)}}}}}\
          %{!fsyntax-only:%(invoke_as)}}}}", 0},
    {"-",
     "%{!E:%e-E required when input is from standard input}\
*************** struct option_map option_map[] =
*** 901,906 ****
--- 905,911 ----
     {"--warn-", "-W", "*j"},
     {"--write-dependencies", "-MD", 0},
     {"--write-user-dependencies", "-MMD", 0},
+    {"--zzzz-cpp", "-zzzz-cpp", 0},
     {"--", "-f", "*j"}
   };
  



1>@awk[160]% diff -c3p gcc-3.0.2/gcc/cp/lang-specs.h  test/gcc-3.0.2/gcc/cp/lang-specs.h
diff -c3p gcc-3.0.2/gcc/cp/lang-specs.h  test/gcc-3.0.2/gcc/cp/lang-specs.h
*** gcc-3.0.2/gcc/cp/lang-specs.h       Thu Jun  7 20:00:32 2001
--- test/gcc-3.0.2/gcc/cp/lang-specs.h  Fri Nov 30 14:42:42 2001
*************** Boston, MA 02111-1307, USA.  */
*** 41,60 ****
         %{!fno-new-abi:-D__GXX_ABI_VERSION=100}\
         %{ansi:-D__STRICT_ANSI__ -trigraphs -$} %(cpp_options)}\
       %{!E:%{!M:%{!MM:\
!        %{save-temps:cpp0 -lang-c++ \
                    %{!no-gcc:-D__GNUG__=%v1}\
                            %{!Wno-deprecated:-D__GXX_DEPRECATED}\
                    %{!fno-exceptions:-D__EXCEPTIONS}\
                    %{!fno-new-abi:-D__GXX_ABI_VERSION=100}\
                    %{ansi:-D__STRICT_ANSI__ -trigraphs -$}\
!                   %(cpp_options) %b.ii \n}\
!       cc1plus %{save-temps:-fpreprocessed %b.ii}\
!               %{!save-temps:%(cpp_options)\
                            %{!no-gcc:-D__GNUG__=%v1} \
                                    %{!Wno-deprecated:-D__GXX_DEPRECATED}\
                            %{!fno-exceptions:-D__EXCEPTIONS}\
                            %{!fno-new-abi:-D__GXX_ABI_VERSION=100}\
!                           %{ansi:-D__STRICT_ANSI__}}\
         %{ansi:-trigraphs -$}\
         %(cc1_options) %2 %{+e1*}\
         %{!fsyntax-only:%(invoke_as)}}}}",
--- 41,61 ----
         %{!fno-new-abi:-D__GXX_ABI_VERSION=100}\
         %{ansi:-D__STRICT_ANSI__ -trigraphs -$} %(cpp_options)}\
       %{!E:%{!M:%{!MM:\
!        %{save-temps|zzzz-cpp:cpp0 -lang-c++ \
                    %{!no-gcc:-D__GNUG__=%v1}\
                            %{!Wno-deprecated:-D__GXX_DEPRECATED}\
                    %{!fno-exceptions:-D__EXCEPTIONS}\
                    %{!fno-new-abi:-D__GXX_ABI_VERSION=100}\
                    %{ansi:-D__STRICT_ANSI__ -trigraphs -$}\
!                   %(cpp_options) %{save-temps:%b.ii} %{!save-temps:%g.ii}  \n}\
!       cc1plus %{save-temps|zzzz-cpp:-fpreprocessed %{save-temps:%b.ii} %{!save-temps:%g.ii}}\
!              %{!save-temps:%{!zzzz-cpp:\
!                      %(cpp_options)\
                            %{!no-gcc:-D__GNUG__=%v1} \
                                    %{!Wno-deprecated:-D__GXX_DEPRECATED}\
                            %{!fno-exceptions:-D__EXCEPTIONS}\
                            %{!fno-new-abi:-D__GXX_ABI_VERSION=100}\
!                           %{ansi:-D__STRICT_ANSI__}}}\
         %{ansi:-trigraphs -$}\
         %(cc1_options) %2 %{+e1*}\
         %{!fsyntax-only:%(invoke_as)}}}}",


thanks,
ashif harji


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]