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