UPDATING revision 1.67
1$NetBSD: UPDATING,v 1.67 2002/09/21 04:12:35 lukem Exp $
2
3This file is intended to be a brief introduction to the build
4process and a reference on what to do if something doesn't work.
5
6For a more detailed description see Makefile.
7
8Recent changes:
9^^^^^^^^^^^^^^^
10
1120020917:
12	USE_NEW_TOOLCHAIN has been replaced with:
13	    -	TOOLCHAIN_MISSING -- set to "yes" on platforms for which
14		there is no working in-tree toolchain (hppa, ns32k, sh5,
15		x86_64).
16	    -	EXTERNAL_TOOLCHAIN -- if defined by the user, points to the
17		root ofan external toolchain (e.g. /usr/local/gnu).  This
18		enables the cross-build framework even for TOOLCHAIN_MISSING
19		platforms.
20
2120020906:
22	gehenna-devsw has been merged into the trunk. Need to update and
23	reinstall usr.sbin/config before build the kernel.
24
2520020822:
26	Crunched rescue tools (contents of /bin and /sbin, plus others)
27	are now provided in /rescue.
28
29	To ensure that these are built statically linked (no matter
30	what the setting of LDSTATIC is), use a crunchgen(1) built
31	from sources newer than 20020820 (see the next entry).
32
3320020820:
34	crunchgen(1) changed to ensure that the generated program
35	is statically linked.
36
37	Solution: update and reinstall usr.bin/crunch
38
3920020515:
40	sshd user/group has been added.  Need to hand add this in, or sshd
41	will not let you log in (with default, or UsePrivlegeSeparation=yes)
42
43	Add the following into /etc/group:
44
45	sshd:*:16:
46
47	and the following to /etc/master.passwd (via vipw):
48
49	sshd:*:16:16::0:0:& pseudo-user:/var/chroot/sshd:/sbin/nologin
50	
51	also /var/chroot/sshd directory needs to be present (digged as a part of
52	build process).
53
5420020426:
55	NBUILDJOBS obsoleted in favor of just using -j.
56
5720020426:
58	etc/postinstall added, which performs various checks for 
59	configuration file updates and changes, and can fix most of
60	the problems identified.
61	This should make it much easier to upgrade a system's
62	configuration from earlier systems (as far back as NetBSD 1.5).
63
6420020320:
65	<bsd.lib.mk> needs a new install(1) for it's "-a cmd" support.
66	build and install at usr.bin/xinstall before the build.
67
6820020319:
69	raw IPv6 socket now makes strict checking for sa_family and sa_len
70	on send(2) operation.  be sure to have sbin/rtsol and usr.sbin/rtsold
71	newer than November 2001 when you upgrade the kernel.
72
7320020311:
74	ssh configuration files were moved from /etc to /etc/ssh.  Beware
75	if you restart your machine from remote.  Note that sshd.conf needs
76	to be changed (due to the use of "/etc" inside).
77
7820020223:
79	Users of the VAX port will need to rebuild and install gas
80	so it deal with the now present register prefix used in all
81	the VAX assembly files.
82
8320020118:
84
85	ntpd user/group has been added.  Need to hand add this in or builds
86	will break as mtree aborts early.
87
88	Add the following into /etc/group:
89
90	ntpd:*:15:
91
92	and the following to /etc/master.passwd (via vipw):
93
94	ntpd:*:15:15::0:0:Ntpd pseudo-user:/var/chroot/ntpd:/sbin/nologin
95
9620011207:
97
98	If you're attempting to build a snapshot on sparc64 and are getting
99	reloc errors from the toolchain groff binary this means your native
100	toolchain has some broken C++ bits.
101
102	To fix:
103
104	Build a new toolchain (i.e. build.sh -t)
105	Use the new toolchain to build and install natively (i.e. /usr/lib)
106
107	gnu/lib/libgcc
108	gnu/lib/libstdc++
109
110	After this a snapshot will be able to be built.
111
11220011201:
113	In order for a sparc64 build to work you must have a working awk. If
114	you've built and installed a system with the new toolchain up to this
115	point you do not have a working awk as its ability to do floating
116	point is broken. 
117
118	To build:
119
120	remake and install gnu/lib/libgcc
121	remake and install gnu/usr.bin/gawk into /usr/bin (make sure it links
122	against the new libgcc.a)
123
12420011128:
125	Kernel config information was changed to use defflag in
126	the various "files" files.  Bug fixes to config(8) are
127	required in order for this to work properly.  Make sure
128	to build and install in usr.sbin/config before attempting
129	to build a new kernel.
130
13120011030:
132	libc/locale/wcstod.c now needs new lint(1). Update lint(1)
133	before building libc.
134
13520011029:
136	The new document BUILDING.mdoc (view with nroff | more, or
137	see pre-generated .txt and .html versions) describes the build
138	procedure in great detail.  BUILDING, and the USE_NEW_TOOLCHAIN
139	build process, are intended in the long run to replace this
140	manual update log.
141
142	Users building a USE_NEW_TOOLCHAIN system should read the
143	BUILDING document for caveats.  Generally, BUILDING supersedes
144	UPDATING for these systems, as tool updating is taken care of
145	by the new build system.
146
14720011028:
148	src/etc/Makefile now needs install to be able to handle
149	symlinks that point to nowhere. A bug in install that
150	prevented this was corrected.
151
152	Solution: update and reinstall usr.bin/xinstall
153	Better Solution: Use the new toolchain and it will just work
154	for you.
155
15620011006:
157	/etc/mtree/NetBSD.dist has been updated to take advantage of
158	absolute path support added to mtree(8). Older mtree(8)s don't
159	understand the format.
160
161	Solution: update and reinstall usr.sbin/mtree
162
16320011004:
164	Crunchgen has been updated to work via reach-over makefiles. Updating
165	is suggested before running a snapshot build
166
16720010915:
168	The new "ubcperf" code committed by Chuck Silvers removed
169	a header file, uvm/uvm_vnode.h.  There may be stale .depend
170	files that still reference this file.
171
172	Solution: "make cleandir && make dependall" in affected
173	directories.
174
17520010803:
176	grep.info is now built from grep.texi using makeinfo.  Since it
177	requires makeinfo v4.0, you need to install new texinfo before
178	building gnu/usr.bin/grep.  To install new texinfo, please follow
179	the instruction described in 20010726 entry.
180
18120010803: 
182	(i386 only): i386 kernel now uses new instructions like
183        `fxsave' which old gas doesn't understand.  To build the
184	kernel successfully, you need to build and install a new toolchain, 
185	(i.e., build.sh -t) or 	(temporarily) comment out "options I686_CPU" 
186	from your kernel configuration until you rebuild your userland.
187	See 20011029 above and BUILDING file in this directory for more information.
188	[updated 20020630 since i386 gas moved when USE_NEW_TOOLCHAIN enabled]
189
19020010731:
191	Bootloader update on ELF platforms.  DDB in kernels from before
192	this will be unable to read symbol tables provided by newer
193	bootloaders.
194
19520010726:
196	Texinfo was updated to 4.0.  To avoid failures when trying to
197	build the included texinfo files, do:
198
199	cd src/gnu/usr.bin/texinfo
200	make MKINFO=no dependall install
201
20220010718:
203	Enabled correct .init/.fini processing in crt0.  The way this
204	was done was to change a -I directive to cc(1), which means
205	make(1) will have a stale dependency (it will be checking the
206	timestamp on the wrong "dot_init.h").
207
208	The symptom you will see is that new programs die with SIGSEGV
209	if you have a stale dependency.
210
211	Solution: "make cleandir" in both lib/csu and libexec/ld.elf_so
212	before starting your build.
213
21420010628:
215	A construct was added to uvm_page.h that uncovered a bug
216	in lint(1).  If you get a warning/error about a non-portable
217	bitfield, update your lint(1) before proceeding.
218
21920010226:
220	Added named user/group to system. Need to hand add this in or builds
221	will break as mtree aborts early.
222
223	To work around add by hand:
224
225	named:*:14:
226
227	to /etc/group and add:
228
229	named:*:14:14::0:0:Named pseudo-user:/var/named:/sbin/nologin
230
231	to master.passwd (use vipw for instance if doing by hand).
232
233	Now a make build should progress.
234
23520010219:
236	get/setprogname() added. Any hostprogs that may use this will need
237        to be bootstrapped manually until the host system is current.
238
239        Known problems: sys/arch/macppc/stand/fixcoff
240			usr.sbin/config (adding -DMAKE_BOOTSTRAP to
241			  CFLAGS and rebuilding should work)
242			usr.sbin/mdsetimage - Build a static copy if
243  		          building a snapshot before fully bootstrapped.
244
24520010204:
246	prepare the code to compile with stricter gcc flags. in
247	particular start eliminating redundant declarations. Yacc
248	needs to be installed before make build.
249
25020010114:
251	introduce .if commands(target) in make(1). You need to
252	bring everything up-to-date first, then without installing
253	anything make and install in usr.bin/make, then proceed
254	with make build.
255
25620010101:
257	bsd.subdir.mk committed 20001230 had a bug which caused
258	afterinstall targets to run too soon; update again.
259
26020001230:
261	New share/mk files needed to support .WAIT in SUBDIR variables.
262	If you get make errors, 
263		(cd share/mk; make install)
264	Also, PRINTOBJDIR has changed and is now used more heavily.
265
26620001019:
267	The `ca' device driver has been replaced by `ld'; although the
268	major and minor numbers haven't changed, you should update your /dev
269	directory.
270
27120000929:
272	The following make directives are obsoleted.
273	MKCRYPTO_RSA NOCRYPTO_RSA NOCRYPTO_RC5 NOCRYPTO_IDEA 
274	By default, RSA is built into libcrypto.  IDEA and RC5 will not be
275	built into libcrypto.  By using MKCRYPTO_{RC5,IDEA}, you can build
276	additional library libcrypto_{idea,rc5}.
277
278
279Hints for a more successful build:
280^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
281    Build a new kernel first:
282	This makes sure that any new system calls or features
283	   expected by the new userland will be present.  This
284	   helps to avoid critical errors when upgrading.
285    Use object directories:
286	This helps to keep stale object
287	   files from polluting the build if a Makefile "forgets"
288	   about one.  It also makes it easier to clean up after
289	   a build.  It's also necessary if you want to use the
290	   same source tree for multiple machines.
291	   To use object directories:
292	    a) cd /usr/src ; make cleandir
293	    b) Add "OBJMACHINE=yes" to /etc/mk.conf
294	    c) Add "MKOBJDIRS=yes" to /etc/mk.conf
295	    d) cd /usr/src ; make build
296	   Note that running "make obj" in a directory will create
297	   in obj.$MACHINE directory.
298    Build to a DESTDIR:
299	This helps to keep old
300	   installed files (especially libraries) from interfering
301	   with the new build.
302	   To build to a DESTDIR, set the DESTDIR environment
303	   variable before running make build.  It should be set to
304	   the pathname of an initially empty directory.
305	   Problems: you might need to update critical utilities
306		without using DESTDIR since nothing is executed
307		from what is installed in DESTDIR.
308		(See critical utils, below)
309    Build often:
310	This keeps critical utilities current enough to not choke
311	on any other part of the source tree that depends on up to
312	date functionality.
313 
314What to do if things don't work:
315^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
316When things don't work there is usually a few things that commonly
317should be done.
318    1)	make includes
319	This should be done automatically by make build.
320    2)  cd share/mk && make install
321	Again, automatically done by make build.
322
323Failsafe rebuild of a small part of the tree:
324^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
325To make sure you rebuild something correctly you want to do
326something like the following:
327    1)  Make sure the includes and .mk files are up to date.
328    2)  Make sure any program used to build the particular
329	utility is up to date.  (yacc, lex, etc...)
330    3)  cd ...path/to/util...
331	make cleandir
332	rm ...all obj directories...
333	make cleandir			# yes, again
334	make obj
335	make depend && make
336
337Failsafe rebuild of the entire tree:
338^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
339If you really want to make sure the source tree is clean and
340ready for a build try the following.  Note that sourcing /etc/mk.conf
341(a make(1) Makefile) in this manner is not right, and will not work
342for anyone who uses any make(1) features in /etc/mk.conf.
343
344---cut here---
345#!/bin/sh
346. /etc/mk.conf
347
348if [ -z $NETBSDSRCDIR ] ; then
349    NETBSDSRCDIR=/usr/src
350fi
351if [ \! -d $NETBSDSRCDIR ] ; then
352    echo Unable to find sources
353    exit 1
354fi
355find $NETBSDSRCDIR -name \*.o -o -name obj.\* -o -name obj -exec rm \{\} \;
356
357if [ -z $BSDOBJDIR ] ; then
358    BSDOBJDIR=/usr/obj
359fi
360if [ -d $BSDOBJDIR ] ; then
361    rm -rf $BSDOBJDIR
362fi
363
364cd $NETBSDSRCDIR && make cleandir
365
366---cut here---
367
368Critical utilities:
369^^^^^^^^^^^^^^^^^^^
370	gnu/usr.bin/egcs
371	usr.bin/compile_et
372	usr.bin/make
373	usr.bin/yacc
374	usr.bin/lex
375	usr.bin/xlint
376	usr.sbin/config
377
378Other problems and possible solutions:
379^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
380Symptom:Unreasonable compiler errors.
381Fix:	Rebuild gnu/usr.bin/egcs
382
383Symptom:Complaints involving a Makefile.
384Fix:	Rebuild usr.bin/make:
385	cd usr.bin/make && make && make install
386        Or, a failsafe method if that doesn't work:
387	cd usr.bin/make && cc *.c */*.c -I . -o make && mv make /usr/bin
388
389Fix:	Make sure .mk files are up to date.
390	cd share/mk && make install
391
392Symptom:Kernel `config' fails to configure any kernel, including GENERIC.
393Fix:	Rebuild usr.sbin/config
394
395Symptom:
396Fix:	Rebuild usr.bin/yacc
397
398Symptom:
399Fix:	Rebuild usr.bin/lex
400
401Symptom:
402Fix:	rm /usr/lib/libbfd.a
403
404Symptom:Obsolete intermediate files are used during compilation
405Fix:	Try the following sequence of commands in the directory in question.
406	make cleandir; rm `make print-objdir`; make cleandir; make obj
407	(If you built the tree without "make obj" in the past, obsolete files
408	may remain.  The command tries to clean everything up)
409
410Symptom:.../sysinst/run.c:xx: warning: initialization from incompatible pointer type
411Fix:	Rebuild and install usr.bin/menuc
412
413Symptom:mklocale not found during build in share/locale/ctype
414Fix:	Build and install usr.bin/mklocale
415
416Symptom:undefined reference to `__assert13'
417Fix:    Rebuild and install lib/libc
418
419Symptom:usr.sbin/config fails to build.
420Fix:	Try building with -DMAKE_BOOTSTRAP added to CFLAGS in Makefile.
421
422Symptom:undefined reference to `getprogname' or `setprogname'
423Fix:    Rebuild and install lib/libc
424
425Symptom:lint does not understand the '-X' option
426Fix:    May need to build & install libs with NOLINT=1 before rebuilding lint
427