$NetBSD: UPDATING,v 2009/05/30 16:30:24 snj Exp $

This file (UPDATING) is intended to be a brief reference to recent
changes that might cause problems in the build process, and a guide for
what to do if something doesn't work.

For a more detailed description of the recommended way to build NetBSD
using, see the BUILDING file.

Note that much of the advice in this UPDATING file was written before existed.  Nevertheless, the advice here may be useful for
working around specific problems with

See also: BUILDING,, Makefile.

Recent changes:

	pkg_install now depends on the pkgdb cache for automatic conflict
	detection.  It is recommented to rebuild the cache with
	``pkg_admin rebuild''.

	audit-packages.conf(5) has been superseded by pkg_install.conf(5).
	The default configuration is the same.  Support for pkg_view(1) has
	been retired.  The functionality of audit-packages(1) and
	download-vulnerability-list(1) has moved into pkg_admin(1), wrapper
	scripts that handle the common use cases are provided.

	If you build with MKX11=no, you should remove /etc/rc.d/xdm and
	/etc/rc.d/xfs from DESTDIR because those files were moved to the xetc
	set and will appear as extra files for MKX11=no update builds.

	If you built and installed a libc from sources between
	2008/08/20 and 2008/08/26 you got a broken strtouq(3)
	which results in false errors reported by lint(1).
	Since this breaks the libc build itself, manual help is
	needed -- lint must be disabled temporarily, e.g:
	  $ (cd lib/libc && make MKLINT=no dependall install)

	MKDEBUG build was broken because the .depend files did not know
	about .go files. You need to remove all .depend files and rebuild.

	WAPBL (metadata journaling support) has been added, but at this
	time isn't backwards compatible with pre-WAPBL aware kernels
	and userland (fsck_ffs in particular).  Please make sure you
	don't use a journaled filesystem with an older kernel/userland,
	especially an uncleanly mounted journaled filesystem.  WAPBL
	also requires the super block to be in the UFS2 format.  You
	can use fsck_ffs -c 4 to update the superblock format.

	Assembler warnings are now fatal if $WARNS>0 and $NOGCCERROR
	isn't defined.

	The ioctl number of DRVSUSPENDDEV command on /dev/drvctl changed 
	from 125 (conflicted with DRVCTLCOMMAND) to 129. The drvctl(8)
	utility needs to be rebuilt and reinstalled as older binaries
	won't work correctly. The following sequence of commands:

	  $ (cd sys/sys/ && nbmake-$arch includes)
	  $ (cd sbin/drvctl/ && nbmake-$arch clean)
	  $ (cd sbin/drvctl/ && nbmake-$arch all)

	leaves new drvctl utility in sbin/drvctl build directory.

	The <> variable MKPRIVATELIB was renamed to LIBISPRIVATE.

	For a while, unprivileged UPDATE builds would fail to
	succeed at the checkflist stage, complaining that
	${DESTDIR}/stand/<arch>/ did not exist.  A fix for this
	problem was committed to share/mk/, revision 1.9.
	If you already hit this problem, update the .mk file,
	remove ${DESTDIR}/stand/<arch>, and re-run the build.

	Linker warnings are now fatal if $WARNS>0.

	The posix_fadvise system call has been changed from an assembly
	stub, to a c file that calls an assembly stub. You need to
	'rm -f posix_fadvise.* .depend' in the libc build directory to
	avoid using the old assembly stub.

	The acpiec(4) driver has been split into two attachments. If you
	get ACPI errors before the attachment, please update your kernel
	configuration file appropriately or see GENERIC for more details.

	The it(4) driver has been renamed to itesio(4) and the old port
	argument specified in the kernel configuration file is not valid
	anymore. The itesio(4) driver now uses the Super I/O address port
	rather than the EC address port. Please update your kernel
	configuration file appropriately or see GENERIC for more details.

	The pccons(4) driver has been removed from the NetBSD/shark port.
	You need to update any custom kernel configuration file you have
	to remove any references to pccons (which includes removing the
	now useless XSERVER option) and replace them with the correct
	entries for the wscons driver.  See the GENERIC configuration file
	for more details.

	A latent bug in dhclient/dhcpd that caused it to be unable to
	enumerate interfaces was fixed.  The bug began to cause
	problems after 20070911 when the kernel's SIOCGIFCONF
	implementation was repaired.  From 20070529 to 20070911 racoon
	could not enumerate interfaces.  (These are noted because
	normal kernel/userspace version matching hygiene is not
	sufficient to avoid this problem.)  Ensure that both kernel
	and userland are from after 20070913.

	nbinstall has been renamed as it calls the target specific and
	the logic to pass down STRIP from mk been removed.  This forces
	a re-installation of tools.

	The way OS emulations lookup filenames inside the emulation root
	has been changed.  Rather than modify the pathname (and copy back
	to userspace) namei() and lookup() directly check the emulation
	root. One side effect is that absolute symlinks inside the emulated
	root file system will be relative to that file system - unless they
	start /../ this is useful when the emulated root is a real install
	that has such links.
	This might affect symlinks that have been added to reference outside
	the emulated root.

	The pckbc driver on sgimips IP32 has been removed. Use macekbc
	instead. See the GENERIC32_IP3x kernel configuration for an

        src/lib/libc/Makefile revision 1.129 broke libc and ld.elf_so
        on many platforms due to incorrect flags settings.  If you
        updated and built after about 20070315, do "nbmake-$arch
	cleandir" in src/lib/libc and src/libexec/ld.elf_so to force a
	rebuild of object files that might have been built
	incorrectly, and ensure that you have at least
	src/lib/libc/Makefile 1.130.

        src/sys/sys/{sa.h,savar.h} were removed.
          find ${OBJDIR} \( -name .depend -o -name '*.d' \) -print \
              | xargs egrep -l '/sa.h|/savar.h' | xargs rm
        will allow dependencies on those files to get get rebuilt

        The threading model was changed when the newlock2 branch
        was merged to NetBSD-current.  If you boot with a new
        kernel (version 4.99.10), then you also need a new pthread
        library (/usr/lib/  If you boot with
        an old kernel, then you need the old pthread library
        (/usr/lib/  Provided you keep the kernel and
        the pthread library in sync, old threaded applications should
        continue to work with an old or new kernel.  Note that named(8)
	is the only threaded application in the base system.

	Following the move of string_to_flags() and flags_to_string()
	from the bin/ls/ sources to libutil, users doing UPDATE builds
	will need to do a "make cleandir" in
		tools/mtree/, tools/makefs/, tools/binstall/, tools/pax/,
		bin/pax/, bin/ls/, usr.sbin/mtree/, usr.sbin/makefs/,
		usr.bin/xinstall/, libexec/ftpd/, rescue/, as well
		as the installation images in distrib/
	in order to excise stale references to the old stat_flags.h header
	file in the ls sources -- stat_flags.h has been removed.

	The configure script used in the src/tools/gcc compiler has been
	changed to indicate that our libc has ssp support built-in and
	does not depend on -lssp and -lssp-nonshared. You'll need to
	make clean in src/tools/gcc first to rebuild the compiler.

	The sysctl variables net.inet{,6}.tcp{,6}.newreno are no longer
	available. Use net.inet{,6}.tcp{,6}.congctl.selected instead.

	The vt, vidcconsole, kbd, and rpckbd drivers on acorn32 have been
	withdrawn.  Use vidcvideo and pckbd instead.  See the GENERIC
	kernel configuration for an example.  X servers from the last
	few years should cope.

	MPACPI is no more. We always configure PCI interrupts using ACPI
	if we have an ACPI kernel. The option MPACPI_SCANPCI has been renamed
	to ACPI_SCANPCI. Thanks to work from fvdl.

	socket(2) has changed, and its system call has been versioned.
	For userlands with the old version of socket(2), make sure that
	your kernel has 'options COMPAT_30' set, or else 'bad system call'
	errors will result.

Hints for a more successful build:
    Use, but do not use its "expert mode":
	This will automatically build the tools in the
	   correct order, and it will keep the tools and the
	   new build products from interfering with the running
	   system.  This will allow you to ignore most of the
	   other advice in this file.
    Build a new kernel first:
	This makes sure that any new system calls or features
	   expected by the new userland will be present.  This
	   helps to avoid critical errors when upgrading.
    Use object directories:
	This helps to keep stale object
	   files from polluting the build if a Makefile "forgets"
	   about one.  It also makes it easier to clean up after
	   a build.  It's also necessary if you want to use the
	   same source tree for multiple machines.
	   To use object directories with
	    a) invoke with the "-M" or "-O" options.
	   To use object directories without using
	    a) cd /usr/src ; make cleandir
	    b) Add "OBJMACHINE=yes" to /etc/mk.conf
	    c) Add "MKOBJDIRS=yes" to /etc/mk.conf
	    d) cd /usr/src ; make build
	   Note that running "make obj" in a directory will create
	   in obj.$MACHINE directory.
    Build to a DESTDIR:
	This helps to keep old installed files (especially libraries)
	   from interfering with the new build.
	   To build to a DESTDIR with, use the "-D" option.
	   To build to a DESTDIR without using, set the DESTDIR
	   environment variable before running make build.  It should be
	   set to the pathname of an initially empty directory.
	   Problems: if you do not use, you might need to
		update critical utilities without using DESTDIR since
		nothing is executed from what is installed in DESTDIR.
		(See critical utils, below.)
    Build often:
	This keeps critical utilities current enough to not choke
	on any other part of the source tree that depends on up to
	date functionality.  If you use, you should not have
	this problem.
