xref: /netbsd-src/tools/gcc/README.mknative (revision 6de51c519f1b899da63c1bf576f478920b89083f)
1$NetBSD: README.mknative,v 1.14 2012/12/26 19:11:27 martin Exp $
2
3This file describes how to bootstrap the native toolchain on a new NetBSD
4platform (and how to update the new toolchain files, if needed).  These
5files may be generated on a cross-compile host without problems.
6
7NOTE:  DO NOT RUN "mknative" BY HAND!  It requires the Makefile in this
8directory to set up certain environments first.
9
10Since libc's features change over time, the config.h files can change as a
11result; thus the instructions below are the same no matter whether
12bootstrapping on a cross or native host.  This is important: even on a
13"native" host, you should bootstrap the toolchain by building from an
14up-to-date source tree to a $DESTDIR using the exact same instructions.
15
16In these notes, MACHINE is the $MACHINE of the target.  These files can be
17cross-generated.  Though a $MACHINE_ARCH all uses the same config files, you
18must pick a specific $MACHINE so that building the requisite bits below will
19work.
20
211. 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
242. Build and install a cross toolchain (via "build.sh -m MACHINE tools").
25   Note that while PR #47353 is not fixed, you can not use the -O option
26   to build.sh. Use -M instead. (The difference is only a minor layout/
27   pathname prefixe in the object directory pointed to bei either option.)
28
293. In src/tools/gcc, do "nbmake-MACHINE bootstrap-libgcc".
30
31   This will create just enough glue in src/external/gpl3/gcc/lib/libgcc/arch
32   to make it possible to build, based on the toolchain built in
33   ${.OBJDIR}/build.
34   Because the files generated in this step contain things like
35   -DCROSS_COMPILE, they are not suitable for committing.  Step 8 below
36   will regenerate the "proper" libgcc config files.
37
384. At top level, do
39   "nbmake-MACHINE obj do-distrib-dirs MKGCC=no MKBINUTILS=no HAVE_GCC=45", and
40   "nbmake-MACHINE includes HAVE_GCC= MKGCC=no MKBINUTILS=no HAVE_GCC=45".
41   (Note: replace 45 [for gcc 4.5.x] with the appropriate version you are
42   going to mknative-for, the MKGCC=no prevents the standard makefiles from
43   picking up any gcc version info automatically)
44
455. In src/lib/csu, do
46   "nbmake-MACHINE dependall". and "nbmake-MACHINE install".
47
486. If the platform sets USE_COMPILERCRTSTUFF=yes, then in
49   src/external/gpl3/gcc/lib/crtstuff/ do
50   "nbmake-MACHINE obj dependall install"
51
527. In src/external/gpl3/gcc/lib/libgcc, do
53   "nbmake-MACHINE obj includes dependall install".
54
558. In each of src/external/lgpl3/gmp/lib/libgmp,
56   src/external/lgpl3/mpfr/lib/libmpfr, src/external/lgpl2/mpc/lib/libmpc
57   do "nbmake-MACHINE obj includes LIBISPRIVATE=no", and
58   "nbmake-MACHINE dependall install".
59
60   It is important to have LIBISPRIVATE=no while doing includes as this
61   installs a header file that is not part of standard build.
62
639. In src/lib, do
64   "nbmake-MACHINE dependall install MKGCC=no HAVE_GCC=45".
65
66   Optionally, all of the following may be set in the environment to reduce
67   the amount of code needed to build at this step.  Basically, it must be
68   possible for static binaries to build and base system libs to exist so
69   that "configure" can do its job for the target--these MK* options omit
70   the rest for this stage of the build.
71
72   MKCRYPTO=no
73   MKLINT=no
74   MKPROFILE=no
75   MKSHARE=no
76   MKRUMP=no
77
7810. In src/tools/gcc, do "nbmake-MACHINE native-gcc".
79
80   This will do a full configury in ${.OBJDIR}/.native that is a "Canadian"
81   cross toolchain (--build reflects the host platform, but --host and
82   --target are the target).  The result is a tree that would build a
83   native-to-NetBSD compiler on a cross host, and mknative pulls glue data
84   from this.
85
8611. Try out a full build using "nbmake-MACHINE"; the result should include
87   a native compiler.
88
8912. If all is well, commit the glue files added to src/gnu/{lib,usr.bin}/*.
90