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]

[PATCH re-RFA] include CC1-related specs when preprocessing.


[ resend of a patch submitted 2 weeks ago. ]

The patch below causes CC1-related specs to be passed to cc1 when
preprocessing.  This is necessary to insure that the cc1 invocation
doing the preprocessing has the right flags, so that it can set up the
appropriate CPP defines for the preprocessing (based on the original
command line flags).

There's some previous discussion of this issue in:

	http://gcc.gnu.org/ml/gcc/2002-06/msg00601.html

A quick test case to show what's going on here goes like:

* build a mips-elf cross compiler from current sources (i do it using
  a gcc+binutils+gdb/sim+dejagnu+newlib combined source tree).

* compile the following example:

	int foo = __mips_fpr;

  with:

	mips-elf-gcc -c foo.c
	mips-elf-gcc -S foo.c
	mips-elf-gcc -save-temps -c foo.c
	mips-elf-gcc -E foo.c

		-> note value is 32 in all cases, as it's supposed to be.

	mips-elf-gcc -c -mips64 foo.c
	mips-elf-gcc -S -mips64 foo.c

		-> note value is 64, as it's supposed to be.

	mips-elf-gcc -save-temps -c -mips64 foo.c
	mips-elf-gcc -E -mips64 foo.c

		-> note value is 32!

Normally, cc1_spec turns -mips64 into -mips64 -mfp64 -mgp64, and
without the "-mfp64" the __mips_fpr value is defined to 32 (the
default, based onthe default ISA of the compiler).  However, for the
cases where preprocessing is done independently of compilation, using
the new cc1-based preprocessor, cc1_spec isn't currently applied, and
so on.

Changing cpp_options to include cc1_spec hits all of the places where
cc1 is used for preprocessing (i.e., all of the languages), and also
takes care of the cc1 flags to cc1plus when cc1plus is used for
preprocessing.  Since the machine-dependent c++ spec may also effect
MD defines, for preprocessing of c++ I believe the cc1plus_spec must
also be added.


the gcc.c change was tested w/ check-gcc on mips-elf, mipsisa32-elf,
mipsisa64-elf, and mips64-elf cross from x86-linux, w/o no new
failures when tested on the sim.  the cp/lang-specs.h change was added
later, and tested only on a build from scratch + check of
mipsisa32-elf.  I don't really think that testing is adequate for a
change of this magnitude, but I can't easily test it more thoroughly
at this time.

Also, I'm not really sure that this is the Right Thing.  However, I
did run the general idea past neil & echristo, and they didn't recoil
in horror...  8-)


(as an aside, i grepped through definitions of CC1PLUS_SPEC, and i
note that m68k/m68k-psos.h seems to define it to be the same as
CC1_SPEC...  which seems redundant, since even before this change
whenever cc1plus_spec was applied cc1_spec would also be applied. Is
my understanding correct?  If so, I'd be glad to submit a patch --
which i can't possibly test -- for m68k-psos.h...)




chris
===================================================================
[ ChangeLog ]
2002-07-04  Chris Demetriou  <cgd@broadcom.com>

	* gcc.c (cpp_options): Include "%1" (cc1_spec).

[ cp/ChangeLog ]
2002-07-04  Chris Demetriou  <cgd@broadcom.com>

	* lang-specs.h (@c++): Include "%2" (cc1plus_spec) whever
	cpp_options is included.

Index: gcc.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.326
diff -u -p -r1.326 gcc.c
--- gcc.c	26 Jun 2002 02:58:51 -0000	1.326
+++ gcc.c	4 Jul 2002 06:42:11 -0000
@@ -691,9 +691,12 @@ static const char *cpp_unique_options =
  %{E|M|MM:%W{o*}}";
 
 /* This contains cpp options which are common with cc1_options and are passed
-   only when preprocessing only to avoid duplication.  */
+   only when preprocessing only to avoid duplication.  We pass the cc1 spec
+   options to the preprocessor so that it the cc1 spec may manipulate
+   options used to set target flags.  Those special target flags settings may
+   in turn cause preprocessor symbols to be defined specially.  */
 static const char *cpp_options =
-"%(cpp_unique_options) %{std*} %{W*&pedantic*} %{w} %{m*} %{f*}\
+"%(cpp_unique_options) %1 %{std*} %{W*&pedantic*} %{w} %{m*} %{f*}\
  %{O*} %{undef}";
 
 /* This contains cpp options which are not passed when the preprocessor
Index: cp/lang-specs.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cp/lang-specs.h,v
retrieving revision 1.49
diff -u -p -r1.49 lang-specs.h
--- cp/lang-specs.h	31 May 2002 21:01:25 -0000	1.49
+++ cp/lang-specs.h	4 Jul 2002 06:42:11 -0000
@@ -39,7 +39,7 @@ Boston, MA 02111-1307, USA.  */
        %{!Wno-deprecated:-D__DEPRECATED}\
        %{!fno-exceptions:-D__EXCEPTIONS}\
        -D__GXX_ABI_VERSION=100\
-       %{ansi:-D__STRICT_ANSI__ -trigraphs -$} %(cpp_options)\
+       %{ansi:-D__STRICT_ANSI__ -trigraphs -$} %(cpp_options) %2\
        %(cpp_debug_options)}\
      %{!E:%{!M:%{!MM:\
        %{save-temps:cc1plus -E \
@@ -48,7 +48,7 @@ Boston, MA 02111-1307, USA.  */
 		    %{!fno-exceptions:-D__EXCEPTIONS}\
 		    -D__GXX_ABI_VERSION=100\
 		    %{ansi:-D__STRICT_ANSI__ -trigraphs -$}\
-		    %(cpp_options) %b.ii \n}\
+		    %(cpp_options) %2 %b.ii \n}\
       cc1plus %{save-temps:-fpreprocessed %b.ii}\
               %{!save-temps:%(cpp_unique_options)\
 			    %{!no-gcc:-D__GNUG__=%v1} \




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