What to do if things don't work:
When things don't work there is usually a few things that commonly
should be done.
    1)	make includes
	This should be done automatically by make build.
    2)  cd share/mk && make install
	Again, automatically done by make build.

Failsafe rebuild of a small part of the tree:
To make sure you rebuild something correctly you want to do
something like the following:
    1)  Make sure the includes and .mk files are up to date.
    2)  Make sure any program used to build the particular
	utility is up to date.  (yacc, lex, etc...)
    3)  cd ...path/to/util...
	make cleandir
	rm ...all obj directories...
	make cleandir			# yes, again
	make obj
	make depend && make

Failsafe rebuild of the entire tree:
If you really want to make sure the source tree is clean and
ready for a build try the following.  Note that sourcing /etc/mk.conf
(a make(1) Makefile) in this manner is not right, and will not work
for anyone who uses any make(1) features in /etc/mk.conf.

---cut here---
. /etc/mk.conf

if [ -z $NETBSDSRCDIR ] ; then
if [ \! -d $NETBSDSRCDIR ] ; then
    echo Unable to find sources
    exit 1
find $NETBSDSRCDIR -name \*.o -o -name obj.\* -o -name obj -exec rm \{\} \;

if [ -z $BSDOBJDIR ] ; then
if [ -d $BSDOBJDIR ] ; then
    rm -rf $BSDOBJDIR

