summaryrefslogtreecommitdiff
path: root/debian/patches/gcc-lto-pick-compile-time-g.diff
blob: 3cbf48e67eeeb69b2fd78a0d63675aed15c93bed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# DP: Make LTO link pick up compile-time -g

https://gcc.gnu.org/ml/gcc-patches/2019-09/msg00501.html

2019-09-09  Richard Biener  <rguenther@suse.de>

	* lto-opts.c (lto_write_options): Stream -g when debug is enabled.
	* lto-wrapper.c (merge_and_complain): Pick up -g.
	(append_compiler_options): Likewise.
	(run_gcc): Re-instantiate handling -g0 at link-time.
	* doc/invoke.texi (flto): Document debug info generation.

--- a/src/gcc/lto-opts.c
+++ b/src/gcc/lto-opts.c
@@ -94,6 +94,10 @@ lto_write_options (void)
 				      : "-fno-pie");
     }
 
+  /* If debug info is enabled append -g.  */
+  if (debug_info_level > DINFO_LEVEL_NONE)
+    append_to_collect_gcc_options (&temporary_obstack, &first_p, "-g");
+
   /* Append options from target hook and store them to offload_lto section.  */
   if (lto_stream_offload_p)
     {
--- a/src/gcc/lto-wrapper.c
+++ b/src/gcc/lto-wrapper.c
@@ -265,6 +265,7 @@ merge_and_complain (struct cl_decoded_op
 	case OPT_fshow_column:
 	case OPT_fcommon:
 	case OPT_fgnu_tm:
+	case OPT_g:
 	  /* Do what the old LTO code did - collect exactly one option
 	     setting per OPT code, we pick the first we encounter.
 	     ???  This doesn't make too much sense, but when it doesn't
@@ -617,6 +618,7 @@ append_compiler_options (obstack *argv_o
 	case OPT_fopenacc:
 	case OPT_fopenacc_dim_:
 	case OPT_foffload_abi_:
+	case OPT_g:
 	case OPT_O:
 	case OPT_Ofast:
 	case OPT_Og:
@@ -1399,6 +1401,10 @@ run_gcc (unsigned argc, char *argv[])
 	  linker_output_rel = !strcmp (option->arg, "rel");
 	  break;
 
+	case OPT_g:
+	  /* Recognize -g0.  */
+	  skip_debug = option->arg && !strcmp (option->arg, "0");
+	  break;
 
 	default:
 	  break;