Home | History | Annotate | only in /src/tools/gcc
Up to higher level directory
NameDateSize
gcc-version.mk16-Sep-2025232
lgpl3.mk09-Aug-2023769
Makefile17-Sep-20259.7K
mknative-gcc17-Sep-202514.5K
mknative-gcc.old16-Sep-202514.2K
mknative.common15-Apr-20182.8K
README.mknative21-Jul-20253.7K

README.mknative

      1 $NetBSD: README.mknative,v 1.24 2025/07/21 05:27:20 mrg 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 0. Note that example paths like src/external/gpl3/gcc/lib/libgcc/arch will
     22    really be src/external/gpl3/gcc.old/lib/libgcc/arch for the previous GCC.
     23 
     24 1. Set MKMAINTAINERTOOLS=yes in mk.conf.  (Needed so that src/tools/gettext
     25    gets built, eliciting proper HAVE_*GETTEXT* defns in config.h files.)
     26 
     27 2. Build and install a cross toolchain (via "build.sh -m MACHINE tools").
     28    Note that while PR #47353 is not fixed, you can not use the -O option
     29    to build.sh. Use -M instead. (The differences are in layout and pathname
     30    prefixes in the object directory pointed to by each option.)
     31 
     32 3. In src/tools/gcc, do "nbmake-MACHINE HAVE_GCC=8 bootstrap-libgcc".
     33 
     34    This will create just enough glue in src/external/gpl3/gcc/lib/libgcc/arch
     35    to make it possible to build, based on the toolchain built in
     36    ${.OBJDIR}/build.
     37    Because the files generated in this step contain things like
     38    -DCROSS_COMPILE, they are not suitable for committing.  Step 8 below
     39    will regenerate the "proper" libgcc config files.
     40 
     41 4. At top level, do
     42    "nbmake-MACHINE obj do-distrib-dirs MKGCC=no MKBINUTILS=no HAVE_GCC=8", and
     43    "nbmake-MACHINE includes HAVE_GCC= MKGCC=no MKBINUTILS=no HAVE_GCC=8".
     44    (Note: replace 8 [for GCC 8.x] with the appropriate version you are going
     45    to mknative-for, the MKGCC=no prevents the standard makefiles from picking
     46    up any gcc version info automatically)
     47 
     48 5. In src/lib/csu, do
     49    "nbmake-MACHINE dependall". and "nbmake-MACHINE install".
     50 
     51 6. In src/external/gpl3/gcc/lib/libgcc, do
     52    "nbmake-MACHINE obj includes dependall install".
     53 
     54 7. In each of src/external/lgpl3/gmp/lib/libgmp,
     55    src/external/lgpl3/mpfr/lib/libmpfr, src/external/lgpl3/mpc/lib/libmpc,
     56    and src/external/mit/isl, do "nbmake-MACHINE obj dependall".
     57 
     58 8. In src/lib, do
     59    "nbmake-MACHINE dependall install MKGCC=no HAVE_GCC=8".
     60 
     61    Optionally, all of the following may be set in the environment to reduce
     62    the amount of code needed to build at this step.  Basically, it must be
     63    possible for static binaries to build and base system libs to exist so
     64    that "configure" can do its job for the target--these MK* options omit
     65    the rest for this stage of the build. 
     66 
     67    MKLINT=no
     68    MKPROFILE=no
     69    MKSHARE=no
     70    MKRUMP=no
     71 
     72 9. In src/tools/gcc, do "nbmake-MACHINE native-gcc".
     73 
     74    This will do a full configury in ${.OBJDIR}/.native that is a "Canadian"
     75    cross toolchain (--build reflects the host platform, but --host and
     76    --target are the target).  The result is a tree that would build a
     77    native-to-NetBSD compiler on a cross host, and mknative pulls glue data
     78    from this.
     79 
     80 10. Try out a full build using "nbmake-MACHINE"; the result should include
     81    a native compiler.
     82 
     83 11. If all is well, commit the glue files added to src/gnu/{lib,usr.bin}/*.
     84