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