public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Attempt to increase RLIMIT_STACK in the driver as well as compiler (PR c++/49756)
@ 2011-07-18 23:20 Jakub Jelinek
  2011-07-19  8:42 ` Mike Stump
  2011-07-19  8:57 ` [PATCH] Attempt to increase RLIMIT_STACK in the driver as well as compiler (PR c++/49756, take 2) Jakub Jelinek
  0 siblings, 2 replies; 9+ messages in thread
From: Jakub Jelinek @ 2011-07-18 23:20 UTC (permalink / raw)
  To: gcc-patches

Hi!

Especially the FEs and gimplification are highly recursive on more complex
(especially badly generated) testcases, the following patch attempts to
increase stack size to 64MB if possible.  It is done in the driver
(where it can affect the children of the driver early) and also in
toplev_main to make similar results when invoking the compiler by hand,
unless mmap of some shared library or some other mmap make it impossible
to have such a large stack.

Bootstrapped/regtested on x86_64-linux and i686-linux, cures
gcc.c-torture/compile/limits-exprparen.c ICEs on x86_64-linux on all
-O* levels as well as the testcase from this PR (which is quite large and
compile time consuming, so not including it in this testcase).

2011-07-18  Jakub Jelinek  <jakub@redhat.com>

	PR c++/49756
	* gcc.c (main): Try to increase RLIMIT_STACK to at least
	64MB if possible.
	* toplev.c (toplev_main): Likewise.

--- gcc/gcc.c.jj	2011-07-08 15:09:38.000000000 +0200
+++ gcc/gcc.c	2011-07-18 21:13:18.000000000 +0200
@@ -6156,6 +6156,22 @@ main (int argc, char **argv)
   signal (SIGCHLD, SIG_DFL);
 #endif
 
+#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_STACK) && defined(RLIM_INFINITY)
+  {
+    /* Parsing and gimplification sometimes need quite large stack.
+       Increase stack size limits if possible.  */
+    struct rlimit rlim;
+    if (getrlimit (RLIMIT_STACK, &rlim) == 0
+	&& rlim.rlim_cur != RLIM_INFINITY)
+      {
+	rlim.rlim_cur = MAX (rlim.rlim_cur, 64 * 1024 * 1024);
+	if (rlim.rlim_max != RLIM_INFINITY)
+	  rlim.rlim_cur = MIN (rlim.rlim_cur, rlim.rlim_max);
+	setrlimit (RLIMIT_STACK, &rlim);
+      }
+  }
+#endif
+
   /* Allocate the argument vector.  */
   alloc_args ();
 
--- gcc/toplev.c.jj	2011-07-11 10:39:50.000000000 +0200
+++ gcc/toplev.c	2011-07-18 21:14:24.000000000 +0200
@@ -1911,6 +1911,22 @@ do_compile (void)
 int
 toplev_main (int argc, char **argv)
 {
+#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_STACK) && defined(RLIM_INFINITY)
+  {
+    /* Parsing and gimplification sometimes need quite large stack.
+       Increase stack size limits if possible.  */
+    struct rlimit rlim;
+    if (getrlimit (RLIMIT_STACK, &rlim) == 0
+	&& rlim.rlim_cur != RLIM_INFINITY)
+      {
+	rlim.rlim_cur = MAX (rlim.rlim_cur, 64 * 1024 * 1024);
+	if (rlim.rlim_max != RLIM_INFINITY)
+	  rlim.rlim_cur = MIN (rlim.rlim_cur, rlim.rlim_max);
+	setrlimit (RLIMIT_STACK, &rlim);
+      }
+  }
+#endif
+
   expandargv (&argc, &argv);
 
   /* Initialization of GCC's environment, and diagnostics.  */

	Jakub

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-07-22 22:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-18 23:20 [PATCH] Attempt to increase RLIMIT_STACK in the driver as well as compiler (PR c++/49756) Jakub Jelinek
2011-07-19  8:42 ` Mike Stump
2011-07-19  8:46   ` Mike Stump
2011-07-19  8:57 ` [PATCH] Attempt to increase RLIMIT_STACK in the driver as well as compiler (PR c++/49756, take 2) Jakub Jelinek
2011-07-19 10:18   ` Richard Guenther
2011-07-21 15:19     ` [PATCH] Attempt to increase RLIMIT_STACK in the driver as well as compiler (PR c++/49756, take 3) Jakub Jelinek
2011-07-21 18:32       ` Ian Lance Taylor
2011-07-22 23:01         ` Gerald Pfeifer
2011-07-22 23:22           ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).