diff --git a/pkgs/development/tools/build-managers/gnumake/MAKEFLAGS-reexec.patch b/pkgs/development/tools/build-managers/gnumake/MAKEFLAGS-reexec.patch new file mode 100644 index 000000000000..a2f59657d4ca --- /dev/null +++ b/pkgs/development/tools/build-managers/gnumake/MAKEFLAGS-reexec.patch @@ -0,0 +1,14 @@ +http://bugs.gentoo.org/331975 +https://savannah.gnu.org/bugs/?30723 + +--- main.c 2010/07/19 07:10:53 1.243 ++++ main.c 2010/08/10 07:35:34 1.244 +@@ -2093,7 +2093,7 @@ + const char *pv = define_makeflags (1, 1); + char *p = alloca (sizeof ("MAKEFLAGS=") + strlen (pv) + 1); + sprintf (p, "MAKEFLAGS=%s", pv); +- putenv (p); ++ putenv (allocated_variable_expand (p)); + } + + if (ISDB (DB_BASIC)) diff --git a/pkgs/development/tools/build-managers/gnumake/archives-many-objs.patch b/pkgs/development/tools/build-managers/gnumake/archives-many-objs.patch new file mode 100644 index 000000000000..73c0381ced45 --- /dev/null +++ b/pkgs/development/tools/build-managers/gnumake/archives-many-objs.patch @@ -0,0 +1,48 @@ +diff -u -p -r1.193 -r1.194 +--- read.c 13 Jul 2010 01:20:42 -0000 1.193 ++++ read.c 14 Aug 2010 02:50:14 -0000 1.194 +@@ -3028,7 +3028,7 @@ parse_file_seq (char **stringp, unsigned + { + /* This looks like the first element in an open archive group. + A valid group MUST have ')' as the last character. */ +- const char *e = p + nlen; ++ const char *e = p; + do + { + e = next_token (e); +@@ -3084,19 +3084,19 @@ parse_file_seq (char **stringp, unsigned + Go to the next item in the string. */ + if (flags & PARSEFS_NOGLOB) + { +- NEWELT (concat (2, prefix, tp)); ++ NEWELT (concat (2, prefix, tmpbuf)); + continue; + } + + /* If we get here we know we're doing glob expansion. + TP is a string in tmpbuf. NLEN is no longer used. + We may need to do more work: after this NAME will be set. */ +- name = tp; ++ name = tmpbuf; + + /* Expand tilde if applicable. */ +- if (tp[0] == '~') ++ if (tmpbuf[0] == '~') + { +- tildep = tilde_expand (tp); ++ tildep = tilde_expand (tmpbuf); + if (tildep != 0) + name = tildep; + } +@@ -3152,7 +3152,10 @@ parse_file_seq (char **stringp, unsigned + else + { + /* We got a chain of items. Attach them. */ +- (*newp)->next = found; ++ if (*newp) ++ (*newp)->next = found; ++ else ++ *newp = found; + + /* Find and set the new end. Massage names if necessary. */ + while (1) diff --git a/pkgs/development/tools/build-managers/gnumake/construct-command-line.patch b/pkgs/development/tools/build-managers/gnumake/construct-command-line.patch new file mode 100644 index 000000000000..c504c45291ba --- /dev/null +++ b/pkgs/development/tools/build-managers/gnumake/construct-command-line.patch @@ -0,0 +1,71 @@ +https://savannah.gnu.org/bugs/?23922 + +From 6f3684710a0f832533191f8657a57bc2fbba90ba Mon Sep 17 00:00:00 2001 +From: eliz +Date: Sat, 7 May 2011 08:29:13 +0000 +Subject: [PATCH] job.c (construct_command_argv_internal): Don't assume + shellflags is always non-NULL. Escape-protect characters + special to the shell when copying the value of SHELL into + new_line. Fixes Savannah bug #23922. + +--- + ChangeLog | 7 +++++++ + job.c | 23 ++++++++++++++++------- + 2 files changed, 23 insertions(+), 7 deletions(-) + +diff --git a/job.c b/job.c +index 67b402d..c2ce84d 100644 +--- a/job.c ++++ b/job.c +@@ -2844,12 +2844,12 @@ construct_command_argv_internal (char *line, char **restp, char *shell, + + unsigned int shell_len = strlen (shell); + unsigned int line_len = strlen (line); +- unsigned int sflags_len = strlen (shellflags); ++ unsigned int sflags_len = shellflags ? strlen (shellflags) : 0; + char *command_ptr = NULL; /* used for batch_mode_shell mode */ + char *new_line; + + # ifdef __EMX__ /* is this necessary? */ +- if (!unixy_shell) ++ if (!unixy_shell && shellflags) + shellflags[0] = '/'; /* "/c" */ + # endif + +@@ -2911,19 +2911,28 @@ construct_command_argv_internal (char *line, char **restp, char *shell, + + new_argv = xmalloc (4 * sizeof (char *)); + new_argv[0] = xstrdup(shell); +- new_argv[1] = xstrdup(shellflags); ++ new_argv[1] = xstrdup(shellflags ? shellflags : ""); + new_argv[2] = line; + new_argv[3] = NULL; + return new_argv; + } + +- new_line = alloca (shell_len + 1 + sflags_len + 1 ++ new_line = alloca ((shell_len*2) + 1 + sflags_len + 1 + + (line_len*2) + 1); + ap = new_line; +- memcpy (ap, shell, shell_len); +- ap += shell_len; ++ /* Copy SHELL, escaping any characters special to the shell. If ++ we don't escape them, construct_command_argv_internal will ++ recursively call itself ad nauseam, or until stack overflow, ++ whichever happens first. */ ++ for (p = shell; *p != '\0'; ++p) ++ { ++ if (strchr (sh_chars, *p) != 0) ++ *(ap++) = '\\'; ++ *(ap++) = *p; ++ } + *(ap++) = ' '; +- memcpy (ap, shellflags, sflags_len); ++ if (shellflags) ++ memcpy (ap, shellflags, sflags_len); + ap += sflags_len; + *(ap++) = ' '; + command_ptr = ap; +-- +1.7.12 + diff --git a/pkgs/development/tools/build-managers/gnumake/copy-on-expand.patch b/pkgs/development/tools/build-managers/gnumake/copy-on-expand.patch new file mode 100644 index 000000000000..3f202b4db96b --- /dev/null +++ b/pkgs/development/tools/build-managers/gnumake/copy-on-expand.patch @@ -0,0 +1,58 @@ +fix from upstream cvs + +---------------------------- +revision 1.58 +date: 2011-08-29 12:20:19 -0400; author: psmith; state: Exp; lines: +7 -13; commitid: MdH0jSxpuIy7mqxv; +Save strings we're expanding in case an embedded eval causes them +to be freed (if they're the value of a variable that's reset for example). +See Savannah patch #7534 + +Index: expand.c +=================================================================== +RCS file: /sources/make/make/expand.c,v +retrieving revision 1.57 +retrieving revision 1.58 +diff -u -p -r1.57 -r1.58 +--- expand.c 7 May 2011 20:03:49 -0000 1.57 ++++ expand.c 29 Aug 2011 16:20:19 -0000 1.58 +@@ -197,7 +197,7 @@ variable_expand_string (char *line, cons + { + struct variable *v; + const char *p, *p1; +- char *abuf = NULL; ++ char *save; + char *o; + unsigned int line_offset; + +@@ -212,16 +212,11 @@ variable_expand_string (char *line, cons + return (variable_buffer); + } + +- /* If we want a subset of the string, allocate a temporary buffer for it. +- Most of the functions we use here don't work with length limits. */ +- if (length > 0 && string[length] != '\0') +- { +- abuf = xmalloc(length+1); +- memcpy(abuf, string, length); +- abuf[length] = '\0'; +- string = abuf; +- } +- p = string; ++ /* We need a copy of STRING: due to eval, it's possible that it will get ++ freed as we process it (it might be the value of a variable that's reset ++ for example). Also having a nil-terminated string is handy. */ ++ save = length < 0 ? xstrdup (string) : xstrndup (string, length); ++ p = save; + + while (1) + { +@@ -411,8 +406,7 @@ variable_expand_string (char *line, cons + ++p; + } + +- if (abuf) +- free (abuf); ++ free (save); + + variable_buffer_output (o, "", 1); + return (variable_buffer + line_offset); diff --git a/pkgs/development/tools/build-managers/gnumake/darwin-library_search-dylib.patch b/pkgs/development/tools/build-managers/gnumake/darwin-library_search-dylib.patch new file mode 100644 index 000000000000..de7e4f615212 --- /dev/null +++ b/pkgs/development/tools/build-managers/gnumake/darwin-library_search-dylib.patch @@ -0,0 +1,17 @@ +Fixed default libpatttern on Darwin, imported from prefix overlay. +Got merged upstream: +https://savannah.gnu.org/bugs/?37197 +--- default.c.orig 2009-05-02 12:25:24 +0200 ++++ default.c 2009-05-02 12:25:58 +0200 +@@ -509,7 +509,11 @@ + #ifdef __MSDOS__ + ".LIBPATTERNS", "lib%.a $(DJDIR)/lib/lib%.a", + #else ++#ifdef __APPLE__ ++ ".LIBPATTERNS", "lib%.dylib lib%.a", ++#else + ".LIBPATTERNS", "lib%.so lib%.a", ++#endif + #endif + #endif + diff --git a/pkgs/development/tools/build-managers/gnumake/default.nix b/pkgs/development/tools/build-managers/gnumake/default.nix index cf33e7a5bbc3..cb0ab18a40f5 100644 --- a/pkgs/development/tools/build-managers/gnumake/default.nix +++ b/pkgs/development/tools/build-managers/gnumake/default.nix @@ -26,6 +26,21 @@ stdenv.mkDerivation { ./impure-dirs.patch ]; + # a bunch of patches from Gentoo, mostly should be from upstream (unreleased) + preConfigure = '' + patch -i ${./archives-many-objs.patch} + patch -i ${./MAKEFLAGS-reexec.patch} + patch -i ${./memory-corruption.patch} + patch -i ${./glob-speedup.patch} + patch -i ${./copy-on-expand.patch} + patch -i ${./oneshell.patch} + patch -i ${./parallel-remake.patch} + patch -p1 -i ${./intermediate-parallel.patch} + patch -i ${./construct-command-line.patch} + patch -i ${./long-command-line.patch} + patch -i ${./darwin-library_search-dylib.patch} + ''; + meta = { description = "GNU Make, a program controlling the generation of non-source files from sources"; diff --git a/pkgs/development/tools/build-managers/gnumake/glob-speedup.patch b/pkgs/development/tools/build-managers/gnumake/glob-speedup.patch new file mode 100644 index 000000000000..c826c2c0e1fa --- /dev/null +++ b/pkgs/development/tools/build-managers/gnumake/glob-speedup.patch @@ -0,0 +1,104 @@ +change from upstream to speed up by skipping unused globs +https://bugs.gentoo.org/382845 + +http://cvs.savannah.gnu.org/viewvc/make/read.c?root=make&r1=1.198&r2=1.200 + +Revision 1.200 +Sat May 7 14:36:12 2011 UTC (4 months, 1 week ago) by psmith +Branch: MAIN +Changes since 1.199: +1 -1 lines +Inverted the boolean test from what I wanted it to be. Added a +regression test to make sure this continues to work. + +Revision 1.199 +Mon May 2 00:18:06 2011 UTC (4 months, 2 weeks ago) by psmith +Branch: MAIN +Changes since 1.198: +35 -25 lines +Avoid invoking glob() unless the filename has potential globbing +characters in it, for performance improvements. + +--- a/read.c 2011/04/29 15:27:39 1.198 ++++ b/read.c 2011/05/07 14:36:12 1.200 +@@ -2901,6 +2901,7 @@ + const char *name; + const char **nlist = 0; + char *tildep = 0; ++ int globme = 1; + #ifndef NO_ARCHIVES + char *arname = 0; + char *memname = 0; +@@ -3109,32 +3110,40 @@ + } + #endif /* !NO_ARCHIVES */ + +- switch (glob (name, GLOB_NOSORT|GLOB_ALTDIRFUNC, NULL, &gl)) +- { +- case GLOB_NOSPACE: +- fatal (NILF, _("virtual memory exhausted")); +- +- case 0: +- /* Success. */ +- i = gl.gl_pathc; +- nlist = (const char **)gl.gl_pathv; +- break; +- +- case GLOB_NOMATCH: +- /* If we want only existing items, skip this one. */ +- if (flags & PARSEFS_EXISTS) +- { +- i = 0; +- break; +- } +- /* FALLTHROUGH */ +- +- default: +- /* By default keep this name. */ ++ /* glob() is expensive: don't call it unless we need to. */ ++ if (!(flags & PARSEFS_EXISTS) && strpbrk (name, "?*[") == NULL) ++ { ++ globme = 0; + i = 1; + nlist = &name; +- break; +- } ++ } ++ else ++ switch (glob (name, GLOB_NOSORT|GLOB_ALTDIRFUNC, NULL, &gl)) ++ { ++ case GLOB_NOSPACE: ++ fatal (NILF, _("virtual memory exhausted")); ++ ++ case 0: ++ /* Success. */ ++ i = gl.gl_pathc; ++ nlist = (const char **)gl.gl_pathv; ++ break; ++ ++ case GLOB_NOMATCH: ++ /* If we want only existing items, skip this one. */ ++ if (flags & PARSEFS_EXISTS) ++ { ++ i = 0; ++ break; ++ } ++ /* FALLTHROUGH */ ++ ++ default: ++ /* By default keep this name. */ ++ i = 1; ++ nlist = &name; ++ break; ++ } + + /* For each matched element, add it to the list. */ + while (i-- > 0) +@@ -3174,7 +3183,8 @@ + #endif /* !NO_ARCHIVES */ + NEWELT (concat (2, prefix, nlist[i])); + +- globfree (&gl); ++ if (globme) ++ globfree (&gl); + + #ifndef NO_ARCHIVES + if (arname) diff --git a/pkgs/development/tools/build-managers/gnumake/intermediate-parallel.patch b/pkgs/development/tools/build-managers/gnumake/intermediate-parallel.patch new file mode 100644 index 000000000000..88f2b238e698 --- /dev/null +++ b/pkgs/development/tools/build-managers/gnumake/intermediate-parallel.patch @@ -0,0 +1,46 @@ +diff --git a/remake.c b/remake.c +index c0bf709..b1ddd23 100644 +--- a/remake.c ++++ b/remake.c +@@ -612,6 +612,10 @@ update_file_1 (struct file *file, unsigned int depth) + d->file->dontcare = file->dontcare; + } + ++ /* We may have already considered this file, when we didn't know ++ we'd need to update it. Force update_file() to consider it and ++ not prune it. */ ++ d->file->considered = !considered; + + dep_status |= update_file (d->file, depth); + +diff --git a/tests/scripts/features/parallelism b/tests/scripts/features/parallelism +index d4250f0..76d24a7 100644 +--- a/tests/scripts/features/parallelism ++++ b/tests/scripts/features/parallelism +@@ -214,6 +214,23 @@ rm main.x"); + rmfiles(qw(foo.y foo.y.in main.bar)); + } + ++# Ensure intermediate/secondary files are not pruned incorrectly. ++# See Savannah bug #30653 ++ ++utouch(-15, 'file2'); ++utouch(-10, 'file4'); ++utouch(-5, 'file1'); ++ ++run_make_test(q! ++.INTERMEDIATE: file3 ++file4: file3 ; @mv -f $< $@ ++file3: file2 ; touch $@ ++file2: file1 ; @touch $@ ++!, ++ '--no-print-directory -j2', "touch file3"); ++ ++#rmfiles('file1', 'file2', 'file3', 'file4'); ++ + if ($all_tests) { + # Jobserver FD handling is messed up in some way. + # Savannah bug #28189 +-- +1.7.12 + diff --git a/pkgs/development/tools/build-managers/gnumake/long-command-line.patch b/pkgs/development/tools/build-managers/gnumake/long-command-line.patch new file mode 100644 index 000000000000..9266786e4da7 --- /dev/null +++ b/pkgs/development/tools/build-managers/gnumake/long-command-line.patch @@ -0,0 +1,54 @@ +https://savannah.gnu.org/bugs/?36451 + +From a95796de3a491d8acfc8ea94c217b90531161786 Mon Sep 17 00:00:00 2001 +From: psmith +Date: Sun, 9 Sep 2012 23:25:07 +0000 +Subject: [PATCH] Keep the command line on the heap to avoid stack overflow. + Fixes Savannah bug #36451. + +--- + ChangeLog | 3 +++ + job.c | 13 +++++++++---- + 2 files changed, 12 insertions(+), 4 deletions(-) + +diff --git a/job.c b/job.c +index 754576b..f7b7d51 100644 +--- a/job.c ++++ b/job.c +@@ -2984,8 +2984,8 @@ construct_command_argv_internal (char *line, char **restp, char *shell, + return new_argv; + } + +- new_line = alloca ((shell_len*2) + 1 + sflags_len + 1 +- + (line_len*2) + 1); ++ new_line = xmalloc ((shell_len*2) + 1 + sflags_len + 1 ++ + (line_len*2) + 1); + ap = new_line; + /* Copy SHELL, escaping any characters special to the shell. If + we don't escape them, construct_command_argv_internal will +@@ -3052,8 +3052,11 @@ construct_command_argv_internal (char *line, char **restp, char *shell, + *ap++ = *p; + } + if (ap == new_line + shell_len + sflags_len + 2) +- /* Line was empty. */ +- return 0; ++ { ++ /* Line was empty. */ ++ free (new_line); ++ return 0; ++ } + *ap = '\0'; + + #ifdef WINDOWS32 +@@ -3194,6 +3197,8 @@ construct_command_argv_internal (char *line, char **restp, char *shell, + fatal (NILF, _("%s (line %d) Bad shell context (!unixy && !batch_mode_shell)\n"), + __FILE__, __LINE__); + #endif ++ ++ free (new_line); + } + #endif /* ! AMIGA */ + +-- +1.7.12 + diff --git a/pkgs/development/tools/build-managers/gnumake/memory-corruption.patch b/pkgs/development/tools/build-managers/gnumake/memory-corruption.patch new file mode 100644 index 000000000000..b28c07353ec2 --- /dev/null +++ b/pkgs/development/tools/build-managers/gnumake/memory-corruption.patch @@ -0,0 +1,37 @@ +--- function.c 2011/04/18 01:25:20 1.121 ++++ function.c 2011/05/02 12:35:01 1.122 +@@ -706,7 +706,7 @@ + const char *word_iterator = argv[0]; + char buf[20]; + +- while (find_next_token (&word_iterator, (unsigned int *) 0) != 0) ++ while (find_next_token (&word_iterator, NULL) != 0) + ++i; + + sprintf (buf, "%d", i); +@@ -1133,21 +1133,14 @@ + + /* Find the maximum number of words we'll have. */ + t = argv[0]; +- wordi = 1; +- while (*t != '\0') ++ wordi = 0; ++ while ((p = find_next_token (&t, NULL)) != 0) + { +- char c = *(t++); +- +- if (! isspace ((unsigned char)c)) +- continue; +- ++ ++t; + ++wordi; +- +- while (isspace ((unsigned char)*t)) +- ++t; + } + +- words = xmalloc (wordi * sizeof (char *)); ++ words = xmalloc ((wordi == 0 ? 1 : wordi) * sizeof (char *)); + + /* Now assign pointers to each string in the array. */ + t = argv[0]; diff --git a/pkgs/development/tools/build-managers/gnumake/oneshell.patch b/pkgs/development/tools/build-managers/gnumake/oneshell.patch new file mode 100644 index 000000000000..fbade127ce61 --- /dev/null +++ b/pkgs/development/tools/build-managers/gnumake/oneshell.patch @@ -0,0 +1,24 @@ +fix from upstream cvs + +---------------------------- +revision 1.245 +date: 2010-08-13 22:50:14 -0400; author: psmith; state: Exp; lines: +1 -1; commitid: 4UaslPqQHZTs5wKu; +- Add oneshell to $(.FEATURES) (forgot that!) + +Index: main.c +=================================================================== +RCS file: /sources/make/make/main.c,v +retrieving revision 1.244 +retrieving revision 1.245 +diff -u -p -r1.244 -r1.245 +--- main.c 10 Aug 2010 07:35:34 -0000 1.244 ++++ main.c 14 Aug 2010 02:50:14 -0000 1.245 +@@ -1138,7 +1138,7 @@ main (int argc, char **argv, char **envp + a macro and some compilers (MSVC) don't like conditionals in macros. */ + { + const char *features = "target-specific order-only second-expansion" +- " else-if shortest-stem undefine" ++ " else-if shortest-stem undefine oneshell" + #ifndef NO_ARCHIVES + " archives" + #endif diff --git a/pkgs/development/tools/build-managers/gnumake/parallel-remake.patch b/pkgs/development/tools/build-managers/gnumake/parallel-remake.patch new file mode 100644 index 000000000000..a19fe7b7d629 --- /dev/null +++ b/pkgs/development/tools/build-managers/gnumake/parallel-remake.patch @@ -0,0 +1,39 @@ +fix from upstream cvs + +---------------------------- +revision 1.247 +date: 2011-09-18 19:39:26 -0400; author: psmith; state: Exp; lines: +5 -3; commitid: 07NxO4T5PiWC82Av; +When we re-exec the master makefile in a jobserver environment, ensure +that MAKEFLAGS is set properly so the re-exec'd make runs in parallel. +See Savannah bug #33873. + +Index: main.c +=================================================================== +RCS file: /sources/make/make/main.c,v +retrieving revision 1.246 +retrieving revision 1.247 +diff -u -p -r1.246 -r1.247 +--- main.c 29 Aug 2010 23:05:27 -0000 1.246 ++++ main.c 18 Sep 2011 23:39:26 -0000 1.247 +@@ -2089,6 +2089,11 @@ main (int argc, char **argv, char **envp + + ++restarts; + ++ /* If we're re-exec'ing the first make, put back the number of ++ job slots so define_makefiles() will get it right. */ ++ if (master_job_slots) ++ job_slots = master_job_slots; ++ + /* Reset makeflags in case they were changed. */ + { + const char *pv = define_makeflags (1, 1); +@@ -2825,9 +2830,6 @@ define_makeflags (int all, int makefile) + && (*(unsigned int *) cs->value_ptr == + *(unsigned int *) cs->noarg_value)) + ADD_FLAG ("", 0); /* Optional value omitted; see below. */ +- else if (cs->c == 'j') +- /* Special case for `-j'. */ +- ADD_FLAG ("1", 1); + else + { + char *buf = alloca (30);