~ubuntu-branches/debian/sid/gcc-4.8/sid

« back to all changes in this revision

Viewing changes to .svn/pristine/7b/7b90c55163d82919e218df1efdd7c6f10ad66f49.svn-base

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-12-19 19:48:34 UTC
  • Revision ID: package-import@ubuntu.com-20141219194834-4dz1q7rrn5pad823
Tags: 4.8.4-1
* GCC 4.8.4 release.
  - Fix PR target/61407 (darwin), PR middle-end/58624 (ice),
    PR sanitizer/64265 (wrong code).
* Require recent binutils to pass go test failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# DP: Retry the build on an ice, save the calling options and preprocessed
 
2
# DP: source when the ice is reproducible.
 
3
 
 
4
2004-01-23  Jakub Jelinek  <jakub@redhat.com>
 
5
 
 
6
        * gcc.c (execute): Don't free first string early, but at the end
 
7
        of the function.  Call retry_ice if compiler exited with
 
8
        ICE_EXIT_CODE.
 
9
        (retry_ice): New function.
 
10
        * diagnostic.c (diagnostic_count_diagnostic,
 
11
        diagnostic_action_after_output, error_recursion): Exit with
 
12
        ICE_EXIT_CODE instead of FATAL_EXIT_CODE.
 
13
 
 
14
#--- a/src/gcc/Makefile.in
 
15
#+++ b/src/gcc/Makefile.in
 
16
#@@ -181,6 +181,8 @@ SYSCALLS.c.X-warn = -Wno-strict-prototypes -Wno-error
 
17
# dfp.o-warn = -Wno-error
 
18
# # mips-tfile.c contains -Wcast-qual warnings.
 
19
# mips-tfile.o-warn = -Wno-error
 
20
#+# gcc-ice-hack
 
21
#+gcc.o-warn = -Wno-error
 
22
 
23
# # All warnings have to be shut off in stage1 if the compiler used then
 
24
# # isn't gcc; configure determines that.  WARN_CFLAGS will be either
 
25
Index: b/src/gcc/gcc.c
 
26
===================================================================
 
27
--- a/src/gcc/gcc.c
 
28
+++ b/src/gcc/gcc.c
 
29
@@ -249,6 +249,9 @@
 
30
 #if defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
 
31
 static const char *convert_filename (const char *, int, int);
 
32
 #endif
 
33
+#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS))
 
34
+static void retry_ice (const char *prog, const char **argv);
 
35
+#endif
 
36
 
 
37
 static const char *getenv_spec_function (int, const char **);
 
38
 static const char *if_exists_spec_function (int, const char **);
 
39
@@ -2771,7 +2774,7 @@
 
40
            }
 
41
        }
 
42
 
 
43
-      if (string != commands[i].prog)
 
44
+      if (i && string != commands[i].prog)
 
45
        free (CONST_CAST (char *, string));
 
46
     }
 
47
 
 
48
@@ -2824,6 +2827,16 @@
 
49
        else if (WIFEXITED (status)
 
50
                 && WEXITSTATUS (status) >= MIN_FATAL_STATUS)
 
51
          {
 
52
+#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS))
 
53
+           /* For ICEs in cc1, cc1obj, cc1plus see if it is
 
54
+              reproducible or not.  */
 
55
+           const char *p;
 
56
+           if (WEXITSTATUS (status) == ICE_EXIT_CODE
 
57
+               && i == 0
 
58
+               && (p = strrchr (commands[0].argv[0], DIR_SEPARATOR))
 
59
+               && ! strncmp (p + 1, "cc1", 3))
 
60
+             retry_ice (commands[0].prog, commands[0].argv);
 
61
+#endif
 
62
            if (WEXITSTATUS (status) > greatest_status)
 
63
              greatest_status = WEXITSTATUS (status);
 
64
            ret_code = -1;
 
65
@@ -2881,6 +2894,9 @@
 
66
          }
 
67
       }
 
68
 
 
69
+    if (commands[0].argv[0] != commands[0].prog)
 
70
+      free (CONST_CAST (char *, commands[0].argv[0]));
 
71
+
 
72
     return ret_code;
 
73
   }
 
74
 }
 
75
@@ -6034,6 +6050,227 @@
 
76
   switches[switchnum].validated = true;
 
77
 }
 
78
 
 
79
+#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS))
 
80
+#define RETRY_ICE_ATTEMPTS 2
 
81
+
 
82
+static void
 
83
+retry_ice (const char *prog, const char **argv)
 
