README.mknative revision 1.10
11.10Sskrll$NetBSD: README.mknative,v 1.10 2012/09/16 15:09:55 skrll Exp $
21.1Smrg
31.2SskrllThis file describes how to bootstrap the native toolchain on a new NetBSD
41.2Sskrllplatform (and how to update the new toolchain files, if needed).  These
51.2Sskrllfiles may be generated on a cross-compile host without problems.
61.1Smrg
71.2SskrllNOTE:  DO NOT RUN "mknative" BY HAND!  It requires the Makefile in this
81.2Sskrlldirectory to set up certain environments first.
91.2Sskrll
101.2SskrllSince libc's features change over time, the config.h files can change as a
111.2Sskrllresult; thus the instructions below are the same no matter whether
121.2Sskrllbootstrapping on a cross or native host.  This is important: even on a
131.2Sskrll"native" host, you should bootstrap the toolchain by building from an
141.2Sskrllup-to-date source tree to a $DESTDIR using the exact same instructions.
151.2Sskrll
161.2SskrllIn these notes, MACHINE is the $MACHINE of the target.  These files can be
171.2Sskrllcross-generated.  Though a $MACHINE_ARCH all uses the same config files, you
181.2Sskrllmust pick a specific $MACHINE so that building the requisite bits below will
191.2Sskrllwork.
201.2Sskrll
211.2Sskrll1. Set MKMAINTAINERTOOLS=yes in mk.conf.  (Needed so that src/tools/gettext
221.2Sskrll   gets built, eliciting proper HAVE_*GETTEXT* defns in config.h files.)
231.2Sskrll
241.2Sskrll2. Build and install a cross toolchain (via "build.sh -m MACHINE tools").
251.2Sskrll
261.2Sskrll3. In src/tools/gcc, do "nbmake-MACHINE bootstrap-libgcc".
271.2Sskrll
281.10Sskrll   This will create just enough glue in src/external/gpl3/gcc/lib/libgcc/arch
291.10Sskrll   to make it possible to build, based on the toolchain built in
301.10Sskrll   ${.OBJDIR}/build.
311.2Sskrll   Because the files generated in this step contain things like
321.4Smartin   -DCROSS_COMPILE, they are not suitable for committing.  Step 8 below
331.2Sskrll   will regenerate the "proper" libgcc config files.
341.2Sskrll
351.2Sskrll4. At top level, do
361.7Sskrll   "nbmake-MACHINE do-distrib-dirs obj includes MKGCC=no MKBINUTILS=no".
371.2Sskrll
381.10Sskrll5. In src/external/gpl3/gcc/lib/libgcc, do "nbmake-MACHINE obj includes".
391.10Sskrll
401.10Sskrll6. If the platform sets USE_COMPILERCRTSTUFF=yes, then in
411.10Sskrll   src/external/gpl3/gcc/lib/crtstuff/ do "nbmake-MACHINE dependall install"
421.2Sskrll
431.10Sskrll7. In each of src/lib/csu, src/external/gpl3/gcc/lib/libgcc,
441.10Sskrll   src/external/lgpl3/gmp/lib/libgmp,  src/external/lgpl3/mpfr/lib/libmpfr,
451.10Sskrll   src/external/lgpl2/mpc/lib/libmpc and src/lib,
461.10Sskrll   do "nbmake-MACHINE includes dependall install".
471.4Smartin
481.10Sskrll   It is important to have LIBISPRIVATE=no while doing src/external/lgpl[23]/*
491.2Sskrll
501.2Sskrll   Optionally, all of the following may be set in the environment to reduce
511.2Sskrll   the amount of code needed to build at this step.  Basically, it must be
521.2Sskrll   possible for static binaries to build and base system libs to exist so
531.2Sskrll   that "configure" can do its job for the target--these MK* options omit
541.2Sskrll   the rest for this stage of the build.
551.2Sskrll
561.2Sskrll   MKCRYPTO=no
571.2Sskrll   MKLINT=no
581.2Sskrll   MKPROFILE=no
591.2Sskrll   MKSHARE=no
601.2Sskrll
611.4Smartin8. In src/tools/gcc, do "nbmake-MACHINE native-gcc".
621.2Sskrll
631.2Sskrll   This will do a full configury in ${.OBJDIR}/.native that is a "Canadian"
641.2Sskrll   cross toolchain (--build reflects the host platform, but --host and
651.2Sskrll   --target are the target).  The result is a tree that would build a
661.2Sskrll   native-to-NetBSD compiler on a cross host, and mknative pulls glue data
671.2Sskrll   from this.
681.2Sskrll
691.4Smartin9. Try out a full build using "nbmake-MACHINE"; the result should include
701.2Sskrll   a native compiler.
711.2Sskrll
721.4Smartin10. If all is well, commit the glue files added to src/gnu/{lib,usr.bin}/*.
73