diff mbox series

driver/101383 - handle -gtoggle in driver

Message ID p17p7o-28o1-271o-6950-42oq6rnrs42@fhfr.qr
State New
Headers show
Series driver/101383 - handle -gtoggle in driver | expand

Commit Message

Richard Biener July 9, 2021, 9:32 a.m. UTC
The driver amends assembler options with for example --gdwarf-5
when debugging is enabled but the check for that does not consider
the effect of -gtoggle which is not handled in the common option
machinery.  The following alters debug_info_level according to
-gtoggle mimicing what process_options later does in the compiler.

This in particular avoids changing of the cc1-checksum with every
bootstrap (debug) cycle as we compute that from stage2 where we
use -g -gtoggle but with --gdwarf-5 and no debug info from the
compiler the assembler will fill the line table with the temporary
assembler file names.

Bootstrap and regtest pending on x86_64-unknown-linux-gnu, OK?

I've sofar verified the patch has the desired effect on --gdwarf-5
passing to the assembler for gcc -c t.c, gcc -c t.c -gtoggle,
gcc -c t.c -g -gtoggle and gcc -c t.c -g

Thanks,
Richard.

2021-07-09  Richard Biener  <rguenther@suse.de>

	PR driver/101383
	* gcc.c (process_command): Process -gtoggle like process_options
	would after parsing options.
---
 gcc/gcc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Richard Biener July 14, 2021, 7:43 a.m. UTC | #1
On Fri, Jul 9, 2021 at 11:32 AM Richard Biener <rguenther@suse.de> wrote:
>
> The driver amends assembler options with for example --gdwarf-5
> when debugging is enabled but the check for that does not consider
> the effect of -gtoggle which is not handled in the common option
> machinery.  The following alters debug_info_level according to
> -gtoggle mimicing what process_options later does in the compiler.
>
> This in particular avoids changing of the cc1-checksum with every
> bootstrap (debug) cycle as we compute that from stage2 where we
> use -g -gtoggle but with --gdwarf-5 and no debug info from the
> compiler the assembler will fill the line table with the temporary
> assembler file names.
>
> Bootstrap and regtest pending on x86_64-unknown-linux-gnu, OK?
>
> I've sofar verified the patch has the desired effect on --gdwarf-5
> passing to the assembler for gcc -c t.c, gcc -c t.c -gtoggle,
> gcc -c t.c -g -gtoggle and gcc -c t.c -g

Bootstrapped / tested on x86_64-unknown-linux-gnu, the reporter
confirmed the patch fixes his issue (different cc1 executables when
repeatedly bootstrapping GCC 11).

Thus early ping - I'd like to get this fixed for 11.2.

OK?

Thanks,
Richard.


> Thanks,
> Richard.
>
> 2021-07-09  Richard Biener  <rguenther@suse.de>
>
>         PR driver/101383
>         * gcc.c (process_command): Process -gtoggle like process_options
>         would after parsing options.
> ---
>  gcc/gcc.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/gcc/gcc.c b/gcc/gcc.c
> index 36a88fc99b0..6c7a4847c43 100644
> --- a/gcc/gcc.c
> +++ b/gcc/gcc.c
> @@ -4924,6 +4924,16 @@ process_command (unsigned int decoded_options_count,
>  #endif
>      }
>
> +  /* Handle -gtoggle as it would later in toplev.c:process_options to
> +     make the debug-level-gt spec function work as expected.  */
> +  if (flag_gtoggle)
> +    {
> +      if (debug_info_level == DINFO_LEVEL_NONE)
> +       debug_info_level = DINFO_LEVEL_NORMAL;
> +      else
> +       debug_info_level = DINFO_LEVEL_NONE;
> +    }
> +
>    if (output_file
>        && strcmp (output_file, "-") != 0
>        && strcmp (output_file, HOST_BIT_BUCKET) != 0)
> --
> 2.26.2
Joseph Myers July 14, 2021, 3:37 p.m. UTC | #2
This patch is OK.
diff mbox series

Patch

diff --git a/gcc/gcc.c b/gcc/gcc.c
index 36a88fc99b0..6c7a4847c43 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -4924,6 +4924,16 @@  process_command (unsigned int decoded_options_count,
 #endif
     }
 
+  /* Handle -gtoggle as it would later in toplev.c:process_options to
+     make the debug-level-gt spec function work as expected.  */
+  if (flag_gtoggle)
+    {
+      if (debug_info_level == DINFO_LEVEL_NONE)
+	debug_info_level = DINFO_LEVEL_NORMAL;
+      else
+	debug_info_level = DINFO_LEVEL_NONE;
+    }
+
   if (output_file
       && strcmp (output_file, "-") != 0
       && strcmp (output_file, HOST_BIT_BUCKET) != 0)