The Free Pascal team releases at intervals a completely prepared package, with compiler and units all ready to use, the so-called releases. After a release, work on the compiler continues, bugs are fixed and features are added. The Free Pascal team doesn't make a new release whenever they change something in the compiler, instead the sources are available for anyone to use and compile. Compiled versions of RTL and compiler are also made daily, and put on the web.
There are, nevertheless, circumstances when the compiler must be recompiled manually. When changes are made to compiler code, or when the compiler is downloaded through CVS.
There are essentially 2 ways of recompiling the compiler: by hand, or using the makefiles. Each of these methods will be discussed.
To compile the compiler easily, it is best to keep the following directory structure (a base directory of /pp/src is supposed, but that may be different):
/pp/src/Makefile /makefile.fpc /rtl/linux /inc /i386 /... /compilerWhen the makefiles should be used, the above directory tree must be used.
The compiler and rtl source are zipped in such a way that when both are unzipped in the same directory (/pp/src in the above) the above directory tree results.
There are 2 ways to start compiling the compiler and RTL. Both ways must be used, depending on the situation. Usually, the RTL must be compiled first, before compiling the compiler, after which the compiler is compiled using the current compiler. In some special cases the compiler must be compiled first, with a previously compiled RTL.
How to decide which should be compiled first? In general, the answer is that the RTL should be compiled first. There are 2 exceptions to this rule:
When compiling with make it is necessary to have the above directory structure. Compiling the compiler is achieved with the target cycle.
Under normal circumstances, recompiling the compiler is limited to the following instructions (assuming you start in directory /pp/src):
cd compiler make cycleThis will work only if the makefile is installed correctly and if the needed tools are present in the PATH. Which tools must be installed can be found in appendix
The above instructions will do the following:
Compiling for another target: When compiling the compiler for another target, it is necessary to specify the OS_TARGET makefile variable. It can be set to the following values: win32, go32v2, os2 and linux. As an example, cross-compilation for the go32v2 target from the win32 target is chosen:
cd compiler make cycle OS_TARGET=go32v2This will compile the go32v2 RTL, and compile a go32v2 compiler.
When compiling a new compiler and the compiler should be compiled using an existing compiled RTL, the all target must be used, and another RTL directory than the default (which is the ../rtl/$(OS_TARGET) directory) must be indicated. For instance, assuming that the compiled RTL units are in /pp/rtl, typing
cd compiler make clean make all UNITDIR=/pp/rtlshould use the RTL from the /pp/rtl dirrectory.
This will then compile the compiler using the RTL units in /pp/rtl. After this has been done, the 'make cycle' can be used, starting with this compiler:
make cycle PP=./ppc386This will do the make cycle from above, but will start with the compiler that was generated by the make all instruction.
In all cases, many options can be passed to make to influence the compile process. In general, the makefiles add any needed compiler options to the command-line, so that the RTL and compiler can be compiled. Additional options (e.g. optimization options) can be specified by passing them in OPT.
Compiling by hand is difficult and tedious, but can be done. The compilation of RTL and compiler will be treated separately.
ppc386 -Tlinux -b- -Fi../inc -Fi../i386 -FE. -di386 -Us -Sg syslinux.pp ppc386 -Tlinux -b- -Fi../inc -Fi../i386 -FE. -di386 ../inc/strings.pp ppc386 -Tlinux -b- -Fi../inc -Fi../i386 -FE. -di386 dos.pp ppc386 -Tlinux -b- -Fi../inc -Fi../i386 -FE. -di386 ../inc/objects.ppThese are the minimum command-line options, needed to compile the RTL.
For another processor, the i386 should be changed into the appropriate processor. For another operating system (target) the syslinux should be changed in the appropriate system unit file, and the target OS setting (-T) must be set accordingly.
Depending on the target OS there are other units that can be compiled, but which are not strictly needed to recompile the compiler. The following units are available for all plaforms:
Compiling the compiler can be done with one statement. It's always best to remove all units from the compiler directory first, so something like
rm *.ppu *.oon LINUX, and on DOS
del *.ppu del *.oAfter this, the compiler can be compiled with the following command-line:
ppc386 -Tlinux -Fu../rtl/linux -di386 -dGDB pp.pasSo, the minimum options are:
ppc386 -di386 -dGDB -Sg pp.pas
Some other command-line options can be used, but the above are the minimum. A list of recognised options can be found in table (FPCdefines) .
Define | does what |
TP | Needed to compile the compiler with Turbo or Borland Pascal. |
GDB | Support of the GNU Debugger (required switch). |
I386 | Generate a compiler for the Intel i386+ processor family. |
M68K | Generate a compiler for the M680x0 processor family. |
EXTDEBUG | Some extra debug code is executed. |
MEMDEBUG | Some memory usage information is displayed. |
SUPPORT_MMX | only i386: enables the compiler switch MMX which |
allows the compiler to generate MMX instructions. | |
EXTERN_MSG | Don't compile the msgfiles in the compiler, always use |
external messagefiles (default for TP). | |
LOGSECONDPASS | Write compiler node information in assembler output. |
NOOPT | Do not include the optimizer in the compiler. |