From owner-freebsd-current Thu Nov 29 3:18:58 2001 Delivered-To: freebsd-current@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 0110737B43B; Thu, 29 Nov 2001 03:18:51 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id WAA26325; Thu, 29 Nov 2001 22:18:47 +1100 Date: Thu, 29 Nov 2001 22:18:51 +1100 (EST) From: Bruce Evans X-X-Sender: To: Robert Watson Cc: Subject: Re: LINT fails due to '/bin/sh:Argument list too long' In-Reply-To: Message-ID: <20011129220209.S1324-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, 26 Nov 2001, Robert Watson wrote: > Decided to run a LINT build on my POSIX.1e capability tree in p4 today, > and ran into something a bit unusual: > > make buildkernel KERNCONF=LINT > ... > boss/p4/rwatson/trustedbsd/cap/sys/kern/link_aout.c > /cboss/p4/rwatson/trustedbsd/cap/sys/kern/subr_diskmbr.c > /cboss/p4/rwatson/trustedbsd/cap/sys/libkern/divdi3.c /cboss/p4/rwatson/trustedbsd/cap/sys/libkern/moddi3.c > ... > /bin/sh:Argument list too long > *** Error code 1 > ... > Looks like the number of C files in the kernel was finally too much for > the make depend :-). Haven't seen this on my other trees I built LINT on > lately, so my guess is we're just at the threshold, and one or two more > files (such as in my p4 tree) bumps you over. config(8) -d bloats the pathnames by a factor of about 2, so there is plenty to spare if you don't use -d. It expands: ../../../kern/link_aout.c to: /cboss/p4/rwatson/trustedbsd/cap/sys/kern/link_aout.c My version of config(8) always creates a symlink "@" to the system sources and arranges to use that instead. This unbloats the path prefix a little more, from "../../.." to "./@". The only known problem with this is that it is not clear in error output where "@" points to. But this is already a problem for the "machine" symlink. I don't know how the inefficiencies for the symlink compare with the inefficiencies for the long pathnames. Old inefficiencies for the "machine" symlink are probably dominant anyway (since there are many more references to headers in "machine" than to *.c). Index: main.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/config/main.c,v retrieving revision 1.54 diff -u -2 -r1.54 main.c --- main.c 14 Jul 2001 00:03:05 -0000 1.54 +++ main.c 29 Jul 2001 13:44:45 -0000 @@ -77,8 +77,9 @@ int profiling; +static void cleanheaders(char *); static void configfile(void); static void get_srcdir(void); static void usage(void); -static void cleanheaders(char *); +static void symlinkifchanged(const char *linkcontents, const char *linkname); struct hdr_list { @@ -96,6 +97,6 @@ struct stat buf; - int ch, len; - char *p; + char *archname, *p; + int ch, cold, len; char xxx[MAXPATHLEN]; @@ -131,17 +132,20 @@ while (len > 1 && destdir[len - 1] == '/') destdir[--len] = '\0'; - get_srcdir(); } else { strlcpy(destdir, CDIR, sizeof(destdir)); strlcat(destdir, PREFIX, sizeof(destdir)); } + get_srcdir(); p = path((char *)NULL); if (stat(p, &buf)) { + cold = 1; if (mkdir(p, 0777)) err(2, "%s", p); + } else { + cold = 0; + if (!S_ISDIR(buf.st_mode)) + errx(2, "%s isn't a directory", p); } - else if ((buf.st_mode & S_IFMT) != S_IFDIR) - errx(2, "%s isn't a directory", p); dtab = NULL; @@ -153,16 +157,19 @@ exit(1); } + archname = getenv("MACHINE_ARCH"); /* XXX */ + if (archname == NULL) + archname = machinename; + /* - * make symbolic links in compilation directory - * for "sys" (to make genassym.c work along with #include ) - * and similarly for "machine". + * Create symbolic links "@" and "machine" to help the makefile + * locate the root of the kernel source tree and the + * include directory. */ - if (*srcdir == '\0') - (void)snprintf(xxx, sizeof(xxx), "../../include"); - else - (void)snprintf(xxx, sizeof(xxx), "%s/%s/include", - srcdir, machinename); - (void) unlink(path("machine")); - (void) symlink(xxx, path("machine")); + symlinkifchanged(srcdir, path("@")); + if ((unsigned)snprintf(xxx, sizeof(xxx), "@/%s/include", archname) >= + sizeof(xxx)) + errx(2, "preposterously long machine arch name"); + symlinkifchanged(xxx, path("machine")); + options(); /* make options .h files */ makefile(); /* build Makefile */ @@ -171,5 +178,6 @@ cleanheaders(p); printf("Kernel build directory is %s\n", p); - printf("Don't forget to do a ``make depend''\n"); + if (cold == 0) + printf("Don't forget to do a ``make depend''\n"); exit(0); } @@ -478,3 +486,24 @@ hl->h_next = htab; htab = hl; +} + +/* Create a symlink if the correct symlink doesn't already exist. */ +static void +symlinkifchanged(const char *linkcontents, const char *linkname) +{ + struct stat sb; + size_t len; + char buf[PATH_MAX]; + + if (lstat(linkname, &sb) == 0) { + if (S_ISLNK(sb.st_mode)) { + len = readlink(linkname, buf, sizeof(buf)); + if (len == strlen(linkcontents) && + strncmp(buf, linkcontents, len) == 0) + return; + } + (void)unlink(linkname); + } + if (symlink(linkcontents, linkname) != 0) + err(2, "symlink `%s' -> `%s'", linkname, linkcontents); } Index: mkmakefile.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/config/mkmakefile.c,v retrieving revision 1.71 diff -u -2 -r1.71 mkmakefile.c --- mkmakefile.c 17 Sep 2001 21:25:48 -0000 1.71 +++ mkmakefile.c 18 Sep 2001 00:34:56 -0000 @@ -156,6 +156,4 @@ fprintf(ofp, "PROFLEVEL=%d\n", profiling); } - if (*srcdir != '\0') - fprintf(ofp,"S=%s\n", srcdir); while (fgets(line, BUFSIZ, ifp) != 0) { if (*line != '%') { Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message