xref: /minix3/tools/gcc/README.mknative (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc$NetBSD: README.mknative,v 1.20 2014/06/14 20:49:37 mrg Exp $
2c8a0e2f4SThomas Veerman
3c8a0e2f4SThomas VeermanThis file describes how to bootstrap the native toolchain on a new NetBSD
4c8a0e2f4SThomas Veermanplatform (and how to update the new toolchain files, if needed).  These
5c8a0e2f4SThomas Veermanfiles may be generated on a cross-compile host without problems.
6c8a0e2f4SThomas Veerman
7c8a0e2f4SThomas VeermanNOTE:  DO NOT RUN "mknative" BY HAND!  It requires the Makefile in this
8c8a0e2f4SThomas Veermandirectory to set up certain environments first.
9c8a0e2f4SThomas Veerman
10c8a0e2f4SThomas VeermanSince libc's features change over time, the config.h files can change as a
11c8a0e2f4SThomas Veermanresult; thus the instructions below are the same no matter whether
12c8a0e2f4SThomas Veermanbootstrapping on a cross or native host.  This is important: even on a
13c8a0e2f4SThomas Veerman"native" host, you should bootstrap the toolchain by building from an
14c8a0e2f4SThomas Veermanup-to-date source tree to a $DESTDIR using the exact same instructions.
15c8a0e2f4SThomas Veerman
16c8a0e2f4SThomas VeermanIn these notes, MACHINE is the $MACHINE of the target.  These files can be
17c8a0e2f4SThomas Veermancross-generated.  Though a $MACHINE_ARCH all uses the same config files, you
18c8a0e2f4SThomas Veermanmust pick a specific $MACHINE so that building the requisite bits below will
19c8a0e2f4SThomas Veermanwork.
20c8a0e2f4SThomas Veerman
21*0a6a1f1dSLionel Sambuc0. Note that example paths like src/external/gpl3/gcc/lib/libgcc/arch will
22*0a6a1f1dSLionel Sambuc   really be src/external/gpl3/gcc.old/lib/libgcc/arch for the previous GCC.
23*0a6a1f1dSLionel Sambuc
24c8a0e2f4SThomas Veerman1. Set MKMAINTAINERTOOLS=yes in mk.conf.  (Needed so that src/tools/gettext
25c8a0e2f4SThomas Veerman   gets built, eliciting proper HAVE_*GETTEXT* defns in config.h files.)
26c8a0e2f4SThomas Veerman
27c8a0e2f4SThomas Veerman2. Build and install a cross toolchain (via "build.sh -m MACHINE tools").
2884d9c625SLionel Sambuc   Note that while PR #47353 is not fixed, you can not use the -O option
2984d9c625SLionel Sambuc   to build.sh. Use -M instead. (The differences are in layout and pathname
3084d9c625SLionel Sambuc   prefixes in the object directory pointed to by each option.)
31c8a0e2f4SThomas Veerman
32*0a6a1f1dSLionel Sambuc3. In src/tools/gcc, do "nbmake-MACHINE HAVE_GCC=48 bootstrap-libgcc".
33c8a0e2f4SThomas Veerman
34d19d7d58SLionel Sambuc   This will create just enough glue in src/external/gpl3/gcc/lib/libgcc/arch
35d19d7d58SLionel Sambuc   to make it possible to build, based on the toolchain built in
36d19d7d58SLionel Sambuc   ${.OBJDIR}/build.
37c8a0e2f4SThomas Veerman   Because the files generated in this step contain things like
38c8a0e2f4SThomas Veerman   -DCROSS_COMPILE, they are not suitable for committing.  Step 8 below
39c8a0e2f4SThomas Veerman   will regenerate the "proper" libgcc config files.
40c8a0e2f4SThomas Veerman
41c8a0e2f4SThomas Veerman4. At top level, do
42*0a6a1f1dSLionel Sambuc   "nbmake-MACHINE obj do-distrib-dirs MKGCC=no MKBINUTILS=no HAVE_GCC=48", and
43*0a6a1f1dSLionel Sambuc   "nbmake-MACHINE includes HAVE_GCC= MKGCC=no MKBINUTILS=no HAVE_GCC=48".
44*0a6a1f1dSLionel Sambuc   (Note: replace 48 [for gcc 4.8.x] with the appropriate version you are
4584d9c625SLionel Sambuc   going to mknative-for, the MKGCC=no prevents the standard makefiles from
4684d9c625SLionel Sambuc   picking up any gcc version info automatically)
47c8a0e2f4SThomas Veerman
48d19d7d58SLionel Sambuc5. In src/lib/csu, do
49d19d7d58SLionel Sambuc   "nbmake-MACHINE dependall". and "nbmake-MACHINE install".
50c8a0e2f4SThomas Veerman
51*0a6a1f1dSLionel Sambuc6. In src/external/gpl3/gcc/lib/libgcc, do
52d19d7d58SLionel Sambuc   "nbmake-MACHINE obj includes dependall install".
53d19d7d58SLionel Sambuc
54*0a6a1f1dSLionel Sambuc7. In each of src/external/lgpl3/gmp/lib/libgmp,
5584d9c625SLionel Sambuc   src/external/lgpl3/mpfr/lib/libmpfr, src/external/lgpl3/mpc/lib/libmpc
5684d9c625SLionel Sambuc   do "nbmake-MACHINE obj dependall".
57d19d7d58SLionel Sambuc
58*0a6a1f1dSLionel Sambuc8. In src/lib, do
59*0a6a1f1dSLionel Sambuc   "nbmake-MACHINE dependall install MKGCC=no HAVE_GCC=48".
60c8a0e2f4SThomas Veerman
61c8a0e2f4SThomas Veerman   Optionally, all of the following may be set in the environment to reduce
62c8a0e2f4SThomas Veerman   the amount of code needed to build at this step.  Basically, it must be
63c8a0e2f4SThomas Veerman   possible for static binaries to build and base system libs to exist so
64c8a0e2f4SThomas Veerman   that "configure" can do its job for the target--these MK* options omit
65c8a0e2f4SThomas Veerman   the rest for this stage of the build.
66c8a0e2f4SThomas Veerman
67c8a0e2f4SThomas Veerman   MKCRYPTO=no
68c8a0e2f4SThomas Veerman   MKLINT=no
69c8a0e2f4SThomas Veerman   MKPROFILE=no
70c8a0e2f4SThomas Veerman   MKSHARE=no
7184d9c625SLionel Sambuc   MKRUMP=no
72c8a0e2f4SThomas Veerman
73*0a6a1f1dSLionel Sambuc9. In src/tools/gcc, do "nbmake-MACHINE native-gcc".
74c8a0e2f4SThomas Veerman
75c8a0e2f4SThomas Veerman   This will do a full configury in ${.OBJDIR}/.native that is a "Canadian"
76c8a0e2f4SThomas Veerman   cross toolchain (--build reflects the host platform, but --host and
77c8a0e2f4SThomas Veerman   --target are the target).  The result is a tree that would build a
78c8a0e2f4SThomas Veerman   native-to-NetBSD compiler on a cross host, and mknative pulls glue data
79c8a0e2f4SThomas Veerman   from this.
80c8a0e2f4SThomas Veerman
81*0a6a1f1dSLionel Sambuc10. Try out a full build using "nbmake-MACHINE"; the result should include
82c8a0e2f4SThomas Veerman   a native compiler.
83c8a0e2f4SThomas Veerman
84*0a6a1f1dSLionel Sambuc11. If all is well, commit the glue files added to src/gnu/{lib,usr.bin}/*.
85