Home | History | Annotate | Line # | Download | only in gcc
README.mknative revision 1.10
      1 $NetBSD: README.mknative,v 1.10 2012/09/16 15:09:55 skrll Exp $
      2 
      3 This file describes how to bootstrap the native toolchain on a new NetBSD
      4 platform (and how to update the new toolchain files, if needed).  These
      5 files may be generated on a cross-compile host without problems.
      6 
      7 NOTE:  DO NOT RUN "mknative" BY HAND!  It requires the Makefile in this
      8 directory to set up certain environments first.
      9 
     10 Since libc's features change over time, the config.h files can change as a
     11 result; thus the instructions below are the same no matter whether
     12 bootstrapping on a cross or native host.  This is important: even on a
     13 "native" host, you should bootstrap the toolchain by building from an
     14 up-to-date source tree to a $DESTDIR using the exact same instructions.
     15 
     16 In these notes, MACHINE is the $MACHINE of the target.  These files can be
     17 cross-generated.  Though a $MACHINE_ARCH all uses the same config files, you
     18 must pick a specific $MACHINE so that building the requisite bits below will
     19 work.
     20 
     21 1. Set MKMAINTAINERTOOLS=yes in mk.conf.  (Needed so that src/tools/gettext
     22    gets built, eliciting proper HAVE_*GETTEXT* defns in config.h files.)
     23 
     24 2. Build and install a cross toolchain (via "build.sh -m MACHINE tools").
     25 
     26 3. In src/tools/gcc, do "nbmake-MACHINE bootstrap-libgcc".
     27 
     28    This will create just enough glue in src/external/gpl3/gcc/lib/libgcc/arch
     29    to make it possible to build, based on the toolchain built in
     30    ${.OBJDIR}/build.
     31    Because the files generated in this step contain things like
     32    -DCROSS_COMPILE, they are not suitable for committing.  Step 8 below
     33    will regenerate the "proper" libgcc config files.
     34 
     35 4. At top level, do
     36    "nbmake-MACHINE do-distrib-dirs obj includes MKGCC=no MKBINUTILS=no".
     37 
     38 5. In src/external/gpl3/gcc/lib/libgcc, do "nbmake-MACHINE obj includes".
     39 
     40 6. If the platform sets USE_COMPILERCRTSTUFF=yes, then in
     41    src/external/gpl3/gcc/lib/crtstuff/ do "nbmake-MACHINE dependall install"
     42 
     43 7. In each of src/lib/csu, src/external/gpl3/gcc/lib/libgcc,
     44    src/external/lgpl3/gmp/lib/libgmp,  src/external/lgpl3/mpfr/lib/libmpfr,
     45    src/external/lgpl2/mpc/lib/libmpc and src/lib,
     46    do "nbmake-MACHINE includes dependall install".
     47 
     48    It is important to have LIBISPRIVATE=no while doing src/external/lgpl[23]/*
     49 
     50    Optionally, all of the following may be set in the environment to reduce
     51    the amount of code needed to build at this step.  Basically, it must be
     52    possible for static binaries to build and base system libs to exist so
     53    that "configure" can do its job for the target--these MK* options omit
     54    the rest for this stage of the build.
     55 
     56    MKCRYPTO=no
     57    MKLINT=no
     58    MKPROFILE=no
     59    MKSHARE=no
     60 
     61 8. In src/tools/gcc, do "nbmake-MACHINE native-gcc".
     62 
     63    This will do a full configury in ${.OBJDIR}/.native that is a "Canadian"
     64    cross toolchain (--build reflects the host platform, but --host and
     65    --target are the target).  The result is a tree that would build a
     66    native-to-NetBSD compiler on a cross host, and mknative pulls glue data
     67    from this.
     68 
     69 9. Try out a full build using "nbmake-MACHINE"; the result should include
     70    a native compiler.
     71 
     72 10. If all is well, commit the glue files added to src/gnu/{lib,usr.bin}/*.
     73