bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GNU make patch to avoid stack limit brain damage on Solaris 2.6


From: Paul Eggert
Subject: GNU make patch to avoid stack limit brain damage on Solaris 2.6
Date: Thu, 6 Sep 2001 10:46:04 -0700 (PDT)

Here's a patch to work around the GNU make problem noted by
address@hidden on Solaris 2.6.  This code uses the same basic
idea as code already in GCC 3.0.1.

I attempted to minimize the size of the patch by using some
nonstandard indenting in main.c; you may want to fix that after
applying the patch.  (The call to setrlimit should precede the first
use of PATH_VAR, as PATH_VAR invokes alloca.)

2001-09-06  Paul Eggert  <address@hidden>

        * configure.in (AC_CHECK_HEADERS): Add sys/resource.h.
        (AC_CHECK_FUNCS): Add getrlimit, setrlimit.

        * main.c: Include <sys/resource.h> if it, getrlimit, and
        setrlimit are available.
        (main): Get rid of any avoidable limit on stack size.

===================================================================
RCS file: configure.in,v
retrieving revision 3.79.1.5
retrieving revision 3.79.1.6
diff -pu -r3.79.1.5 -r3.79.1.6
--- configure.in        2001/08/15 18:42:35     3.79.1.5
+++ configure.in        2001/09/06 17:13:34     3.79.1.6
@@ -32,7 +32,7 @@ AC_TYPE_UID_T                 dnl Also does gid_t.
 AC_TYPE_PID_T
 AC_TYPE_SIGNAL
 AC_CHECK_HEADERS(stdlib.h unistd.h limits.h sys/param.h fcntl.h string.h \
-                memory.h sys/time.h sys/timeb.h)
+                memory.h sys/resource.h sys/time.h sys/timeb.h)
 AC_PROG_CC_C_O
 AM_PROG_CC_STDC
 AC_C_CONST                     dnl getopt needs this.
@@ -115,6 +115,7 @@ fi
 AC_CHECK_FUNCS(        memmove memcpy strchr strdup psignal mkstemp mktemp 
fdopen \
                bsd_signal \
                dup2 getcwd sigsetmask sigaction getgroups setlinebuf \
+               getrlimit setrlimit \
                seteuid setegid setreuid setregid pipe strerror strsignal)
 
 AC_CHECK_SYMBOL(sys_siglist)
===================================================================
RCS file: main.c,v
retrieving revision 3.79.1.2
retrieving revision 3.79.1.3
diff -pu -r3.79.1.2 -r3.79.1.3
--- main.c      2001/05/07 06:37:51     3.79.1.2
+++ main.c      2001/09/06 17:13:34     3.79.1.3
@@ -40,6 +40,10 @@ MA 02111-1307, USA.  */
 # include <fcntl.h>
 #endif
 
+#if HAVE_SYS_RESOURCE_H && HAVE_GETRLIMIT && HAVE_SETRLIMIT
+# include <sys/resource.h>
+#endif
+
 #ifdef _AMIGA
 int __stack = 20000; /* Make sure we have 20K of stack space */
 #endif
@@ -808,6 +812,22 @@ int main (int argc, char ** argv)
   register unsigned int i;
   char **p;
   struct dep *read_makefiles;
+
+#if defined RLIMIT_STACK && HAVE_GETRLIMIT && HAVE_SETRLIMIT
+ /* Get rid of any avoidable limit on stack size.  */
+ {
+  struct rlimit rlim;
+
+  /* Set the stack limit huge so that alloca does not fail.  */
+  if (getrlimit (RLIMIT_STACK, &rlim) == 0)
+    {
+      rlim.rlim_cur = rlim.rlim_max;
+      setrlimit (RLIMIT_STACK, &rlim);
+    }
+ }
+#endif
+  
+ {
   PATH_VAR (current_directory);
 #ifdef WINDOWS32
   char *unix_path = NULL;
@@ -1933,6 +1953,7 @@ int main (int argc, char ** argv)
   }
 
   return 0;
+ }
 }
 
 /* Parsing of arguments, decoding of switches.  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]