[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make: *** virtual memory exhausted. Stop.
From: |
Jason Lunz |
Subject: |
Re: make: *** virtual memory exhausted. Stop. |
Date: |
Thu, 9 Mar 2006 17:57:10 +0000 (UTC) |
User-agent: |
slrn/0.9.8.1 (Debian) |
address@hidden said:
> I am looking for a workaround to what appears to be a make 3.80 bug. A
> bit of googling turned up this:
>
> %% Fabio Alemagna <address@hidden> writes:
>
> fa> That happens when using a construct like this:
> fa> define function
> fa> target: very long dependency list
> fa> whatever
> fa> endef
>
> fa> and then passign that to $(eval) trough $(call). By reading the ml
> fa> archives I got to know that this is a pretty old bug, which should
> fa> have supposedly been fixed in a release which, at the time, was
> fa> about to be made. However it appears that there have no been any
> fa> more releases since then... Am I to assume that this bug will
> fa> never be fixed (I read about the patch, but I also read it doesn't
> fa> work as it should)?
>
> which pretty much looks like my problem. Since this email was written
> back in 2003 and no stable release of make has been made since then,
> this bug still bites some of my users who are unlucky enough to use the
> macosx-provided gnu make which does not include the gnu make patches
> used in pretty much every linux distribution under the sun (yes, my
> Makefile works nicely on every linux distribution I tried it on, most
> likely because of the patches applied by these distributions).
>
> So, I am looking for a way to work around this small limitation of gnu
> make. Is there something I could do to change the structure of my
> Makefile to avoid this ?
My Makefile is bitten by this bug. I didn't notice it for a long time,
because most Linux distributions that ship make 3.80 patch it. MacOSX
does not patch their make 3.80, however.
The patch below, extracted from a Debian package, applies to make 3.80
and builds on macosx. It solved all my "virtual memory exhausted"
problems.
Jason
--- make-3.80.orig/expand.c
+++ make-3.80/expand.c
@@ -564,3 +564,28 @@
return value;
}
+
+/* Install a new variable_buffer context, returning the current one for
+ safe-keeping. */
+
+void
+install_variable_buffer (char **bufp, unsigned int *lenp)
+{
+ *bufp = variable_buffer;
+ *lenp = variable_buffer_length;
+
+ variable_buffer = 0;
+ initialize_variable_output ();
+}
+
+/* Restore a previously-saved variable_buffer setting (free the current one).
+ */
+
+void
+restore_variable_buffer (char *buf, unsigned int len)
+{
+ free (variable_buffer);
+
+ variable_buffer = buf;
+ variable_buffer_length = len;
+}
--- make-3.80.orig/function.c
+++ make-3.80/function.c
@@ -1281,8 +1281,18 @@
char **argv;
const char *funcname;
{
+ char *buf;
+ unsigned int len;
+
+ /* Eval the buffer. Pop the current variable buffer setting so that the
+ eval'd code can use its own without conflicting. */
+
+ install_variable_buffer (&buf, &len);
+
eval_buffer (argv[0]);
+ restore_variable_buffer (buf, len);
+
return o;
}
--- make-3.80.orig/read.c
+++ make-3.80/read.c
@@ -271,7 +271,7 @@
return read_makefiles;
}
-
+
static int
eval_makefile (filename, flags)
char *filename;
@@ -386,11 +386,37 @@
return r;
}
+static struct conditionals *
+install_conditionals (struct conditionals *new)
+{
+ struct conditionals *save = conditionals;
+
+ bzero ((char *) new, sizeof (*new));
+ conditionals = new;
+
+ return save;
+}
+
+static void
+restore_conditionals (struct conditionals *saved)
+{
+ /* Free any space allocated by conditional_line. */
+ if (conditionals->ignoring)
+ free (conditionals->ignoring);
+ if (conditionals->seen_else)
+ free (conditionals->seen_else);
+
+ /* Restore state. */
+ conditionals = saved;
+}
+
int
eval_buffer (buffer)
char *buffer;
{
struct ebuffer ebuf;
+ struct conditionals *saved;
+ struct conditionals new;
const struct floc *curfile;
int r;
@@ -405,8 +431,12 @@
curfile = reading_file;
reading_file = &ebuf.floc;
+ saved = install_conditionals (&new);
+
r = eval (&ebuf, 1);
+ restore_conditionals (saved);
+
reading_file = curfile;
return r;
--- make-3.80.orig/variable.c
+++ make-3.80/variable.c
@@ -160,6 +160,7 @@
v->per_target = 0;
v->append = 0;
v->export = v_default;
+ v->special = 0;
v->exportable = 1;
if (*name != '_' && (*name < 'A' || *name > 'Z')
--- make-3.80.orig/variable.h
+++ make-3.80/variable.h
@@ -107,6 +107,8 @@
extern char *expand_argument PARAMS ((char *str, char *end));
extern char *variable_expand_string PARAMS ((char *line, char *string,
long length));
+extern void install_variable_buffer PARAMS ((char **bufp, unsigned int *lenp));
+extern void restore_variable_buffer PARAMS ((char *buf, unsigned int len));
/* function.c */
extern int handle_function PARAMS ((char **op, char **stringp));
Re: make: *** virtual memory exhausted. Stop.,
Jason Lunz <=