2003-07-09 00:38:14

by Bart Trojanowski

[permalink] [raw]
Subject: [PATCH 2.4.21] kernel fails to build in deeply nested directories

I ran into this when building the kernel in a directory whose path name
was quite long. This is probably not a problem for most that build in
/usr/src/linux, but I was able to reproduce it when building a debian
kernel (that adds in about 40 characters on it's own) in my home
directory.

The error comes from bash telling me that ...

scripts/mkdep -- `find $(FINDHPATH) \( -name SCCS -o -name .svn \) -prune -o -follow -name \*.h ! -name modversions.h -print` > .hdepend

... generates a command line that exceeds bash's limit.

The fix is to allow mkdep to take the list of parameters on stdin and as
arguments.

The patch that follows, only changes the top level Makefile's dep-files
rule.

Regards,
Bart.


diff -ruN linux-2.4.21-org/Makefile linux-2.4.21/Makefile
--- linux-2.4.21-org/Makefile 2003-06-13 10:51:39.000000000 -0400
+++ linux-2.4.21/Makefile 2003-07-08 20:40:43.000000000 -0400
@@ -493,7 +493,7 @@
ifdef CONFIG_MODVERSIONS
$(MAKE) update-modverfile
endif
- scripts/mkdep -- `find $(FINDHPATH) \( -name SCCS -o -name .svn \) -prune -o -follow -name \*.h ! -name modversions.h -print` > .hdepend
+ find $(FINDHPATH) \( -name SCCS -o -name .svn \) -prune -o -follow -name \*.h ! -name modversions.h -print | scripts/mkdep --stdin > .hdepend
scripts/mkdep -- init/*.c > .depend

ifdef CONFIG_MODVERSIONS
diff -ruN linux-2.4.21-org/scripts/mkdep.c linux-2.4.21/scripts/mkdep.c
--- linux-2.4.21-org/scripts/mkdep.c 2002-08-02 20:39:46.000000000 -0400
+++ linux-2.4.21/scripts/mkdep.c 2003-07-08 20:42:25.000000000 -0400
@@ -43,9 +43,9 @@
#include <sys/stat.h>
#include <sys/types.h>

+#define MAX_FILE_NAME_LEN 512

-
-char __depname[512] = "\n\t@touch ";
+char __depname[MAX_FILE_NAME_LEN] = "\n\t@touch ";
#define depname (__depname+9)
int hasdep;

@@ -531,6 +531,7 @@
fd = open(filename, O_RDONLY);
if (fd < 0) {
perror(filename);
+ exit(1);
return;
}

@@ -577,6 +578,7 @@
{
int len;
const char *hpath;
+ int use_stdin = 0;

hpath = getenv("HPATH");
if (!hpath) {
@@ -598,6 +600,10 @@
add_path(*argv);
}
}
+ else if (strcmp(*argv, "--stdin") == 0) {
+ use_stdin = 1;
+ break;
+ }
else if (strcmp(*argv, "--") == 0) {
break;
}
@@ -605,24 +611,58 @@

add_path(hpath); /* must be last entry, for config files */

- while (--argc > 0) {
- const char * filename = *++argv;
- const char * command = __depname;
- g_filename = 0;
- len = strlen(filename);
- memcpy(depname, filename, len+1);
- if (len > 2 && filename[len-2] == '.') {
- if (filename[len-1] == 'c' || filename[len-1] == 'S') {
- depname[len-1] = 'o';
- g_filename = filename;
- command = "";
+ if (use_stdin) {
+ /* process entries passed in by stdin */
+
+ char buff[MAX_FILE_NAME_LEN];
+ char *line;
+
+ while ((line = fgets(buff, MAX_FILE_NAME_LEN, stdin))) {
+ char * filename = line;
+ const char * command = __depname;
+ g_filename = 0;
+ len = strlen(filename);
+ while (isspace (filename[len-1])) {
+ len--;
+ filename[len]=0;
+ }
+ memcpy(depname, filename, len+1);
+ if (len > 2 && filename[len-2] == '.') {
+ if (filename[len-1] == 'c'
+ || filename[len-1] == 'S') {
+ depname[len-1] = 'o';
+ g_filename = filename;
+ command = "";
+ }
}
+ do_depend(filename, command);
+ }
+
+ } else {
+ /* process entries passed in by command line arguments */
+
+ while (--argc > 0) {
+ const char * filename = *++argv;
+ const char * command = __depname;
+ g_filename = 0;
+ len = strlen(filename);
+ memcpy(depname, filename, len+1);
+ if (len > 2 && filename[len-2] == '.') {
+ if (filename[len-1] == 'c'
+ || filename[len-1] == 'S') {
+ depname[len-1] = 'o';
+ g_filename = filename;
+ command = "";
+ }
+ }
+ do_depend(filename, command);
}
- do_depend(filename, command);
}
+
if (len_precious) {
*(str_precious+len_precious) = '\0';
printf(".PRECIOUS:%s\n", str_precious);
}
return 0;
}
+


Attachments:
(No filename) (3.91 kB)
(No filename) (189.00 B)
Download all attachments