This is the mail archive of the gcc-prs@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: preprocessor/3951: need for -MF w/ -M breaks backward compat. w/ documented features.


The following reply was made to PR preprocessor/3951; it has been noted by GNATS.

From: Neil Booth <neil@daikokuya.demon.co.uk>
To: cgd@broadcom.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: preprocessor/3951: need for -MF w/ -M breaks backward compat. w/ documented features.
Date: Sat, 23 Mar 2002 13:16:56 +0000

 I've cc-ed GNATS.
 
 Chris G. Demetriou wrote:-
 
 > On further testing, not sure that all is happy in 3.0.x with the
 > matches that you made.  (I didn't cc the list/gnats on this, but if
 > you'd like feel free to fwd this msg there.)
 > 
 > 
 > It could be that i've goofed them up applying them to my source tree,
 > but I don't _think_ I did.
 > 
 > 
 > For a file foo.c and foo.S with 'junk' contents, what does:
 > 
 > 	gcc -MMD -c -o foo.o $@
 > 
 > produce for you?
 > 
 > similarly, what if you say "-E" instead of -c?
 > 
 > 
 > in my little world, for the .c / -c case, things are fine.
 > 
 > for the .c / -E, .S / -c, and .S / -E cases, the the preprocessed
 > output is zero-length (leading to ... not the right thing in the .S /
 > -c case, especially 8-).
 
 Wah! It works now! And with -save-temps!!  Happy!!!  I've done
 everything I can think of to break it, and compared everything with
 2.95.4; and it's all matching.
 
 The final patch I sent you seems to be the holy grail.  It gets the
 above right, fixes the 2.95 issues we wanted to avoid, and handles -MF,
 -MQ and -MT like we want.  For the benefit of GNATS, I'll reproduce the
 patch below.  If you could confirm this fixes this issue once and for
 all, I'll apply it to all 3 trees.
 
 Thanks for persevering!
 
 Neil.
 
 Index: gcc.c
 ===================================================================
 RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
 retrieving revision 1.205.2.26
 diff -u -p -r1.205.2.26 gcc.c
 --- gcc.c	2002/03/11 21:38:14	1.205.2.26
 +++ gcc.c	2002/03/23 12:07:37
 @@ -596,8 +596,8 @@ static const char *cpp_options =
  "%{C:%{!E:%eGNU C does not support -C without using -E}}\
   %{std*} %{nostdinc*}\
   %{C} %{v} %{I*} %{P} %{$} %I\
 - %{MD:-M -MF %W{!o: %b.d}%W{o*:%.d%*}}\
 - %{MMD:-MM -MF %W{!o: %b.d}%W{o*:%.d%*}}\
 + %{MD:-MD %W{!o: %b.d}%W{o*:%.d%*}}\
 + %{MMD:-MMD %W{!o: %b.d}%W{o*:%.d%*}}\
   %{M} %{MM} %W{MF*} %{MG} %{MP} %{MQ*} %{MT*}\
   %{!E:%{!M:%{!MM:%{MD|MMD:%{o*:-MQ %*}}}}}\
   %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2 -D__GNUC_PATCHLEVEL__=%v3}\
 Index: cppinit.c
 ===================================================================
 RCS file: /cvs/gcc/gcc/gcc/cppinit.c,v
 retrieving revision 1.147.2.12
 diff -u -p -r1.147.2.12 cppinit.c
 --- cppinit.c	2002/03/11 21:38:18	1.147.2.12
 +++ cppinit.c	2002/03/23 12:07:41
 @@ -1459,10 +1459,16 @@ cpp_handle_option (pfile, argc, argv)
  	  CPP_OPTION (pfile, print_deps_missing_files) = 1;
  	  break;
  	case OPT_M:
 +	  /* When doing dependencies with -M or -MM, suppress normal
 +	     preprocessed output, but still do -dM etc. as software
 +	     depends on this.  Preprocessed output occurs if -MD, -MMD
 +	     or environment var dependency generation is used.  */
  	  CPP_OPTION (pfile, print_deps) = 2;
 +	  CPP_OPTION (pfile, no_output) = 1;
  	  break;
  	case OPT_MM:
  	  CPP_OPTION (pfile, print_deps) = 1;
 +	  CPP_OPTION (pfile, no_output) = 1;
  	  break;
  	case OPT_MF:
  	  CPP_OPTION (pfile, deps_file) = arg;
 @@ -1476,12 +1482,6 @@ cpp_handle_option (pfile, argc, argv)
  	  deps_add_target (pfile->deps, arg, opt_code == OPT_MQ);
  	  break;
  
 -	  /* -MD and -MMD for cpp0 are deprecated and undocumented
 -	     (use -M or -MM with -MF instead), and probably should be
 -	     removed with the next major GCC version.  For the moment
 -	     we allow these for the benefit of Automake 1.4, which
 -	     uses these when dependency tracking is enabled.  Automake
 -	     1.5 will fix this.  */
  	case OPT_MD:
  	  CPP_OPTION (pfile, print_deps) = 2;
  	  CPP_OPTION (pfile, deps_file) = arg;
 @@ -1786,10 +1786,6 @@ init_dependency_output (pfile)
      /* If -M or -MM was seen, default output to wherever was specified
         with -o.  out_fname is non-NULL here.  */
      CPP_OPTION (pfile, deps_file) = CPP_OPTION (pfile, out_fname);
 -
 -  /* When doing dependencies, suppress normal preprocessed output.
 -     Still do -dM, -dI etc. as e.g. glibc depends on this.  */
 -  CPP_OPTION (pfile, no_output) = 1;
  }
  
  static void


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