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