1*8feb0f0bSmrg@c Copyright (C) 2001-2020 Free Software Foundation, Inc. 21debfc3dSmrg@c This is part of the GCC manual. 31debfc3dSmrg@c For copying conditions, see the file gcc.texi. 41debfc3dSmrg 51debfc3dSmrg@node Makefile 61debfc3dSmrg@subsection Makefile Targets 71debfc3dSmrg@cindex makefile targets 81debfc3dSmrg@cindex targets, makefile 91debfc3dSmrg 101debfc3dSmrgThese targets are available from the @samp{gcc} directory: 111debfc3dSmrg 121debfc3dSmrg@table @code 131debfc3dSmrg@item all 141debfc3dSmrgThis is the default target. Depending on what your build/host/target 151debfc3dSmrgconfiguration is, it coordinates all the things that need to be built. 161debfc3dSmrg 171debfc3dSmrg@item doc 181debfc3dSmrgProduce info-formatted documentation and man pages. Essentially it 191debfc3dSmrgcalls @samp{make man} and @samp{make info}. 201debfc3dSmrg 211debfc3dSmrg@item dvi 221debfc3dSmrgProduce DVI-formatted documentation. 231debfc3dSmrg 241debfc3dSmrg@item pdf 251debfc3dSmrgProduce PDF-formatted documentation. 261debfc3dSmrg 271debfc3dSmrg@item html 281debfc3dSmrgProduce HTML-formatted documentation. 291debfc3dSmrg 301debfc3dSmrg@item man 311debfc3dSmrgGenerate man pages. 321debfc3dSmrg 331debfc3dSmrg@item info 341debfc3dSmrgGenerate info-formatted pages. 351debfc3dSmrg 361debfc3dSmrg@item mostlyclean 371debfc3dSmrgDelete the files made while building the compiler. 381debfc3dSmrg 391debfc3dSmrg@item clean 401debfc3dSmrgThat, and all the other files built by @samp{make all}. 411debfc3dSmrg 421debfc3dSmrg@item distclean 431debfc3dSmrgThat, and all the files created by @command{configure}. 441debfc3dSmrg 451debfc3dSmrg@item maintainer-clean 461debfc3dSmrgDistclean plus any file that can be generated from other files. Note 471debfc3dSmrgthat additional tools may be required beyond what is normally needed to 481debfc3dSmrgbuild GCC. 491debfc3dSmrg 501debfc3dSmrg@item srcextra 511debfc3dSmrgGenerates files in the source directory that are not version-controlled but 521debfc3dSmrgshould go into a release tarball. 531debfc3dSmrg 541debfc3dSmrg@item srcinfo 551debfc3dSmrg@itemx srcman 561debfc3dSmrgCopies the info-formatted and manpage documentation into the source 571debfc3dSmrgdirectory usually for the purpose of generating a release tarball. 581debfc3dSmrg 591debfc3dSmrg@item install 601debfc3dSmrgInstalls GCC. 611debfc3dSmrg 621debfc3dSmrg@item uninstall 631debfc3dSmrgDeletes installed files, though this is not supported. 641debfc3dSmrg 651debfc3dSmrg@item check 661debfc3dSmrgRun the testsuite. This creates a @file{testsuite} subdirectory that 671debfc3dSmrghas various @file{.sum} and @file{.log} files containing the results of 681debfc3dSmrgthe testing. You can run subsets with, for example, @samp{make check-gcc}. 691debfc3dSmrgYou can specify specific tests by setting @env{RUNTESTFLAGS} to be the name 701debfc3dSmrgof the @file{.exp} file, optionally followed by (for some tests) an equals 711debfc3dSmrgand a file wildcard, like: 721debfc3dSmrg 731debfc3dSmrg@smallexample 741debfc3dSmrgmake check-gcc RUNTESTFLAGS="execute.exp=19980413-*" 751debfc3dSmrg@end smallexample 761debfc3dSmrg 771debfc3dSmrgNote that running the testsuite may require additional tools be 781debfc3dSmrginstalled, such as Tcl or DejaGnu. 791debfc3dSmrg@end table 801debfc3dSmrg 811debfc3dSmrgThe toplevel tree from which you start GCC compilation is not 821debfc3dSmrgthe GCC directory, but rather a complex Makefile that coordinates 831debfc3dSmrgthe various steps of the build, including bootstrapping the compiler 841debfc3dSmrgand using the new compiler to build target libraries. 851debfc3dSmrg 861debfc3dSmrgWhen GCC is configured for a native configuration, the default action 871debfc3dSmrgfor @command{make} is to do a full three-stage bootstrap. This means 881debfc3dSmrgthat GCC is built three times---once with the native compiler, once with 891debfc3dSmrgthe native-built compiler it just built, and once with the compiler it 901debfc3dSmrgbuilt the second time. In theory, the last two should produce the same 911debfc3dSmrgresults, which @samp{make compare} can check. Each stage is configured 921debfc3dSmrgseparately and compiled into a separate directory, to minimize problems 931debfc3dSmrgdue to ABI incompatibilities between the native compiler and GCC. 941debfc3dSmrg 951debfc3dSmrgIf you do a change, rebuilding will also start from the first stage 961debfc3dSmrgand ``bubble'' up the change through the three stages. Each stage 971debfc3dSmrgis taken from its build directory (if it had been built previously), 981debfc3dSmrgrebuilt, and copied to its subdirectory. This will allow you to, for 991debfc3dSmrgexample, continue a bootstrap after fixing a bug which causes the 1001debfc3dSmrgstage2 build to crash. It does not provide as good coverage of the 1011debfc3dSmrgcompiler as bootstrapping from scratch, but it ensures that the new 1021debfc3dSmrgcode is syntactically correct (e.g., that you did not use GCC extensions 1031debfc3dSmrgby mistake), and avoids spurious bootstrap comparison 1041debfc3dSmrgfailures@footnote{Except if the compiler was buggy and miscompiled 1051debfc3dSmrgsome of the files that were not modified. In this case, it's best 1061debfc3dSmrgto use @command{make restrap}.}. 1071debfc3dSmrg 1081debfc3dSmrgOther targets available from the top level include: 1091debfc3dSmrg 1101debfc3dSmrg@table @code 1111debfc3dSmrg@item bootstrap-lean 1121debfc3dSmrgLike @code{bootstrap}, except that the various stages are removed once 1131debfc3dSmrgthey're no longer needed. This saves disk space. 1141debfc3dSmrg 1151debfc3dSmrg@item bootstrap2 1161debfc3dSmrg@itemx bootstrap2-lean 1171debfc3dSmrgPerforms only the first two stages of bootstrap. Unlike a three-stage 1181debfc3dSmrgbootstrap, this does not perform a comparison to test that the compiler 1191debfc3dSmrgis running properly. Note that the disk space required by a ``lean'' 1201debfc3dSmrgbootstrap is approximately independent of the number of stages. 1211debfc3dSmrg 1221debfc3dSmrg@item stage@var{N}-bubble (@var{N} = 1@dots{}4, profile, feedback) 1231debfc3dSmrgRebuild all the stages up to @var{N}, with the appropriate flags, 1241debfc3dSmrg``bubbling'' the changes as described above. 1251debfc3dSmrg 1261debfc3dSmrg@item all-stage@var{N} (@var{N} = 1@dots{}4, profile, feedback) 1271debfc3dSmrgAssuming that stage @var{N} has already been built, rebuild it with the 1281debfc3dSmrgappropriate flags. This is rarely needed. 1291debfc3dSmrg 1301debfc3dSmrg@item cleanstrap 1311debfc3dSmrgRemove everything (@samp{make clean}) and rebuilds (@samp{make bootstrap}). 1321debfc3dSmrg 1331debfc3dSmrg@item compare 1341debfc3dSmrgCompares the results of stages 2 and 3. This ensures that the compiler 1351debfc3dSmrgis running properly, since it should produce the same object files 1361debfc3dSmrgregardless of how it itself was compiled. 1371debfc3dSmrg 1381debfc3dSmrg@item profiledbootstrap 1391debfc3dSmrgBuilds a compiler with profiling feedback information. In this case, 1401debfc3dSmrgthe second and third stages are named @samp{profile} and @samp{feedback}, 1411debfc3dSmrgrespectively. For more information, see the installation instructions. 1421debfc3dSmrg 1431debfc3dSmrg@item restrap 1441debfc3dSmrgRestart a bootstrap, so that everything that was not built with 1451debfc3dSmrgthe system compiler is rebuilt. 1461debfc3dSmrg 1471debfc3dSmrg@item stage@var{N}-start (@var{N} = 1@dots{}4, profile, feedback) 1481debfc3dSmrgFor each package that is bootstrapped, rename directories so that, 1491debfc3dSmrgfor example, @file{gcc} points to the stage@var{N} GCC, compiled 1501debfc3dSmrgwith the stage@var{N-1} GCC@footnote{Customarily, the system compiler 1511debfc3dSmrgis also termed the @file{stage0} GCC.}. 1521debfc3dSmrg 1531debfc3dSmrgYou will invoke this target if you need to test or debug the 1541debfc3dSmrgstage@var{N} GCC@. If you only need to execute GCC (but you need 1551debfc3dSmrgnot run @samp{make} either to rebuild it or to run test suites), 1561debfc3dSmrgyou should be able to work directly in the @file{stage@var{N}-gcc} 1571debfc3dSmrgdirectory. This makes it easier to debug multiple stages in 1581debfc3dSmrgparallel. 1591debfc3dSmrg 1601debfc3dSmrg@item stage 1611debfc3dSmrgFor each package that is bootstrapped, relocate its build directory 1621debfc3dSmrgto indicate its stage. For example, if the @file{gcc} directory 1631debfc3dSmrgpoints to the stage2 GCC, after invoking this target it will be 1641debfc3dSmrgrenamed to @file{stage2-gcc}. 1651debfc3dSmrg 1661debfc3dSmrg@end table 1671debfc3dSmrg 1681debfc3dSmrgIf you wish to use non-default GCC flags when compiling the stage2 and 1691debfc3dSmrgstage3 compilers, set @code{BOOT_CFLAGS} on the command line when doing 1701debfc3dSmrg@samp{make}. 1711debfc3dSmrg 1721debfc3dSmrgUsually, the first stage only builds the languages that the compiler 1731debfc3dSmrgis written in: typically, C and maybe Ada. If you are debugging a 1741debfc3dSmrgmiscompilation of a different stage2 front-end (for example, of the 1751debfc3dSmrgFortran front-end), you may want to have front-ends for other languages 1761debfc3dSmrgin the first stage as well. To do so, set @code{STAGE1_LANGUAGES} 1771debfc3dSmrgon the command line when doing @samp{make}. 1781debfc3dSmrg 1791debfc3dSmrgFor example, in the aforementioned scenario of debugging a Fortran 1801debfc3dSmrgfront-end miscompilation caused by the stage1 compiler, you may need a 1811debfc3dSmrgcommand like 1821debfc3dSmrg 1831debfc3dSmrg@example 1841debfc3dSmrgmake stage2-bubble STAGE1_LANGUAGES=c,fortran 1851debfc3dSmrg@end example 1861debfc3dSmrg 1871debfc3dSmrgAlternatively, you can use per-language targets to build and test 1881debfc3dSmrglanguages that are not enabled by default in stage1. For example, 1891debfc3dSmrg@command{make f951} will build a Fortran compiler even in the stage1 1901debfc3dSmrgbuild directory. 1911debfc3dSmrg 192