xref: /netbsd/tools/gcc/README.mknative (revision 4f4d2ab4)
1*4f4d2ab4Smrg$NetBSD: README.mknative,v 1.23 2019/09/30 08:40:20 mrg Exp $
26c4963a6Smrg
3d5174d72SskrllThis file describes how to bootstrap the native toolchain on a new NetBSD
4d5174d72Sskrllplatform (and how to update the new toolchain files, if needed).  These
5d5174d72Sskrllfiles may be generated on a cross-compile host without problems.
66c4963a6Smrg
7d5174d72SskrllNOTE:  DO NOT RUN "mknative" BY HAND!  It requires the Makefile in this
8d5174d72Sskrlldirectory to set up certain environments first.
9d5174d72Sskrll
10d5174d72SskrllSince libc's features change over time, the config.h files can change as a
11d5174d72Sskrllresult; thus the instructions below are the same no matter whether
12d5174d72Sskrllbootstrapping on a cross or native host.  This is important: even on a
13d5174d72Sskrll"native" host, you should bootstrap the toolchain by building from an
14d5174d72Sskrllup-to-date source tree to a $DESTDIR using the exact same instructions.
15d5174d72Sskrll
16d5174d72SskrllIn these notes, MACHINE is the $MACHINE of the target.  These files can be
17d5174d72Sskrllcross-generated.  Though a $MACHINE_ARCH all uses the same config files, you
18d5174d72Sskrllmust pick a specific $MACHINE so that building the requisite bits below will
19d5174d72Sskrllwork.
20d5174d72Sskrll
219be7c7ebSmrg0. Note that example paths like src/external/gpl3/gcc/lib/libgcc/arch will
229be7c7ebSmrg   really be src/external/gpl3/gcc.old/lib/libgcc/arch for the previous GCC.
239be7c7ebSmrg
24d5174d72Sskrll1. Set MKMAINTAINERTOOLS=yes in mk.conf.  (Needed so that src/tools/gettext
25d5174d72Sskrll   gets built, eliciting proper HAVE_*GETTEXT* defns in config.h files.)
26d5174d72Sskrll
27d5174d72Sskrll2. Build and install a cross toolchain (via "build.sh -m MACHINE tools").
28a191c797Smartin   Note that while PR #47353 is not fixed, you can not use the -O option
299e28fb60Sskrll   to build.sh. Use -M instead. (The differences are in layout and pathname
309e28fb60Sskrll   prefixes in the object directory pointed to by each option.)
31d5174d72Sskrll
32*4f4d2ab4Smrg3. In src/tools/gcc, do "nbmake-MACHINE HAVE_GCC=8 bootstrap-libgcc".
33d5174d72Sskrll
349d22372fSskrll   This will create just enough glue in src/external/gpl3/gcc/lib/libgcc/arch
359d22372fSskrll   to make it possible to build, based on the toolchain built in
369d22372fSskrll   ${.OBJDIR}/build.
37d5174d72Sskrll   Because the files generated in this step contain things like
38417e9345Smartin   -DCROSS_COMPILE, they are not suitable for committing.  Step 8 below
39d5174d72Sskrll   will regenerate the "proper" libgcc config files.
40d5174d72Sskrll
41d5174d72Sskrll4. At top level, do
42*4f4d2ab4Smrg   "nbmake-MACHINE obj do-distrib-dirs MKGCC=no MKBINUTILS=no HAVE_GCC=8", and
43*4f4d2ab4Smrg   "nbmake-MACHINE includes HAVE_GCC= MKGCC=no MKBINUTILS=no HAVE_GCC=8".
44*4f4d2ab4Smrg   (Note: replace 8 [for GCC 8.x] with the appropriate version you are going
45c4d67dd6Smrg   to mknative-for, the MKGCC=no prevents the standard makefiles from picking
46c4d67dd6Smrg   up any gcc version info automatically)
47d5174d72Sskrll
483ea11251Sskrll5. In src/lib/csu, do
493ea11251Sskrll   "nbmake-MACHINE dependall". and "nbmake-MACHINE install".
50d5174d72Sskrll
513d71da30Sjoerg6. In src/external/gpl3/gcc/lib/libgcc, do
5250449f01Sskrll   "nbmake-MACHINE obj includes dependall install".
539d22372fSskrll
543d71da30Sjoerg7. In each of src/external/lgpl3/gmp/lib/libgmp,
55f77bde7dSmrg   src/external/lgpl3/mpfr/lib/libmpfr, src/external/lgpl3/mpc/lib/libmpc
568293a92aSskrll   do "nbmake-MACHINE obj dependall".
5750449f01Sskrll
583d71da30Sjoerg8. In src/lib, do
59*4f4d2ab4Smrg   "nbmake-MACHINE dependall install MKGCC=no HAVE_GCC=8".
60d5174d72Sskrll
61d5174d72Sskrll   Optionally, all of the following may be set in the environment to reduce
62d5174d72Sskrll   the amount of code needed to build at this step.  Basically, it must be
63d5174d72Sskrll   possible for static binaries to build and base system libs to exist so
64d5174d72Sskrll   that "configure" can do its job for the target--these MK* options omit
65d5174d72Sskrll   the rest for this stage of the build.
66d5174d72Sskrll
67d5174d72Sskrll   MKLINT=no
68d5174d72Sskrll   MKPROFILE=no
69d5174d72Sskrll   MKSHARE=no
70a191c797Smartin   MKRUMP=no
71d5174d72Sskrll
723d71da30Sjoerg9. In src/tools/gcc, do "nbmake-MACHINE native-gcc".
73d5174d72Sskrll
74d5174d72Sskrll   This will do a full configury in ${.OBJDIR}/.native that is a "Canadian"
75d5174d72Sskrll   cross toolchain (--build reflects the host platform, but --host and
76d5174d72Sskrll   --target are the target).  The result is a tree that would build a
77d5174d72Sskrll   native-to-NetBSD compiler on a cross host, and mknative pulls glue data
78d5174d72Sskrll   from this.
79d5174d72Sskrll
803d71da30Sjoerg10. Try out a full build using "nbmake-MACHINE"; the result should include
81d5174d72Sskrll   a native compiler.
82d5174d72Sskrll
833d71da30Sjoerg11. If all is well, commit the glue files added to src/gnu/{lib,usr.bin}/*.
84