UPDATING revision 1.43
1$NetBSD: UPDATING,v 1.43 2001/10/29 01:53:56 mason 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
8Note that users of the new toolchain in many instances will not
9experience the problems listed below because their host tools are
10automatically generated for them.
11
12Recent changes:
13^^^^^^^^^^^^^^^
14
1520011028:
16        /usr/src/build.sh exists as of 2001.10.19. From the cvs log:
17
18        "Script to automate bootstrapping a build on any host platform.
19         Creates a bmake (rebuilds, if necessary) and invokes that to
20         start the build."
21
22        This should, incidentally, allow 1.5.x hosts to build -current
23        using the new toolchain, on USE_NEW_TOOLCHAIN-enabled platforms.
24
2520011028:
26	src/etc/Makefile now needs install to be able to handle
27	symlinks that point to nowhere. A bug in install that
28	prevented this was corrected.
29
30	Solution: update and reinstall usr.bin/xinstall
31	Better Solution: Use the new toolchain and it will just work
32	for you.
33
3420011006:
35	/etc/mtree/NetBSD.dist has been updated to take advantage of
36	absolute path support added to mtree(8). Older mtree(8)s don't
37	understand the format.
38
39	Solution: update and reinstall usr.sbin/mtree
40
4120011004:
42
43	Crunchgen has been updated to work via reach-over makefiles. Updating
44	is suggested before running a snapshot build
45
4620010922:
47	The new toolchain is enabled on i386.  This new build method
48	is intended to make all the upgrade issues elsewhere in UPDATING
49	obsolete (stay tuned...).
50
51	i386 platform builds must now set TOOLDIR in mk.conf or the
52	environment in order to build the system.  This is a pathname
53	where host build tools will be installed, and must NOT be
54	the same as src/tools.
55
56	(Optionally, USETOOLS=no can be set in the environment if you
57	wish to avoid using the separate host toolchain for building a
58	subtree.  Otherwise, this will default to "yes" automatically.)
59
6020010915:
61	The new "ubcperf" code committed by Chuck Silvers removed
62	a header file, uvm/uvm_vnode.h.  There may be stale .depend
63	files that still reference this file.
64
65	Solution: "make cleandir && make dependall" in affected
66	directories.
67
6820010803:
69	grep.info is now built from grep.texi using makeinfo.  Since it
70	requires makeinfo v4.0, you need to install new texinfo before
71	building gnu/usr.bin/grep.  To install new texinfo, please follow
72	the instruction described in 20010726 entry.
73
7420010803:
75	(i386 only): i386 kernel now uses new instructions like
76        `fxsave' which old gas doesn't understand.  To build the
77	kernel successfuly, you need to build and install new gas
78	(gnu/usr.bin/gas.new), or (temporarily) comment out
79	"options I686_CPU" from your kernel configuration until you
80	rebuilt your userland (and got a new gas).
81
8220010731:
83	Bootloader update on ELF platforms.  DDB in kernels from before
84	this will be unable to read symbol tables provided by newer
85	bootloaders.
86
8720010726:
88	Texinfo was updated to 4.0.  To avoid failures when trying to
89	build the included texinfo files, do:
90
91	cd src/gnu/usr.bin/texinfo
92	make MKINFO=no dependall install
93
9420010718:
95
96	Enabled correct .init/.fini processing in crt0.  The way this
97	was done was to change a -I directive to cc(1), which means
98	make(1) will have a stale dependency (it will be checking the
99	timestamp on the wrong "dot_init.h").
100
101	The symptom you will see is that new programs die with SIGSEGV
102	if you have a stale dependency.
103
104	Solution: "make cleandir" in both lib/csu and libexec/ld.elf_so
105	before starting your build.
106
10720010628:
108
109	A construct was added to uvm_page.h that uncovered a bug
110	in lint(1).  If you get a warning/error about a non-portable
111	bitfield, update your lint(1) before proceeding.
112
11320010226:
114
115	Added named user/group to system. Need to hand add this in or builds
116	will break as mtree aborts early.
117
118	To work around add by hand:
119
120	named:*:14:
121
122	to /etc/group and add:
123
124	named:*:14:14::0:0:Named pseudo-user:/var/named:/sbin/nologin
125
126	to master.passwd (use vipw for instance if doing by hand).
127
128	Now a make build should progress.
129
13020010219:
131	get/setprogname() added. Any hostprog's that may use this will need
132        to be bootstrapped manually until the host system is current.
133
134        Known problems: sys/arch/macppc/stand/fixcoff
135			usr.sbin/config (adding -DMAKE_BOOTSTRAP to
136			  CFLAGS and rebuilding should work)
137			usr.sbin/mdsetimage - Build a static copy if
138  		          building a snapshot before fully bootstrapped.
139
14020010204:
141	prepare the code to compile with stricter gcc flags. in
142	particular start eliminating redundant declarations. Yacc
143	needs to be installed before make build.
144
14520010114:
146	introduce .if commands(target) in make(1). You need to
147	bring everything up-to-date first, then without installing
148	anything make and install in usr.bin/make, then proceed
149	with make build.
150
15120010101:
152	bsd.subdir.mk committed 20001230 had a bug which caused
153	afterinstall targets to run too soon; update again.
154
15520001230:
156	New share/mk files needed to support .WAIT in SUBDIR variables.
157	If you get make errors, 
158		(cd share/mk; make install)
159	Also, PRINTOBJDIR has changed and is now used more heavily.
160
16120001019:
162	The `ca' device driver has been replaced by `ld'; although the
163	major and minor numbers haven't changed, you should update your /dev
164	directory.
165
16620000929:
167	The following make directives are obsoleted.
168	MKCRYPTO_RSA NOCRYPTO_RSA NOCRYPTO_RC5 NOCRYPTO_IDEA 
169	By default, RSA is built into libcrypto.  IDEA and RC5 will not be
170	built into libcrypto.  By using MKCRYPTO_{RC5,IDEA}, you can build
171	additional library libcrypto_{idea,rc5}.
172
17320000623:
174	MKCRYPTO and friends added to share/mk/bsd.own.mk.
175	'cd share/mk ; make install' needed before make build.
176
177
178Hints for a more successful build:
179^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
180    Build a new kernel first:
181	This makes sure that any new system calls or features
182	   expected by the new userland will be present.  This
183	   helps to avoid critical errors when upgrading.
184    Use object directories:
185	This helps to keep stale object
186	   files from polluting the build if a Makefile "forgets"
187	   about one.  It also makes it easier to clean up after
188	   a build.  It's also necessary if you want to use the
189	   same source tree for multiple machines.
190	   To use object directories:
191	    a) cd /usr/src ; make cleandir
192	    b) Add "OBJMACHINE=yes" to /etc/mk.conf
193	    c) Add "MKOBJDIRS=yes" to /etc/mk.conf
194	    d) cd /usr/src ; make build
195	   Note that running "make obj" in a directory will create
196	   in obj.$MACHINE directory.
197    Build to a DESTDIR:
198	This helps to keep old
199	   installed files (especially libraries) from interfering
200	   with the new build.
201	   To build to a DESTDIR, set the DESTDIR environment
202	   variable before running make build.  It should be set to
203	   the pathname of an initially empty directory.
204	   Problems: you might need to update critical utilities
205		without using DESTDIR since nothing is executed
206		from what is installed in DESTDIR.
207		(See critical utils, below)
208    Build often:
209	This keeps critical utilities current enough to not choke
210	on any other part of the source tree that depends on up to
211	date functionality.
212 
213What to do if things don't work:
214^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
215When things don't work there is usually a few things that commonly
216should be done.
217    1)	make includes
218	This should be done automatically by make build.
219    2)  cd share/mk && make install
220	Again, automatically done by make build.
221
222Failsafe rebuild of a small part of the tree:
223^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
224To make sure you rebuild something correctly you want to do
225something like the following:
226    1)  Make sure the includes and .mk files are up to date.
227    2)  Make sure any program used to build the particular
228	utility is up to date.  (yacc, lex, etc...)
229    3)  cd ...path/to/util...
230	make cleandir
231	rm ...all obj directories...
232	make cleandir			# yes, again
233	make obj
234	make depend && make
235
236Failsafe rebuild of the entire tree:
237^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
238If you really want to make sure the source tree is clean and
239ready for a build try the following.  Note that sourcing /etc/mk.conf
240(a make(1) Makefile) in this manner is not right, and will not work
241for anyone who uses any make(1) features in /etc/mk.conf.
242
243---cut here---
244#!/bin/sh
245. /etc/mk.conf
246
247if [ -z $BSDSRCDIR ] ; then
248    BSDSRCDIR=/usr/src
249fi
250if [ \! -d $BSDSRCDIR ] ; then
251    echo Unable to find sources
252    exit 1
253fi
254find $BSDSRCDIR -name \*.o -o -name obj.\* -o -name obj -exec rm \{\} \;
255
256if [ -z $BSDOBJDIR ] ; then
257    BSDOBJDIR=/usr/obj
258fi
259if [ -d $BSDOBJDIR ] ; then
260    rm -rf $BSDOBJDIR
261fi
262
263cd $BSDSRCDIR && make cleandir
264
265---cut here---
266
267Critical utilities:
268^^^^^^^^^^^^^^^^^^^
269	gnu/usr.bin/egcs
270	usr.bin/compile_et
271	usr.bin/make
272	usr.bin/yacc
273	usr.bin/lex
274	usr.bin/xlint
275	usr.sbin/config
276
277Other problems and possible solutions:
278^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
279Symptom:Unreasonable compiler errors.
280Fix:	Rebuild gnu/usr.bin/egcs
281
282Symptom:Complaints involving a Makefile.
283Fix:	Rebuild usr.bin/make:
284	cd usr.bin/make && make && make install
285        Or, a failsafe method if that doesn't work:
286	cd usr.bin/make && cc *.c */*.c -I . -o make && mv make /usr/bin
287
288Fix:	Make sure .mk files are up to date.
289	cd share/mk && make install
290
291Symptom:Kernel `config' fails to configure any kernel, including GENERIC.
292Fix:	Rebuild usr.sbin/config
293
294Symptom:
295Fix:	Rebuild usr.bin/yacc
296
297Symptom:
298Fix:	Rebuild usr.bin/lex
299
300Symptom:
301Fix:	rm /usr/lib/libbfd.a
302
303Symptom:Obsolete intermediate files are used during compilation
304Fix:	Try the following sequence of commands in the directory in question.
305	make cleandir; rm `make print-objdir`; make cleandir; make obj
306	(If you built the tree without "make obj" in the past, obsolete files
307	may remain.  The command tries to clean everything up)
308
309Symptom:.../sysinst/run.c:xx: warning: initialization from incompatible pointer type
310Fix:	Rebuild and install usr.bin/menuc
311
312Symptom:mklocale not found during build in share/locale/ctype
313Fix:	Build and install usr.bin/mklocale
314
315Symptom:undefined reference to `__assert13'
316Fix:    Rebuild and install lib/libc
317
318Symptom:usr.sbin/config fails to build.
319Fix:	Try building with -DMAKE_BOOTSTRAP added to CFLAGS in Makefile.
320
321Symptom:undefined reference to `getprogname' or `setprogname'
322Fix:    Rebuild and install lib/libc
323
324Symptom:lint does not understand the '-X' option
325Fix:    May need to build & install libs with NOLINT=1 before rebuilding lint
326