Date: Sat, 19 Jan 2002 20:00:02 -0800 (PST) From: Bruce Evans <bde@zeta.org.au> To: freebsd-bugs@FreeBSD.org Subject: Re: misc/34062: bsd.kmod.mk fails due to bug in make with .PATH and exists() function Message-ID: <200201200400.g0K402p32877@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR misc/34062; it has been noted by GNATS.
From: Bruce Evans <bde@zeta.org.au>
To: Kevin Walsh <walsh@cs.duke.edu>
Cc: <freebsd-gnats-submit@FreeBSD.ORG>
Subject: Re: misc/34062: bsd.kmod.mk fails due to bug in make with .PATH and
exists() function
Date: Sun, 20 Jan 2002 14:59:13 +1100 (EST)
On Sat, 19 Jan 2002, Kevin Walsh wrote:
> >Release: 4.3-RELEASE
> >Description:
> When attempting to compile the 4.4-RELEASE kernel modules ('make modules' from the compile/DUMMY directory) make fails with the error:
> ===> libmchain
> "/usr/share/mk/bsd.kmod.mk", line 10: "can't find kernel source tree"
> *** Error code 1
>
> A tour of libmchain/Makefile and the bsd.kmod.mk file reveals the following bug.
> If a path (in this case /blah/blah/../../kern) is specified in the .PATH (as it is in libmchain/Makefile), then the .exists() function will fail when searching for the exact same path if a trailing '/' is left on (in this case, bsd.kmod.mk searches for /blah/blah/../../kern/).
>
> This bug is too obvious and problematic to be real. I ran into it on my very first FreeBSD compile ever (and in multiple places, too!)
kmod.mk was "fixed" (your Workaround 1) in -current (rev.1.86) and
4.4-release (rev.1.82.2.7) to work around the bug. The trailing slash
was used to force a check for a directory (or maybe to follow a symlink
named kern), and removing it allows plain files to match.
> >How-To-Repeat:
> Do 'make modules'.
> Or run 'make' in a directory with the following Makefile:
> # Makefile -- this will break the FreeBSD make (pmake???) and
> # illustrates what is wrong with the kernel makefiles
> [... good example]
This actually illustrates something that is wrong with FreeBSD make
(pmake???).
> >Fix:
> Workaround 1: fix all of the makefiles to never search for a directory with a trailing '/' character.
> Workaround 2: fix all of the module makefiles to never include '../../kern'.
>
> Fix: Change the function Dir_FindFile(name,path) in usr.bin/make/dir.c
> so that (1) there is a check to see if 'name' is absolute BEFORE failing, and/or (2) trailing slashes are recognized and handled appropriately.
I have used the following since a few hours after kmod.mk was "fixed". The
fixer and the MAINTAINER didn't respond to mails asking for a proper fix.
I didn't commit this because I don't really understand the code and suspect
that there is more to the bug than this.
%%
Index: dir.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/make/dir.c,v
retrieving revision 1.17
diff -u -2 -r1.17 dir.c
--- dir.c 25 Apr 2001 14:45:36 -0000 1.17
+++ dir.c 25 Apr 2001 22:47:54 -0000
@@ -764,4 +764,9 @@
hits += 1;
return (file);
+#if 0
+ /*
+ * XXX: this breaks finding names like "foo/", "foo//" and even
+ * "foo/." when the directory "foo" has been found previously.
+ */
} else if (hasSlash) {
/*
@@ -780,4 +785,5 @@
return ((char *) NULL);
}
+#endif
}
}
%%%
Bruce
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200201200400.g0K402p32877>
