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: integrated -save-temps and the death of specs


Hi Aldy,

> i got very upset at specs files today and decided to start the painful
> process towards getting rid of them altogether.  eric sent me your
> post on the -E mode for ./cc1, and here's a patch that will hopefully
> start the ball rolling.

Great, I'm glad we've got another recruit towards killings specs.  There
are still some die-hards around though....

Thanks for looking at this.  I've some comments on your patch.

> my plan after this patch is to:
> 
> 	- change the master specs to use "./cc1 -E" instead of cpp0
> 	  (and use -fpreprocessed on the output).
 
Sounds good.

> 	- implement target macros to be called with a string of
> 	options, which will return additional options to pass to the
> 	assembler, linker, etc etc.  i'll provide memoizeable
> 	functions to read options, so we don't reparse the command
> 	options again and again.

You can't do this so quickly, otherwise the devoted users of tradcpp
will be after you.

We need an integrated tradcpp.  I want to get tradcpp into cpplib
again, and have some ideas on doing so.  So if some re-worked version
of your patch goes in, I'll make that my priority.

> how does this look?

In general, I think you're trying too hard; it should be possible to
get something with a small patch.  I originally intended cpplib handling
-E, but your way of handling it in cc1 is much nicer.

> 	* cppmain.c (do_preprocessing): Rename scan_translation_unit to
> 	cpp_scan_translation_unit.
> 	Rename check_multiline_token to cpp_check_multiline_token.
> 	Rename options to cpp_options.
> 	Rename maybe_print_line to cpp_maybe_print_line.
> 	Rename print_line to cpp_print_line.
> 	(scan_translation_unit): Move to cppoutput.c.
> 	(check_multiline_token): Same.
> 	(maybe_print_line): Same.
> 	(print_line): Same.
> 	(cb_line_change): Same.
> 	(cb_indent): Same.
> 	(cb_define): Same.
> 	(cb_undef): Same.
> 	(cb_include): Same.
> 	(cb_file_change): Same.
> 	(cb_def_pragma): Same.
> 	Rename uses of print to cpp_print.
> 	(struct printer): Move to cpplib.h and rename to
> 	cpp_printer.
> 	(options): Move to cpplib.h and rename to cpp_options_1.

I don't really like this.  Can I suggest instead, that

1) You kill main() and general_init() from cppmain.c
2) You kill the lines in do_preprocessing() down to but not including

  print.line = (unsigned int) -1;

and rename the function cpp_standard_preprocessing() or something like
that.  Make cppmain.c part of libcpp.

3) That this be called from c_common_parse_file instead of yyparse
   if -preprocessing_only?  Then you don't need to change the callbacks
   and everything should more or less "work".

I think the call to cpp_post_options in c_common_parse_file will need
a follow-up check of CPP_FATAL_ERRORS, just like the one you will have
deleted in do_preprocessing ().

Does this sound OK to you?  There are probably a couple of minor issues
I've missed, but roughly this should be enough.

> +   if (flag_preprocess_only)
> +     {
> +       cpp_cb_default_ident (pfile, line, str);
> +       return;
> +     }

You see, I don't think this is necessary.  You can hand it all over
to cpp_standard_preprocessing() or whatever you call it.  Then the
act of doing preprocessed output is still nicely logically separated,
and all still in cppmain.c.

Neil.


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