Subject: Re: why not "make includes" before "make do-tools" for build.sh?
To: NetBSD Userlevel Technical Discussion List <tech-userlevel@NetBSD.ORG>
From: Greg A. Woods <woods@weird.com>
List: tech-userlevel
Date: 05/17/2003 03:29:26
[ On Thursday, May 8, 2003 at 23:20:36 (+0100), Ben Harris wrote: ]
> Subject: Re: why not "make includes" before "make do-tools" for build.sh?
>
> In article <m19Doxf-000B3kC@proven.weird.com> you write:
> > If the tools build doesn't use $DESTDIR/include then my suggestion is
> > obviously pointless, however it seems to me that if the build of the
> > tools does use $DESTDIR/include then "make includes" must be run before
> > the (rest of the) tools are built.
> 
> It shouldn't (since $DESTDIR/usr/include might not even exist at that
> point), but your experience suggests that under some circumstances, it does.
> Someone should work out why, and how to fix that.

Well I have not yet had a chance to repeat my experiment with <paths.h>
(i.e. the one that prompted me to post initially), however I have just
found an example of a host tool which definitely should be compiled
against at least one of the target system's header files:  nbpwd_mkdb.

I noticed this after I posted about the NFS anonymous user on
netbsd-users and then remembered I had not yet merged my custom
master.passwd and group files with my netbsd-1-6 branch source tree, and
so I proceded to do that and then re-run 'build.sh -U'.  Note I had
already merged the prerequisite fixes to the header file in question,
long before my TOOLDIR was last rebuilt in fact.


$ ./build.sh -u -o -U -d -D ~/NetBSD-1.6.x-destdir -R ~/NetBSD-1.6.x-release -T ~/NetBSD-1.6.x-tools -M ~/NetBSD-1.6.x-obj
[[ .... ]]
/home/woods/NetBSD-1.6.x-tools/bin/nbpwd_mkdb -p -L -d /home/woods/NetBSD-1.6.x-destdir/  /home/woods/NetBSD-1.6.x-destdir/etc/master.passwd
nbpwd_mkdb: invalid uid '4294967294'
nbpwd_mkdb: at line #35
nbpwd_mkdb: /home/woods/NetBSD-1.6.x-destdir/etc/master.passwd: Inappropriate file type or format
*** Error code 1

Stop.
nbmake: stopped in /work/woods/m-NetBSD-1.6/etc
*** Error code 1

Stop.
nbmake: stopped in /work/woods/m-NetBSD-1.6/etc
*** Error code 1

Stop.
nbmake: stopped in /work/woods/m-NetBSD-1.6

$ ls -l sys/sys/syslimits.h
-rw-r--r--  1 woods  wheel  3937 Sep 20  2002 sys/sys/syslimits.h
$ ls -l /home/woods/NetBSD-1.6.x-tools/bin/nbpwd_mkdb
-r-xr-xr-x  1 woods  local  87911 May 16 14:27 /home/woods/NetBSD-1.6.x-tools/bin/nbpwd_mkdb
$ fgrep UID_MAX /usr/include/sys/syslimits.h 
#define UID_MAX            2147483647U  /* max value for a uid_t (2^31-2) */
$ fgrep UID_MAX sys/sys/syslimits.h                 
#define UID_MAX       ((~(uid_t)0)-1)   /* max value for a uid_t (2^32-1) */



This is a bit of a pedantic example of course, especially since I
believe the build procedure should not include as one of its steps the
construction of the etc/*pwd.db files (they, along with other similar
files should be built by the system installation procedure, perhaps
'postinstall' now that we have it).

Worst of all I see that when building on non-NetBSD hosts that don't
define a native UID_MAX value of their own then a super-conservative
limit of just 2^15-2 is imposed by tools/compat/compat_defs.h.

I suspect the namespace pollution issues make solving this a most
intractable problem to solve in any generic way.  If pwd_mkdb is to
handle this properly the only viable fix would seem to be to introduce
variant code to explicitly handle being built as a host build tool, i.e.
to make sure it uses the build tree's sys/sys/syslimits.h if the limit
checks are to be preserved for this purpose.

-- 
								Greg A. Woods

+1 416 218-0098;            <g.a.woods@ieee.org>;           <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>