84
+{
 
85
+  int nargs, out_arg = -1, quiet = 0, attempt;
 
86
+  int pid, retries, sleep_interval;
 
87
+  const char **new_argv;
 
88
+  char *temp_filenames[RETRY_ICE_ATTEMPTS * 2 + 2];
 
89
+
 
90
+  if (gcc_input_filename == NULL || ! strcmp (gcc_input_filename, "-"))
 
91
+    return;
 
92
+
 
93
+  for (nargs = 0; argv[nargs] != NULL; ++nargs)
 
94
+    /* Only retry compiler ICEs, not preprocessor ones.  */
 
95
+    if (! strcmp (argv[nargs], "-E"))
 
96
+      return;
 
97
+    else if (argv[nargs][0] == '-' && argv[nargs][1] == 'o')
 
98
+      {
 
99
+       if (out_arg == -1)
 
100
+         out_arg = nargs;
 
101
+       else
 
102
+         return;
 
103
+      }
 
104
+    /* If the compiler is going to output any time information,
 
105
+       it might varry between invocations.  */
 
106
+    else if (! strcmp (argv[nargs], "-quiet"))
 
107
+      quiet = 1;
 
108
+    else if (! strcmp (argv[nargs], "-ftime-report"))
 
109
+      return;
 
110
+
 
111
+  if (out_arg == -1 || !quiet)
 
112
+    return;
 
113
+
 
114
+  memset (temp_filenames, '\0', sizeof (temp_filenames));
 
115
+  new_argv = XALLOCAVEC (const char *, nargs + 3);
 
116
+  memcpy (new_argv, argv, (nargs + 1) * sizeof (const char *));
 
117
+  new_argv[nargs++] = "-frandom-seed=0";
 
118
+  new_argv[nargs] = NULL;
 
119
+  if (new_argv[out_arg][2] == '\0')
 
120
+    new_argv[out_arg + 1] = "-";
 
121
+  else
 
122
+    new_argv[out_arg] = "-o-";
 
123
+
 
124
+  for (attempt = 0; attempt < RETRY_ICE_ATTEMPTS + 1; ++attempt)
 
125
+    {
 
126
+      int fd = -1;
 
127
+      int status;
 
128
+
 
129
+      temp_filenames[attempt * 2] = make_temp_file (".out");
 
130
+      temp_filenames[attempt * 2 + 1] = make_temp_file (".err");
 
131
+
 
132
+      if (attempt == RETRY_ICE_ATTEMPTS)
 
133
+        {
 
134
+         int i;
 
135
+         int fd1, fd2;
 
136
+         struct stat st1, st2;
 
137
+         size_t n, len;
 
138
+         char *buf;
 
139
+
 
140
+         buf = XNEWVEC (char, 8192);
 
141
+
 
142
+         for (i = 0; i < 2; ++i)
 
143
+           {
 
144
+             fd1 = open (temp_filenames[i], O_RDONLY);
 
145
+             fd2 = open (temp_filenames[2 + i], O_RDONLY);
 
146
+
 
147
+             if (fd1 < 0 || fd2 < 0)
 
148
+               {
 
149
+                 i = -1;
 
150
+                 close (fd1);
 
151
+                 close (fd2);
 
152
+                 break;
 
153
+               }
 
154
+
 
155
+             if (fstat (fd1, &st1) < 0 || fstat (fd2, &st2) < 0)
 
156
+               {
 
157
+                 i = -1;
 
158
+                 close (fd1);
 
159
+                 close (fd2);
 
160
+                 break;
 
161
+               }
 
162
+
 
163
+             if (st1.st_size != st2.st_size)
 
164
+               {
 
165
+                 close (fd1);
 
166
+                 close (fd2);
 
167
+                 break;
 
168
+               }
 
169
+
 
170
+             len = 0;
 
171
+             for (n = st1.st_size; n; n -= len)
 
172
+               {
 
173
+                 len = n;
 
174
+                 if (len > 4096)
 
175
+                   len = 4096;
 
176
+
 
177
+                 if (read (fd1, buf, len) != (int) len
 
178
+                     || read (fd2, buf + 4096, len) != (int) len)
 
179
+                   {
 
180
+                     i = -1;
 
181
+                     break;
 
182
+                   }
 
183
+
 
184
+                 if (memcmp (buf, buf + 4096, len) != 0)
 
185
+                   break;
 
186
+               }
 
187
+
 
188
+             close (fd1);
 
189
+             close (fd2);
 
190
+
 
191
+             if (n)
 
192
+               break;
 
193
+           }
 
194
+
 
195
+         free (buf);
 
196
+         if (i == -1)
 
197
+           break;
 
198
+
 
199
+         if (i != 2)
 
200
+           {
 
201
+             fnotice (stderr, "The bug is not reproducible, so it is"
 
202
+                              " likely a hardware or OS problem.\n");
 
203
+             break;
 
204
+           }
 
205
+
 
206
+          fd = open (temp_filenames[attempt * 2], O_RDWR);
 
207
+         if (fd < 0)
 
208
+           break;
 
209
+         write (fd, "//", 2);
 
210
+         for (i = 0; i < nargs; i++)
 
211
+           {
 
212
+             write (fd, " ", 1);
 
213
+             write (fd, new_argv[i], strlen (new_argv[i]));
 
214
+           }
 
215
+         write (fd, "\n", 1);
 
216
+         new_argv[nargs] = "-E";
 
217
+         new_argv[nargs + 1] = NULL;
 
218
+        }
 
219
+
 
220
+      /* Fork a subprocess; wait and retry if it fails.  */
 
221
+      sleep_interval = 1;
 
222
+      pid = -1;
 
223
+      for (retries = 0; retries < 4; retries++)
 
224
+       {
 
225
+         pid = fork ();
 
226
+         if (pid >= 0)
 
227
+           break;
 
228
+         sleep (sleep_interval);
 
229
+         sleep_interval *= 2;
 
230
+       }
 
231
+
 
232
+      if (pid < 0)
 
233
+       break;
 
234
+      else if (pid == 0)
 
235
+       {
 
236
+         if (attempt != RETRY_ICE_ATTEMPTS)
 
237
+           fd = open (temp_filenames[attempt * 2], O_RDWR);
 
238
+         if (fd < 0)
 
239
+           exit (-1);
 
240
+         if (fd != 1)
 
241
+           {
 
242
+             close (1);
 
243
+             dup (fd);
 
244
+             close (fd);
 
245
+           }
 
246
+
 
247
+         fd = open (temp_filenames[attempt * 2 + 1], O_RDWR);
 
248
+         if (fd < 0)
 
249
+           exit (-1);
 
250
+         if (fd != 2)
 
251
+           {
 
252
+             close (2);
 
253
+             dup (fd);
 
254
+             close (fd);
 
255
+           }
 
256
+
 
257
+         if (prog == new_argv[0])
 
258
+           execvp (prog, CONST_CAST2 (char *const *, const char **, new_argv));
 
259
+         else
 
260
+           execv (new_argv[0], CONST_CAST2 (char *const *, const char **, new_argv));
 
261
+         exit (-1);
 
262
+       }
 
263
+
 
264
+      if (waitpid (pid, &status, 0) < 0)
 
265
+       break;
 
266
+
 
267
+      if (attempt < RETRY_ICE_ATTEMPTS
 
268
+         && (! WIFEXITED (status) || WEXITSTATUS (status) != ICE_EXIT_CODE))
 
269
+       {
 
270
+         fnotice (stderr, "The bug is not reproducible, so it is"
 
271
+                          " likely a hardware or OS problem.\n");
 
272
+         break;
 
273
+       }
 
274
+      else if (attempt == RETRY_ICE_ATTEMPTS)
 
275
+       {
 
276
+         close (fd);
 
277
+         if (WIFEXITED (status)
 
278
+             && WEXITSTATUS (status) == SUCCESS_EXIT_CODE)
 
279
+           {
 
280
+             fnotice (stderr, "Preprocessed source stored into %s file,"
 
281
+                              " please attach this to your bugreport.\n",
 
282
+                      temp_filenames[attempt * 2]);
 
283
+             /* Make sure it is not deleted.  */
 
284
+             free (temp_filenames[attempt * 2]);
 
285
+             temp_filenames[attempt * 2] = NULL;
 
286
+             break;
 
287
+           }
 
288
+       }
 
289
+    }
 
290
+
 
291
+  for (attempt = 0; attempt < RETRY_ICE_ATTEMPTS * 2 + 2; attempt++)
 
292
+    if (temp_filenames[attempt])
 
293
+      {
 
294
+       unlink (temp_filenames[attempt]);
 
295
+       free (temp_filenames[attempt]);
 
296
+      }
 
297
+}
 
298
+#endif
 
299
+
 
300
 /* Search for a file named NAME trying various prefixes including the
 
301
    user's -B prefix and some standard ones.
 
302
    Return the absolute file name found.  If nothing is found, return NAME.  */
 
303
Index: b/src/gcc/diagnostic.c
 
304
===================================================================
 
305
--- a/src/gcc/diagnostic.c
 
306
+++ b/src/gcc/diagnostic.c
 
307
@@ -455,7 +455,7 @@
 
308
        real_abort ();
 
309
       diagnostic_finish (context);
 
310
       fnotice (stderr, "compilation terminated.\n");
 
311
-      exit (FATAL_EXIT_CODE);
 
312
+      exit (ICE_EXIT_CODE);
 
313
 
 
314
     default:
 
315
       gcc_unreachable ();