cd $NETBSDSRCDIR && make cleandir

---cut here---

Critical utilities:

Other problems and possible solutions:
Symptom:Complaints involving a Makefile.
Fix:	Rebuild usr.bin/make:
	cd usr.bin/make && make && make install
	Or, a failsafe method if that doesn't work:
	cd usr.bin/make && cc *.c */*.c -I . -o make && mv make /usr/bin

Fix:	Make sure .mk files are up to date.
	cd share/mk && make install

Symptom:Kernel `config' fails to configure any kernel, including GENERIC.
Fix:	Rebuild usr.bin/config

Fix:	Rebuild usr.bin/yacc

Fix:	Rebuild usr.bin/lex

Fix:	rm /usr/lib/libbfd.a

Symptom:Obsolete intermediate files are used during compilation
Fix:	Try the following sequence of commands in the directory in question.
	make cleandir; rm `make print-objdir`; make cleandir; make obj
	(If you built the tree without "make obj" in the past, obsolete files
	may remain.  The command tries to clean everything up)

Symptom:.../sysinst/run.c:xx: warning: initialization from incompatible pointer type
Fix:	Rebuild and install usr.bin/menuc

Symptom:mklocale not found during build in share/locale/ctype
Fix:	Build and install usr.bin/mklocale

Symptom:undefined reference to `__assert13' or `__unsetenv13'
Fix:    Rebuild and install lib/libc

Symptom:usr.bin/config fails to build.
Fix:	Try building with -DMAKE_BOOTSTRAP added to CFLAGS in Makefile.

Symptom:undefined reference to `getprogname' or `setprogname'
Fix:    Rebuild and install lib/libc

Symptom:lint does not understand the '-X' option
Fix:    May need to build & install libs with NOLINT=1 before rebuilding lint