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