UPDATING revision 1.52
1$NetBSD: UPDATING,v 1.52 2002/02/23 17:06:24 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^^^^^^^^^^^^^^^
1020020118:
11
12	ntpd user/group has been added.  Need to hand add this in or builds
13	will break as mtree aborts early.
14
15	Add the following into /etc/group:
16
17	ntpd:*:15:
18
19	and the following to /etc/master.passwd (via vipw):
20
21	ntpd:*:15:15::0:0:Ntpd pseudo-user:/var/chroot/ntpd:/sbin/nologin
22
2320011207:
24
25	If you're attempting to build a snapshot on sparc64 and are getting
26	reloc errors from the toolchain groff binary this means your native
27	toolchain has some broken C++ bits.
28
29	To fix:
30
31	Build a new toolchain (i.e. build.sh -t)
32	Use the new toolchain to build and install natively (i.e. /usr/lib)
33
34	gnu/lib/libgcc
35	gnu/lib/libstdc++
36
37	After this a snapshot will be able to be built.
38
3920011201:
40	In order for a sparc64 build to work you must have a working awk. If
41	you've built and installed a system with the new toolchain up to this
42	point you do not have a working awk as its ability to do floating
43	point is broken. 
44
45	To build:
46
47	remake and install gnu/lib/libgcc
48	remake and install gnu/usr.bin/gawk into /usr/bin (make sure it links
49	against the new libgcc.a)
50
5120011128:
52	Kernel config information was changed to use defflag in
53	the various "files" files.  Bug fixes to config(8) are
54	required in order for this to work properly.  Make sure
55	to build and install in usr.sbin/config before attempting
56	to build a new kernel.
57
5820011030:
59	libc/locale/wcstod.c now needs new lint(1). Update lint(1)
60	before building libc.
61
6220011029:
63	The new document BUILDING.mdoc (view with nroff | more, or
64	see pre-generated .txt and .html versions) describes the build
65	procedure in great detail.  BUILDING, and the USE_NEW_TOOLCHAIN
66	build process, are intended in the long run to replace this
67	manual update log.
68
69	Users building a USE_NEW_TOOLCHAIN system should read the
70	BUILDING document for caveats.  Generally, BUILDING supersedes
71	UPDATING for these systems, as tool updating is taken care of
72	by the new build system.
73
7420011028:
75	src/etc/Makefile now needs install to be able to handle
76	symlinks that point to nowhere. A bug in install that
77	prevented this was corrected.
78
79	Solution: update and reinstall usr.bin/xinstall
80	Better Solution: Use the new toolchain and it will just work
81	for you.
82
8320011006:
84	/etc/mtree/NetBSD.dist has been updated to take advantage of
85	absolute path support added to mtree(8). Older mtree(8)s don't
86	understand the format.
87
88	Solution: update and reinstall usr.sbin/mtree
89
9020011004:
91	Crunchgen has been updated to work via reach-over makefiles. Updating
92	is suggested before running a snapshot build
93
9420010915:
95	The new "ubcperf" code committed by Chuck Silvers removed
96	a header file, uvm/uvm_vnode.h.  There may be stale .depend
97	files that still reference this file.
98
99	Solution: "make cleandir && make dependall" in affected
100	directories.
101
10220010803:
103	grep.info is now built from grep.texi using makeinfo.  Since it
104	requires makeinfo v4.0, you need to install new texinfo before
105	building gnu/usr.bin/grep.  To install new texinfo, please follow
106	the instruction described in 20010726 entry.
107
10820010803:
109	(i386 only): i386 kernel now uses new instructions like
110        `fxsave' which old gas doesn't understand.  To build the
111	kernel successfully, you need to build and install new gas
112	(gnu/usr.bin/gas.new), or (temporarily) comment out
113	"options I686_CPU" from your kernel configuration until you
114	rebuilt your userland (and got a new gas).
115
11620010731:
117	Bootloader update on ELF platforms.  DDB in kernels from before
118	this will be unable to read symbol tables provided by newer
119	bootloaders.
120
12120010726:
122	Texinfo was updated to 4.0.  To avoid failures when trying to
123	build the included texinfo files, do:
124
125	cd src/gnu/usr.bin/texinfo
126	make MKINFO=no dependall install
127
12820010718:
129	Enabled correct .init/.fini processing in crt0.  The way this
130	was done was to change a -I directive to cc(1), which means
131	make(1) will have a stale dependency (it will be checking the
132	timestamp on the wrong "dot_init.h").
133
134	The symptom you will see is that new programs die with SIGSEGV
135	if you have a stale dependency.
136
137	Solution: "make cleandir" in both lib/csu and libexec/ld.elf_so
138	before starting your build.
139
14020010628:
141	A construct was added to uvm_page.h that uncovered a bug
142	in lint(1).  If you get a warning/error about a non-portable
143	bitfield, update your lint(1) before proceeding.
144
14520010226:
146	Added named user/group to system. Need to hand add this in or builds
147	will break as mtree aborts early.
148
149	To work around add by hand:
150
151	named:*:14:
152
153	to /etc/group and add:
154
155	named:*:14:14::0:0:Named pseudo-user:/var/named:/sbin/nologin
156
157	to master.passwd (use vipw for instance if doing by hand).
158
159	Now a make build should progress.
160
16120010219:
162	get/setprogname() added. Any hostprogs that may use this will need
163        to be bootstrapped manually until the host system is current.
164
165        Known problems: sys/arch/macppc/stand/fixcoff
166			usr.sbin/config (adding -DMAKE_BOOTSTRAP to
167			  CFLAGS and rebuilding should work)
168			usr.sbin/mdsetimage - Build a static copy if
169  		          building a snapshot before fully bootstrapped.
170
17120010204:
172	prepare the code to compile with stricter gcc flags. in
173	particular start eliminating redundant declarations. Yacc
174	needs to be installed before make build.
175
17620010114:
177	introduce .if commands(target) in make(1). You need to
178	bring everything up-to-date first, then without installing
179	anything make and install in usr.bin/make, then proceed
180	with make build.
181
18220010101:
183	bsd.subdir.mk committed 20001230 had a bug which caused
184	afterinstall targets to run too soon; update again.
185
18620001230:
187	New share/mk files needed to support .WAIT in SUBDIR variables.
188	If you get make errors, 
189		(cd share/mk; make install)
190	Also, PRINTOBJDIR has changed and is now used more heavily.
191
19220001019:
193	The `ca' device driver has been replaced by `ld'; although the
194	major and minor numbers haven't changed, you should update your /dev
195	directory.
196
19720000929:
198	The following make directives are obsoleted.
199	MKCRYPTO_RSA NOCRYPTO_RSA NOCRYPTO_RC5 NOCRYPTO_IDEA 
200	By default, RSA is built into libcrypto.  IDEA and RC5 will not be
201	built into libcrypto.  By using MKCRYPTO_{RC5,IDEA}, you can build
202	additional library libcrypto_{idea,rc5}.
203
204
205Hints for a more successful build:
206^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
207    Build a new kernel first:
208	This makes sure that any new system calls or features
209	   expected by the new userland will be present.  This
210	   helps to avoid critical errors when upgrading.
211    Use object directories:
212	This helps to keep stale object
213	   files from polluting the build if a Makefile "forgets"
214	   about one.  It also makes it easier to clean up after
215	   a build.  It's also necessary if you want to use the
216	   same source tree for multiple machines.
217	   To use object directories:
218	    a) cd /usr/src ; make cleandir
219	    b) Add "OBJMACHINE=yes" to /etc/mk.conf
220	    c) Add "MKOBJDIRS=yes" to /etc/mk.conf
221	    d) cd /usr/src ; make build
222	   Note that running "make obj" in a directory will create
223	   in obj.$MACHINE directory.
224    Build to a DESTDIR:
225	This helps to keep old
226	   installed files (especially libraries) from interfering
227	   with the new build.
228	   To build to a DESTDIR, set the DESTDIR environment
229	   variable before running make build.  It should be set to
230	   the pathname of an initially empty directory.
231	   Problems: you might need to update critical utilities
232		without using DESTDIR since nothing is executed
233		from what is installed in DESTDIR.
234		(See critical utils, below)
235    Build often:
236	This keeps critical utilities current enough to not choke
237	on any other part of the source tree that depends on up to
238	date functionality.
239 
240What to do if things don't work:
241^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
242When things don't work there is usually a few things that commonly
243should be done.
244    1)	make includes
245	This should be done automatically by make build.
246    2)  cd share/mk && make install
247	Again, automatically done by make build.
248
249Failsafe rebuild of a small part of the tree:
250^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
251To make sure you rebuild something correctly you want to do
252something like the following:
253    1)  Make sure the includes and .mk files are up to date.
254    2)  Make sure any program used to build the particular
255	utility is up to date.  (yacc, lex, etc...)
256    3)  cd ...path/to/util...
257	make cleandir
258	rm ...all obj directories...
259	make cleandir			# yes, again
260	make obj
261	make depend && make
262
263Failsafe rebuild of the entire tree:
264^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
265If you really want to make sure the source tree is clean and
266ready for a build try the following.  Note that sourcing /etc/mk.conf
267(a make(1) Makefile) in this manner is not right, and will not work
268for anyone who uses any make(1) features in /etc/mk.conf.
269
270---cut here---
271#!/bin/sh
272. /etc/mk.conf
273
274if [ -z $BSDSRCDIR ] ; then
275    BSDSRCDIR=/usr/src
276fi
277if [ \! -d $BSDSRCDIR ] ; then
278    echo Unable to find sources
279    exit 1
280fi
281find $BSDSRCDIR -name \*.o -o -name obj.\* -o -name obj -exec rm \{\} \;
282
283if [ -z $BSDOBJDIR ] ; then
284    BSDOBJDIR=/usr/obj
285fi
286if [ -d $BSDOBJDIR ] ; then
287    rm -rf $BSDOBJDIR
288fi
289
290cd $BSDSRCDIR && make cleandir
291
292---cut here---
293
294Critical utilities:
295^^^^^^^^^^^^^^^^^^^
296	gnu/usr.bin/egcs
297	usr.bin/compile_et
298	usr.bin/make
299	usr.bin/yacc
300	usr.bin/lex
301	usr.bin/xlint
302	usr.sbin/config
303
304Other problems and possible solutions:
305^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
306Symptom:Unreasonable compiler errors.
307Fix:	Rebuild gnu/usr.bin/egcs
308
309Symptom:Complaints involving a Makefile.
310Fix:	Rebuild usr.bin/make:
311	cd usr.bin/make && make && make install
312        Or, a failsafe method if that doesn't work:
313	cd usr.bin/make && cc *.c */*.c -I . -o make && mv make /usr/bin
314
315Fix:	Make sure .mk files are up to date.
316	cd share/mk && make install
317
318Symptom:Kernel `config' fails to configure any kernel, including GENERIC.
319Fix:	Rebuild usr.sbin/config
320
321Symptom:
322Fix:	Rebuild usr.bin/yacc
323
324Symptom:
325Fix:	Rebuild usr.bin/lex
326
327Symptom:
328Fix:	rm /usr/lib/libbfd.a
329
330Symptom:Obsolete intermediate files are used during compilation
331Fix:	Try the following sequence of commands in the directory in question.
332	make cleandir; rm `make print-objdir`; make cleandir; make obj
333	(If you built the tree without "make obj" in the past, obsolete files
334	may remain.  The command tries to clean everything up)
335
336Symptom:.../sysinst/run.c:xx: warning: initialization from incompatible pointer type
337Fix:	Rebuild and install usr.bin/menuc
338
339Symptom:mklocale not found during build in share/locale/ctype
340Fix:	Build and install usr.bin/mklocale
341
342Symptom:undefined reference to `__assert13'
343Fix:    Rebuild and install lib/libc
344
345Symptom:usr.sbin/config fails to build.
346Fix:	Try building with -DMAKE_BOOTSTRAP added to CFLAGS in Makefile.
347
348Symptom:undefined reference to `getprogname' or `setprogname'
349Fix:    Rebuild and install lib/libc
350
351Symptom:lint does not understand the '-X' option
352Fix:    May need to build & install libs with NOLINT=1 before rebuilding lint
353