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: [PATCH] Avoid generating code when writing PCH (PR c++/72813)


OK.

On Tue, Jan 10, 2017 at 5:33 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> The comments in both the C and C++ FEs say that after writing PCH file
> when --output-pch= is used, we don't want to do anything else and the
> routines return to the caller early, especially for C++ FE skipping lots of
> needed handling for code generation.  But, nothing is signalled to the
> callers, so we actually continue with the full optimization pipeline and
> generate assembly.  Because some important parts have been skipped, we
> can generate errors though.
>
> Normally, the *.s file is thrown away and not used further, only when
> -S or -save-temps is used, it is preserved.
>
> One option would be (patch in the PR) not to skip anything and continue
> writing, but as Richard mentioned on IRC, emitting assembly for the header
> makes really no sense.  So this patch just does what the comment say,
> by setting flag_syntax_only after writing the PCH file tell callers not to
> perform cgraph finalization.
>
> In addition to that, the patch also extends the r237955 fix to -S
> -save-temps, so that we don't error out on that.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2017-01-10  Jakub Jelinek  <jakub@redhat.com>
>
>         PR c++/72813
>         * gcc.c (default_compilers): Don't add -o %g.s for -S -save-temps
>         of c-header.
>
>         * c-decl.c (pop_file_scope): Set flag_syntax_only to 1 after writing
>         PCH file.
>
>         * decl2.c (c_parse_final_cleanups): Set flag_syntax_only to 1 after
>         writing PCH file.
>
> --- gcc/gcc.c.jj        2017-01-09 17:22:24.000000000 +0100
> +++ gcc/gcc.c   2017-01-10 10:42:52.893462294 +0100
> @@ -1328,7 +1328,7 @@ static const struct compiler default_com
>                 %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\
>                     cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \
>                         %(cc1_options)\
> -                       %{!fsyntax-only:-o %g.s \
> +                       %{!fsyntax-only:%{!S:-o %g.s} \
>                             %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\
>                                                %W{o*:--output-pch=%*}}%V}}\
>           %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\
> --- gcc/c/c-decl.c.jj   2017-01-01 12:45:46.000000000 +0100
> +++ gcc/c/c-decl.c      2017-01-10 10:42:07.387043153 +0100
> @@ -1420,6 +1420,8 @@ pop_file_scope (void)
>    if (pch_file)
>      {
>        c_common_write_pch ();
> +      /* Ensure even the callers don't try to finalize the CU.  */
> +      flag_syntax_only = 1;
>        return;
>      }
>
> --- gcc/cp/decl2.c.jj   2017-01-08 17:41:18.000000000 +0100
> +++ gcc/cp/decl2.c      2017-01-10 10:41:47.539296496 +0100
> @@ -4461,6 +4461,8 @@ c_parse_final_cleanups (void)
>           DECL_ASSEMBLER_NAME (node->decl);
>        c_common_write_pch ();
>        dump_tu ();
> +      /* Ensure even the callers don't try to finalize the CU.  */
> +      flag_syntax_only = 1;
>        return;
>      }
>
>
>         Jakub


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