UPDATING revision 1.81
1$NetBSD: UPDATING,v 1.81 2002/12/23 06:55:33 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
1120021223:
12	The METALOG format changed slightly, to remove the leading
13	"${DESTDIR}" from path names.
14	This only affects people building with UNPRIVED.
15	For complete safety, remove the DESTDIR entirely and
16	update tools/mtree, before running make build.
17
1820021219:
19	install(1) had a '-N dbdir' option added, to specify an
20	alternate location to look up users & groups (instead
21	of the host system passwd(5) and group(5) databases).
22
23	The build system was modified to take advantage of
24	this option (using ${NETBSDSRCDIR}/etc), so if you
25	use USE_TOOLS==no, you may have to rebuild and
26	reinstall usr.bin/xinstall first.
27
2820021130:
29	fparseln(3) moved from libutil to libc.
30	If building to DESTDIR=/, reinstall the includes
31	and rebuild libc:
32		make includes
33		make do-lib-libc
34	If using build.sh, "cd tools/compat && make clean"
35	before rebuilding the tools.
36
3720021126:
38	The mk.conf(5) variable SYS_INCLUDE has been deprecated,
39	including the optional "SYS_INCLUDE=symlinks" support.
40	All header files, including <sys/*.h> are copied into
41	/usr/include.
42
4320021121:
44	The C run-time support files crtbegin.o and crtend.o
45	(and their companions crtbeginS.o and crtendS.o) were
46	split up, with new crti.o and crtn.o files resulting.
47	This means that libtool needs to be rebuilt once the
48	new libraries are installed.  The process of rebuilding
49	libtool will cause it to automatically notice the new
50	required files, but it *must* be rebuilt in order to
51	do this.
52
53	An out-of-date libtool will result in shared libraries
54	which lack _init() and _fini() routines, which means that
55	their global contructors/destructors will not be invoked.
56
5720021121:
58	A bug related to how ARM ELF objects were tagged has been
59	corrected.
60
61	NetBSD ARM ELF uses the soft-VFP floating point model by
62	default.  However, the assembler lacked support for marking
63	objects as using the VFP floating point format, and the
64	compiler was not properly passing the flag indicating "soft-VFP"
65	to the assembler.
66
67	Unfortunately, this means that the linker will now consider
68	old (i.e. not marked "softvfp") NetBSD ARM ELF objects to be
69	incompatible with new (properly marked) objects.
70
71	The problem will only manifest itself if you attempt to compile
72	a new program using the fixed toolchain, and link that program
73	against old libraries which do not have the proper "softvfp"
74	markings.  ALL OF YOUR EXISTING BINARIES AND SHARED LIBRARIES
75	WILL CONTINUE TO WORK PROPERLY.
76
77	The only work-around for the problem is to recompile all of
78	the libraries on the system.  The easiest way to do this for
79	system libraries is to install a binary snapshot; they are
80	generally available on releng.netbsd.org.  Any packages you
81	have installed which supply libraries will have to be recompiled
82	if you wish to link new programs against those libraries.
83
84	If you have questions about this matter, please contact
85	port-arm@netbsd.org.
86
8720021011:
88	Systrace has been improved to support privilege elevation.
89	Updating the kernel requires the userland part of systrace
90	to be rebuilt.
91
9220021010:
93	The config(8) grammar was changed to allow options to register
94	dependencies on attributes, as well as other options.  Users
95	must update and reinstall usr.sbin/config before building a new
96	kernel.
97
9820021009:
99	A new attribute dependency syntax was introduced to config(8),
100	which is now used by the SCSI configuration description.  Users
101	must update and reinstall usr.sbin/config before building a new
102	kernel.
103
10420021003:
105	Several changes have been made to the autoconfiguration
106	framework.  Users must update and reinstall usr.sbin/config
107	before building a new kernel.
108
10920021001:
110	The i386mp branch has been merged.  To compile a kernel, users
111	will need to add the option 'cpu* at mainbus?' to their configuration
112	file.  Multiprocessor kernels will need
113	ioapic*		at mainbus? apid ?
114	options		MULTIPROCESSOR
115	options		COM_MPLOCK
116
11720020922:
118	MKDYNAMICROOT=yes enabled by default, which means that
119	certain shared libraries are installed into /lib, the shared
120	linker is installed into /libexec, and all programs in /bin
121	and /sbin are dynamically linked.
122	If you do not use "make build", you should ensure that
123	you have the libraries and shared linker in the new locations,
124	with:
125		make do-lib-csu do-lib-libc do-lib do-gnu-lib do-ld.elf_so
126
12720020917:
128	USE_NEW_TOOLCHAIN has been replaced with:
129	    -	TOOLCHAIN_MISSING -- set to "yes" on platforms for which
130		there is no working in-tree toolchain (hppa, ns32k, sh5,
131		x86_64).
132	    -	EXTERNAL_TOOLCHAIN -- if defined by the user, points to the
133		root of an external toolchain (e.g. /usr/local/gnu).  This
134		enables the cross-build framework even for TOOLCHAIN_MISSING
135		platforms.
136
13720020906:
138	gehenna-devsw has been merged into the trunk. Need to update and
139	reinstall usr.sbin/config before building the kernel.
140
14120020822:
142	Crunched rescue tools (contents of /bin and /sbin, plus others)
143	are now provided in /rescue.
144
145	To ensure that these are built statically linked (no matter
146	what the setting of LDSTATIC is), use a crunchgen(1) built
147	from sources newer than 20020820 (see the next entry).
148
14920020820:
150	crunchgen(1) changed to ensure that the generated program
151	is statically linked.
152
153	Solution: update and reinstall usr.bin/crunch
154
15520020515:
156	sshd user/group has been added.  Need to hand add this in, or sshd
157	will not let you log in (with default, or UsePrivlegeSeparation=yes)
158
159	Add the following into /etc/group:
160
161	sshd:*:16:
162
163	and the following to /etc/master.passwd (via vipw):
164
165	sshd:*:16:16::0:0:& pseudo-user:/var/chroot/sshd:/sbin/nologin
166	
167	Also /var/chroot/sshd directory needs to be present (digged as part of
168	the build process).
169
17020020426:
171	NBUILDJOBS obsoleted in favor of just using -j.
172
17320020426:
174	etc/postinstall added, which performs various checks for 
175	configuration file updates and changes, and can fix most of
176	the problems identified.
177	This should make it much easier to upgrade a system's
178	configuration from earlier systems (as far back as NetBSD 1.5).
179
18020020320:
181	<bsd.lib.mk> needs a new install(1) for its "-a cmd" support.
182	Build and install at usr.bin/xinstall before the build.
183
18420020319:
185	Raw IPv6 socket now makes strict checking for sa_family and sa_len
186	on send(2) operation.  Be sure to have sbin/rtsol and usr.sbin/rtsold
187	newer than November 2001 when you upgrade the kernel.
188
18920020311:
190	ssh configuration files were moved from /etc to /etc/ssh.  Beware
191	if you restart your machine from remote.  Note that sshd.conf needs
192	to be changed (due to the use of "/etc" inside).
193
19420020223:
195	Users of the VAX port will need to rebuild and install gas
196	so it deal with the now present register prefix used in all
197	the VAX assembly files.
198
19920020118:
200	ntpd user/group has been added.  Need to hand add this in or builds
201	will break as mtree aborts early.
202
203	Add the following into /etc/group:
204
205	ntpd:*:15:
206
207	and the following to /etc/master.passwd (via vipw):
208
209	ntpd:*:15:15::0:0:Ntpd pseudo-user:/var/chroot/ntpd:/sbin/nologin
210
21120011207:
212	If you're attempting to build a snapshot on sparc64 and are getting
213	reloc errors from the toolchain groff binary this means your native
214	toolchain has some broken C++ bits.
215
216	To fix:
217
218	Build a new toolchain (i.e. build.sh -t)
219	Use the new toolchain to build and install natively (i.e. /usr/lib)
220
221	gnu/lib/libgcc
222	gnu/lib/libstdc++
223
224	After this a snapshot will be able to be built.
225
22620011201:
227	In order for a sparc64 build to work you must have a working awk. If
228	you've built and installed a system with the new toolchain up to this
229	point you do not have a working awk as its ability to do floating
230	point is broken. 
231
232	To build:
233
234	remake and install gnu/lib/libgcc
235	remake and install gnu/usr.bin/gawk into /usr/bin (make sure it links
236	against the new libgcc.a)
237
23820011128:
239	Kernel config information was changed to use defflag in
240	the various "files" files.  Bug fixes to config(8) are
241	required in order for this to work properly.  Make sure
242	to build and install in usr.sbin/config before attempting
243	to build a new kernel.
244
24520011030:
246	libc/locale/wcstod.c now needs new lint(1). Update lint(1)
247	before building libc.
248
24920011029:
250	The new document BUILDING.mdoc (view with nroff | more, or
251	see pre-generated .txt and .html versions) describes the build
252	procedure in great detail.  BUILDING, and the USE_NEW_TOOLCHAIN
253	build process, are intended in the long run to replace this
254	manual update log.
255
256	Users building a USE_NEW_TOOLCHAIN system should read the
257	BUILDING document for caveats.  Generally, BUILDING supersedes
258	UPDATING for these systems, as tool updating is taken care of
259	by the new build system.
260
26120011028:
262	src/etc/Makefile now needs install to be able to handle
263	symlinks that point to nowhere. A bug in install that
264	prevented this was corrected.
265
266	Solution: update and reinstall usr.bin/xinstall
267	Better Solution: Use the new toolchain and it will just work
268	for you.
269
27020011006:
271	/etc/mtree/NetBSD.dist has been updated to take advantage of
272	absolute path support added to mtree(8). Older mtree(8)s don't
273	understand the format.
274
275	Solution: update and reinstall usr.sbin/mtree
276
27720011004:
278	Crunchgen has been updated to work via reach-over makefiles. Updating
279	is suggested before running a snapshot build
280
28120010915:
282	The new "ubcperf" code committed by Chuck Silvers removed
283	a header file, uvm/uvm_vnode.h.  There may be stale .depend
284	files that still reference this file.
285
286	Solution: "make cleandir && make dependall" in affected
287	directories.
288
28920010803:
290	grep.info is now built from grep.texi using makeinfo.  Since it
291	requires makeinfo v4.0, you need to install new texinfo before
292	building gnu/usr.bin/grep.  To install new texinfo, please follow
293	the instruction described in 20010726 entry.
294
29520010803: 
296	(i386 only): i386 kernel now uses new instructions like
297        `fxsave' which old gas doesn't understand.  To build the
298	kernel successfully, you need to build and install a new toolchain, 
299	(i.e., build.sh -t) or 	(temporarily) comment out "options I686_CPU" 
300	from your kernel configuration until you rebuild your userland.
301	See 20011029 above and BUILDING file in this directory for more information.
302	[updated 20020630 since i386 gas moved when USE_NEW_TOOLCHAIN enabled]
303
30420010731:
305	Bootloader update on ELF platforms.  DDB in kernels from before
306	this will be unable to read symbol tables provided by newer
307	bootloaders.
308
30920010726:
310	Texinfo was updated to 4.0.  To avoid failures when trying to
311	build the included texinfo files, do:
312
313	cd src/gnu/usr.bin/texinfo
314	make MKINFO=no dependall install
315
31620010718:
317	Enabled correct .init/.fini processing in crt0.  The way this
318	was done was to change a -I directive to cc(1), which means
319	make(1) will have a stale dependency (it will be checking the
320	timestamp on the wrong "dot_init.h").
321
322	The symptom you will see is that new programs die with SIGSEGV
323	if you have a stale dependency.
324
325	Solution: "make cleandir" in both lib/csu and libexec/ld.elf_so
326	before starting your build.
327
32820010628:
329	A construct was added to uvm_page.h that uncovered a bug
330	in lint(1).  If you get a warning/error about a non-portable
331	bitfield, update your lint(1) before proceeding.
332
33320010226:
334	Added named user/group to system. Need to hand add this in or builds
335	will break as mtree aborts early.
336
337	To work around add by hand:
338
339	named:*:14:
340
341	to /etc/group and add:
342
343	named:*:14:14::0:0:Named pseudo-user:/var/named:/sbin/nologin
344
345	to master.passwd (use vipw for instance if doing by hand).
346
347	Now a make build should progress.
348
34920010219:
350	get/setprogname() added. Any hostprogs that may use this will need
351        to be bootstrapped manually until the host system is current.
352
353        Known problems: sys/arch/macppc/stand/fixcoff
354			usr.sbin/config (adding -DMAKE_BOOTSTRAP to
355			  CFLAGS and rebuilding should work)
356			usr.sbin/mdsetimage - Build a static copy if
357  		          building a snapshot before fully bootstrapped.
358
35920010204:
360	prepare the code to compile with stricter gcc flags. in
361	particular start eliminating redundant declarations. Yacc
362	needs to be installed before make build.
363
36420010114:
365	introduce .if commands(target) in make(1). You need to
366	bring everything up-to-date first, then without installing
367	anything make and install in usr.bin/make, then proceed
368	with make build.
369
37020010101:
371	bsd.subdir.mk committed 20001230 had a bug which caused
372	afterinstall targets to run too soon; update again.
373
37420001230:
375	New share/mk files needed to support .WAIT in SUBDIR variables.
376	If you get make errors, 
377		(cd share/mk; make install)
378	Also, PRINTOBJDIR has changed and is now used more heavily.
379
38020001019:
381	The `ca' device driver has been replaced by `ld'; although the
382	major and minor numbers haven't changed, you should update your /dev
383	directory.
384
38520000929:
386	The following make directives are obsoleted.
387	MKCRYPTO_RSA NOCRYPTO_RSA NOCRYPTO_RC5 NOCRYPTO_IDEA 
388	By default, RSA is built into libcrypto.  IDEA and RC5 will not be
389	built into libcrypto.  By using MKCRYPTO_{RC5,IDEA}, you can build
390	additional library libcrypto_{idea,rc5}.
391
392
393Hints for a more successful build:
394^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
395    Build a new kernel first:
396	This makes sure that any new system calls or features
397	   expected by the new userland will be present.  This
398	   helps to avoid critical errors when upgrading.
399    Use object directories:
400	This helps to keep stale object
401	   files from polluting the build if a Makefile "forgets"
402	   about one.  It also makes it easier to clean up after
403	   a build.  It's also necessary if you want to use the
404	   same source tree for multiple machines.
405	   To use object directories:
406	    a) cd /usr/src ; make cleandir
407	    b) Add "OBJMACHINE=yes" to /etc/mk.conf
408	    c) Add "MKOBJDIRS=yes" to /etc/mk.conf
409	    d) cd /usr/src ; make build
410	   Note that running "make obj" in a directory will create
411	   in obj.$MACHINE directory.
412    Build to a DESTDIR:
413	This helps to keep old
414	   installed files (especially libraries) from interfering
415	   with the new build.
416	   To build to a DESTDIR, set the DESTDIR environment
417	   variable before running make build.  It should be set to
418	   the pathname of an initially empty directory.
419	   Problems: you might need to update critical utilities
420		without using DESTDIR since nothing is executed
421		from what is installed in DESTDIR.
422		(See critical utils, below)
423    Build often:
424	This keeps critical utilities current enough to not choke
425	on any other part of the source tree that depends on up to
426	date functionality.
427 
428What to do if things don't work:
429^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
430When things don't work there is usually a few things that commonly
431should be done.
432    1)	make includes
433	This should be done automatically by make build.
434    2)  cd share/mk && make install
435	Again, automatically done by make build.
436
437Failsafe rebuild of a small part of the tree:
438^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
439To make sure you rebuild something correctly you want to do
440something like the following:
441    1)  Make sure the includes and .mk files are up to date.
442    2)  Make sure any program used to build the particular
443	utility is up to date.  (yacc, lex, etc...)
444    3)  cd ...path/to/util...
445	make cleandir
446	rm ...all obj directories...
447	make cleandir			# yes, again
448	make obj
449	make depend && make
450
451Failsafe rebuild of the entire tree:
452^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
453If you really want to make sure the source tree is clean and
454ready for a build try the following.  Note that sourcing /etc/mk.conf
455(a make(1) Makefile) in this manner is not right, and will not work
456for anyone who uses any make(1) features in /etc/mk.conf.
457
458---cut here---
459#!/bin/sh
460. /etc/mk.conf
461
462if [ -z $NETBSDSRCDIR ] ; then
463    NETBSDSRCDIR=/usr/src
464fi
465if [ \! -d $NETBSDSRCDIR ] ; then
466    echo Unable to find sources
467    exit 1
468fi
469find $NETBSDSRCDIR -name \*.o -o -name obj.\* -o -name obj -exec rm \{\} \;
470
471if [ -z $BSDOBJDIR ] ; then
472    BSDOBJDIR=/usr/obj
473fi
474if [ -d $BSDOBJDIR ] ; then
475    rm -rf $BSDOBJDIR
476fi
477
478cd $NETBSDSRCDIR && make cleandir
479
480---cut here---
481
482Critical utilities:
483^^^^^^^^^^^^^^^^^^^
484	gnu/usr.bin/egcs
485	usr.bin/compile_et
486	usr.bin/make
487	usr.bin/yacc
488	usr.bin/lex
489	usr.bin/xlint
490	usr.sbin/config
491
492Other problems and possible solutions:
493^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
494Symptom:Unreasonable compiler errors.
495Fix:	Rebuild gnu/usr.bin/egcs
496
497Symptom:Complaints involving a Makefile.
498Fix:	Rebuild usr.bin/make:
499	cd usr.bin/make && make && make install
500        Or, a failsafe method if that doesn't work:
501	cd usr.bin/make && cc *.c */*.c -I . -o make && mv make /usr/bin
502
503Fix:	Make sure .mk files are up to date.
504	cd share/mk && make install
505
506Symptom:Kernel `config' fails to configure any kernel, including GENERIC.
507Fix:	Rebuild usr.sbin/config
508
509Symptom:
510Fix:	Rebuild usr.bin/yacc
511
512Symptom:
513Fix:	Rebuild usr.bin/lex
514
515Symptom:
516Fix:	rm /usr/lib/libbfd.a
517
518Symptom:Obsolete intermediate files are used during compilation
519Fix:	Try the following sequence of commands in the directory in question.
520	make cleandir; rm `make print-objdir`; make cleandir; make obj
521	(If you built the tree without "make obj" in the past, obsolete files
522	may remain.  The command tries to clean everything up)
523
524Symptom:.../sysinst/run.c:xx: warning: initialization from incompatible pointer type
525Fix:	Rebuild and install usr.bin/menuc
526
527Symptom:mklocale not found during build in share/locale/ctype
528Fix:	Build and install usr.bin/mklocale
529
530Symptom:undefined reference to `__assert13'
531Fix:    Rebuild and install lib/libc
532
533Symptom:usr.sbin/config fails to build.
534Fix:	Try building with -DMAKE_BOOTSTRAP added to CFLAGS in Makefile.
535
536Symptom:undefined reference to `getprogname' or `setprogname'
537Fix:    Rebuild and install lib/libc
538
539Symptom:lint does not understand the '-X' option
540Fix:    May need to build & install libs with NOLINT=1 before rebuilding lint
541