README.mknative revision 1.14
11.14Smartin$NetBSD: README.mknative,v 1.14 2012/12/26 19:11:27 martin 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.14Smartin   Note that while PR #47353 is not fixed, you can not use the -O option
261.14Smartin   to build.sh. Use -M instead. (The difference is only a minor layout/
271.14Smartin   pathname prefixe in the object directory pointed to bei either option.)
281.2Sskrll
291.2Sskrll3. In src/tools/gcc, do "nbmake-MACHINE bootstrap-libgcc".
301.2Sskrll
311.10Sskrll   This will create just enough glue in src/external/gpl3/gcc/lib/libgcc/arch
321.10Sskrll   to make it possible to build, based on the toolchain built in
331.10Sskrll   ${.OBJDIR}/build.
341.2Sskrll   Because the files generated in this step contain things like
351.4Smartin   -DCROSS_COMPILE, they are not suitable for committing.  Step 8 below
361.2Sskrll   will regenerate the "proper" libgcc config files.
371.2Sskrll
381.2Sskrll4. At top level, do
391.14Smartin   "nbmake-MACHINE obj do-distrib-dirs MKGCC=no MKBINUTILS=no HAVE_GCC=45", and
401.14Smartin   "nbmake-MACHINE includes HAVE_GCC= MKGCC=no MKBINUTILS=no HAVE_GCC=45".
411.14Smartin   (Note: replace 45 [for gcc 4.5.x] with the appropriate version you are
421.14Smartin   going to mknative-for, the MKGCC=no prevents the standard makefiles from
431.14Smartin   picking up any gcc version info automatically)
441.2Sskrll
451.13Sskrll5. In src/lib/csu, do
461.13Sskrll   "nbmake-MACHINE dependall". and "nbmake-MACHINE install".
471.10Sskrll
481.10Sskrll6. If the platform sets USE_COMPILERCRTSTUFF=yes, then in
491.11Sskrll   src/external/gpl3/gcc/lib/crtstuff/ do
501.11Sskrll   "nbmake-MACHINE obj dependall install"
511.2Sskrll
521.13Sskrll7. In src/external/gpl3/gcc/lib/libgcc, do
531.11Sskrll   "nbmake-MACHINE obj includes dependall install".
541.4Smartin
551.11Sskrll8. In each of src/external/lgpl3/gmp/lib/libgmp,
561.11Sskrll   src/external/lgpl3/mpfr/lib/libmpfr, src/external/lgpl2/mpc/lib/libmpc
571.11Sskrll   do "nbmake-MACHINE obj includes LIBISPRIVATE=no", and
581.12Sskrll   "nbmake-MACHINE dependall install".
591.11Sskrll
601.11Sskrll   It is important to have LIBISPRIVATE=no while doing includes as this
611.11Sskrll   installs a header file that is not part of standard build.
621.11Sskrll
631.11Sskrll9. In src/lib, do
641.14Smartin   "nbmake-MACHINE dependall install MKGCC=no HAVE_GCC=45".
651.2Sskrll
661.2Sskrll   Optionally, all of the following may be set in the environment to reduce
671.2Sskrll   the amount of code needed to build at this step.  Basically, it must be
681.2Sskrll   possible for static binaries to build and base system libs to exist so
691.2Sskrll   that "configure" can do its job for the target--these MK* options omit
701.11Sskrll   the rest for this stage of the build. 
711.2Sskrll
721.2Sskrll   MKCRYPTO=no
731.2Sskrll   MKLINT=no
741.2Sskrll   MKPROFILE=no
751.2Sskrll   MKSHARE=no
761.14Smartin   MKRUMP=no
771.2Sskrll
781.11Sskrll10. In src/tools/gcc, do "nbmake-MACHINE native-gcc".
791.2Sskrll
801.2Sskrll   This will do a full configury in ${.OBJDIR}/.native that is a "Canadian"
811.2Sskrll   cross toolchain (--build reflects the host platform, but --host and
821.2Sskrll   --target are the target).  The result is a tree that would build a
831.2Sskrll   native-to-NetBSD compiler on a cross host, and mknative pulls glue data
841.2Sskrll   from this.
851.2Sskrll
861.11Sskrll11. Try out a full build using "nbmake-MACHINE"; the result should include
871.2Sskrll   a native compiler.
881.2Sskrll
891.11Sskrll12. If all is well, commit the glue files added to src/gnu/{lib,usr.bin}/*.
90