summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-ice-hack.dpatch
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-08-27 15:14:24 +0100
committerRichard Purdie <rpurdie@linux.intel.com>2010-08-27 15:29:45 +0100
commit29d6678fd546377459ef75cf54abeef5b969b5cf (patch)
tree8edd65790e37a00d01c3f203f773fe4b5012db18 /meta/recipes-devtools/gcc/gcc-4.5.0/gcc-ice-hack.dpatch
parentda49de6885ee1bc424e70bc02f21f6ab920efb55 (diff)
downloadpoky-29d6678fd546377459ef75cf54abeef5b969b5cf.tar.gz
Major layout change to the packages directory
Having one monolithic packages directory makes it hard to find things and is generally overwhelming. This commit splits it into several logical sections roughly based on function, recipes.txt gives more information about the classifications used. The opportunity is also used to switch from "packages" to "recipes" as used in OpenEmbedded as the term "packages" can be confusing to people and has many different meanings. Not all recipes have been classified yet, this is just a first pass at separating things out. Some packages are moved to meta-extras as they're no longer actively used or maintained. Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-4.5.0/gcc-ice-hack.dpatch')
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/gcc-ice-hack.dpatch331
1 files changed, 331 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-ice-hack.dpatch b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-ice-hack.dpatch
new file mode 100644
index 0000000000..84c5ef2ebd
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-ice-hack.dpatch
@@ -0,0 +1,331 @@
1#! /bin/sh -e
2
3# DP: Retry the build on an ice, save the calling options and preprocessed
4# DP: source when the ice is reproducible.
5
6dir=
7if [ $# -eq 3 -a "$2" = '-d' ]; then
8 pdir="-d $3"
9 dir="$3/"
10elif [ $# -ne 1 ]; then
11 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
12 exit 1
13fi
14case "$1" in
15 -patch)
16 patch $pdir -f --no-backup-if-mismatch -p0 < $0
17 ;;
18 -unpatch)
19 patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
20 ;;
21 *)
22 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
23 exit 1
24esac
25exit 0
26
272004-01-23 Jakub Jelinek <jakub@redhat.com>
28
29 * system.h (ICE_EXIT_CODE): Define.
30 * gcc.c (execute): Don't free first string early, but at the end
31 of the function. Call retry_ice if compiler exited with
32 ICE_EXIT_CODE.
33 (retry_ice): New function.
34 * diagnostic.c (diagnostic_count_diagnostic,
35 diagnostic_action_after_output, error_recursion): Exit with
36 ICE_EXIT_CODE instead of FATAL_EXIT_CODE.
37
38--- gcc/diagnostic.c.orig 2007-09-30 10:48:13.000000000 +0000
39+++ gcc/diagnostic.c 2007-09-30 10:49:57.000000000 +0000
40@@ -244,7 +244,7 @@
41 fnotice (stderr, "Please submit a full bug report,\n"
42 "with preprocessed source if appropriate.\n"
43 "See %s for instructions.\n", bug_report_url);
44- exit (ICE_EXIT_CODE);
45+ exit (FATAL_EXIT_CODE);
46
47 case DK_FATAL:
48 if (context->abort_on_error)
49--- gcc/gcc.c.orig 2007-09-30 10:48:13.000000000 +0000
50+++ gcc/gcc.c 2007-09-30 10:48:39.000000000 +0000
51@@ -357,6 +357,9 @@
52 #if defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
53 static const char *convert_filename (const char *, int, int);
54 #endif
55+#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS))
56+static void retry_ice (const char *prog, const char **argv);
57+#endif
58
59 static const char *getenv_spec_function (int, const char **);
60 static const char *if_exists_spec_function (int, const char **);
61@@ -2999,7 +3002,7 @@
62 }
63 }
64
65- if (string != commands[i].prog)
66+ if (i && string != commands[i].prog)
67 free (CONST_CAST (char *, string));
68 }
69
70@@ -3056,6 +3059,16 @@
71 else if (WIFEXITED (status)
72 && WEXITSTATUS (status) >= MIN_FATAL_STATUS)
73 {
74+#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS))
75+ /* For ICEs in cc1, cc1obj, cc1plus see if it is
76+ reproducible or not. */
77+ char *p;
78+ if (WEXITSTATUS (status) == ICE_EXIT_CODE
79+ && i == 0
80+ && (p = strrchr (commands[0].argv[0], DIR_SEPARATOR))
81+ && ! strncmp (p + 1, "cc1", 3))
82+ retry_ice (commands[0].prog, commands[0].argv);
83+#endif
84 if (WEXITSTATUS (status) > greatest_status)
85 greatest_status = WEXITSTATUS (status);
86 ret_code = -1;
87@@ -3076,6 +3089,9 @@
88 }
89 }
90
91+ if (commands[0].argv[0] != commands[0].prog)
92+ free ((PTR) commands[0].argv[0]);
93+
94 return ret_code;
95 }
96 }
97@@ -6016,6 +6032,224 @@
98 switches[switchnum].validated = 1;
99 }
100
101+#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS))
102+#define RETRY_ICE_ATTEMPTS 2
103+
104+static void
105+retry_ice (const char *prog, const char **argv)
106+{
107+ int nargs, out_arg = -1, quiet = 0, attempt;
108+ int pid, retries, sleep_interval;
109+ const char **new_argv;
110+ char *temp_filenames[RETRY_ICE_ATTEMPTS * 2 + 2];
111+
112+ if (input_filename == NULL || ! strcmp (input_filename, "-"))
113+ return;
114+
115+ for (nargs = 0; argv[nargs] != NULL; ++nargs)
116+ /* Only retry compiler ICEs, not preprocessor ones. */
117+ if (! strcmp (argv[nargs], "-E"))
118+ return;
119+ else if (argv[nargs][0] == '-' && argv[nargs][1] == 'o')
120+ {
121+ if (out_arg == -1)
122+ out_arg = nargs;
123+ else
124+ return;
125+ }
126+ /* If the compiler is going to output any time information,
127+ it might vary between invocations. */
128+ else if (! strcmp (argv[nargs], "-quiet"))
129+ quiet = 1;
130+ else if (! strcmp (argv[nargs], "-ftime-report"))
131+ return;
132+
133+ if (out_arg == -1 || !quiet)
134+ return;
135+
136+ memset (temp_filenames, '\0', sizeof (temp_filenames));
137+ new_argv = alloca ((nargs + 3) * sizeof (const char *));
138+ memcpy (new_argv, argv, (nargs + 1) * sizeof (const char *));
139+ new_argv[nargs++] = "-frandom-seed=0";
140+ new_argv[nargs] = NULL;
141+ if (new_argv[out_arg][2] == '\0')
142+ new_argv[out_arg + 1] = "-";
143+ else
144+ new_argv[out_arg] = "-o-";
145+
146+ for (attempt = 0; attempt < RETRY_ICE_ATTEMPTS + 1; ++attempt)
147+ {
148+ int fd = -1;
149+ int status;
150+
151+ temp_filenames[attempt * 2] = make_temp_file (".out");
152+ temp_filenames[attempt * 2 + 1] = make_temp_file (".err");
153+
154+ if (attempt == RETRY_ICE_ATTEMPTS)
155+ {
156+ int i;
157+ int fd1, fd2;
158+ struct stat st1, st2;
159+ size_t n, len;
160+ char *buf;
161+
162+ buf = xmalloc (8192);
163+
164+ for (i = 0; i < 2; ++i)
165+ {
166+ fd1 = open (temp_filenames[i], O_RDONLY);
167+ fd2 = open (temp_filenames[2 + i], O_RDONLY);
168+
169+ if (fd1 < 0 || fd2 < 0)
170+ {
171+ i = -1;
172+ close (fd1);
173+ close (fd2);
174+ break;
175+ }
176+
177+ if (fstat (fd1, &st1) < 0 || fstat (fd2, &st2) < 0)
178+ {
179+ i = -1;
180+ close (fd1);
181+ close (fd2);
182+ break;
183+ }
184+
185+ if (st1.st_size != st2.st_size)
186+ {
187+ close (fd1);
188+ close (fd2);
189+ break;
190+ }
191+
192+ len = 0;
193+ for (n = st1.st_size; n; n -= len)
194+ {
195+ len = n;
196+ if (len > 4096)
197+ len = 4096;
198+
199+ if (read (fd1, buf, len) != (int) len
200+ || read (fd2, buf + 4096, len) != (int) len)
201+ {
202+ i = -1;
203+ break;
204+ }
205+
206+ if (memcmp (buf, buf + 4096, len) != 0)
207+ break;
208+ }
209+
210+ close (fd1);
211+ close (fd2);
212+
213+ if (n)
214+ break;
215+ }
216+
217+ free (buf);
218+ if (i == -1)
219+ break;
220+
221+ if (i != 2)
222+ {
223+ notice ("The bug is not reproducible, so it is likely a hardware or OS problem.\n");
224+ break;
225+ }
226+
227+ fd = open (temp_filenames[attempt * 2], O_RDWR);
228+ if (fd < 0)
229+ break;
230+ write (fd, "//", 2);
231+ for (i = 0; i < nargs; i++)
232+ {
233+ write (fd, " ", 1);
234+ write (fd, new_argv[i], strlen (new_argv[i]));
235+ }
236+ write (fd, "\n", 1);
237+ new_argv[nargs] = "-E";
238+ new_argv[nargs + 1] = NULL;
239+ }
240+
241+ /* Fork a subprocess; wait and retry if it fails. */
242+ sleep_interval = 1;
243+ pid = -1;
244+ for (retries = 0; retries < 4; retries++)
245+ {
246+ pid = fork ();
247+ if (pid >= 0)
248+ break;
249+ sleep (sleep_interval);
250+ sleep_interval *= 2;
251+ }
252+
253+ if (pid < 0)
254+ break;
255+ else if (pid == 0)
256+ {
257+ if (attempt != RETRY_ICE_ATTEMPTS)
258+ fd = open (temp_filenames[attempt * 2], O_RDWR);
259+ if (fd < 0)
260+ exit (-1);
261+ if (fd != 1)
262+ {
263+ close (1);
264+ dup (fd);
265+ close (fd);
266+ }
267+
268+ fd = open (temp_filenames[attempt * 2 + 1], O_RDWR);
269+ if (fd < 0)
270+ exit (-1);
271+ if (fd != 2)
272+ {
273+ close (2);
274+ dup (fd);
275+ close (fd);
276+ }
277+
278+ if (prog == new_argv[0])
279+ execvp (prog, (char *const *) new_argv);
280+ else
281+ execv (new_argv[0], (char *const *) new_argv);
282+ exit (-1);
283+ }
284+
285+ if (waitpid (pid, &status, 0) < 0)
286+ break;
287+
288+ if (attempt < RETRY_ICE_ATTEMPTS
289+ && (! WIFEXITED (status) || WEXITSTATUS (status) != ICE_EXIT_CODE))
290+ {
291+ notice ("The bug is not reproducible, so it is likely a hardware or OS problem.\n");
292+ break;
293+ }
294+ else if (attempt == RETRY_ICE_ATTEMPTS)
295+ {
296+ close (fd);
297+ if (WIFEXITED (status)
298+ && WEXITSTATUS (status) == SUCCESS_EXIT_CODE)
299+ {
300+ notice ("Preprocessed source stored into %s file, please attach this to your bugreport.\n",
301+ temp_filenames[attempt * 2]);
302+ /* Make sure it is not deleted. */
303+ free (temp_filenames[attempt * 2]);
304+ temp_filenames[attempt * 2] = NULL;
305+ break;
306+ }
307+ }
308+ }
309+
310+ for (attempt = 0; attempt < RETRY_ICE_ATTEMPTS * 2 + 2; attempt++)
311+ if (temp_filenames[attempt])
312+ {
313+ unlink (temp_filenames[attempt]);
314+ free (temp_filenames[attempt]);
315+ }
316+}
317+#endif
318+
319 /* Search for a file named NAME trying various prefixes including the
320 user's -B prefix and some standard ones.
321 Return the absolute file name found. If nothing is found, return NAME. */
322--- gcc/Makefile.in.orig 2007-09-30 10:48:13.000000000 +0000
323+++ gcc/Makefile.in 2007-09-30 10:48:39.000000000 +0000
324@@ -192,6 +192,7 @@
325 build/gengtype-lex.o-warn = -Wno-error
326 # SYSCALLS.c misses prototypes
327 SYSCALLS.c.X-warn = -Wno-strict-prototypes -Wno-error
328+build/gcc.o-warn = -Wno-error
329
330 # All warnings have to be shut off in stage1 if the compiler used then
331 # isn't gcc; configure determines that. WARN_CFLAGS will be either