Difference between revisions of "How to start"
m (typo corrected and hint to sudo added) |
|||
(11 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
= How to start = | = How to start = | ||
− | == | + | == Setting up the development environment == |
− | # Install the most recent FPC release for your | + | # Install the most recent FPC release for your operating system, get it [http://www.freepascal.org/sdown.html here] |
# Get the latest FPC source via subversion, read [http://www.freepascal.org/develop.html#svn here] how to do so. | # Get the latest FPC source via subversion, read [http://www.freepascal.org/develop.html#svn here] how to do so. | ||
# Test your setup: | # Test your setup: | ||
* Change to the directory fpc | * Change to the directory fpc | ||
− | * type <tt>make all</tt> and test see if it works without problems. If you've problems with the build, check the [ | + | * type <tt>make all</tt> and test see if it works without problems. If you've problems with the build, or for a general background info for the process, be sure to check the [[buildfaq]]. |
* If you wish to do so, you can install the newly generated compiler with <tt>make install</tt> (This may need sudo). | * If you wish to do so, you can install the newly generated compiler with <tt>make install</tt> (This may need sudo). | ||
Line 13: | Line 13: | ||
== Directory layout of the compiler == | == Directory layout of the compiler == | ||
− | + | The compiler sources are located in fpc/compiler and its subdirectories. | |
− | The compiler sources are located in fpc/compiler and | + | *<tt>fpc/</tt> the main directory |
− | *fpc/ | + | **<tt>compiler/</tt> files common for all target processors. |
− | **compiler/ | + | *** The processor specific files are in subdirectories <tt>alpha, arm, powerpc, i386</tt> (i386 only), <tt>ia64, m68k, mips, powerpc, powerpc64, sparc, x86</tt> (x86 general) and <tt>x86-64</tt> (x86-64 only). |
− | *** | + | *** <tt>systems/</tt> information files for the supported operating systems. |
− | + | ***: The <tt>i_*.pas</tt> files contain the information that is necessary for either hosting or building a compiler compiling for this target. | |
− | + | ***: The <tt>t_*.pas</tt> files contain the code which is necessary if a compiler is built for compiling for this particular target. | |
− | + | *** <tt>msg/</tt> compiler messages in various languages. | |
− | *** systems/ | + | *** <tt>utils/</tt> mainly help programs for compiler development. The are usually not important at the beginning. |
− | *** | ||
− | |||
− | |||
− | |||
− | < | ||
− | |||
− | |||
== Building the compiler == | == Building the compiler == | ||
− | |||
To build the compiler only, a <tt>make</tt> in fpc/compiler is enough. However, if you want to test the generated compiler and you aren't building a cross compiler, better do a <tt>make cycle</tt>. This tests if the modified compiler can compile itself and the rtl. | To build the compiler only, a <tt>make</tt> in fpc/compiler is enough. However, if you want to test the generated compiler and you aren't building a cross compiler, better do a <tt>make cycle</tt>. This tests if the modified compiler can compile itself and the rtl. | ||
=== Building a cross compiler === | === Building a cross compiler === | ||
+ | Building a cross compiler for another processor target is simple as well, just do a <tt>make CPU_TARGET=<processor target></tt>. | ||
− | + | Available processor targets for the current vresion are: arm, ia64, i386, powerpc, ppc64, sparc and x86_64. However, some of them might not work at the moment. | |
== Testing changes == | == Testing changes == | ||
− | + | When doing changes, it is always good to test these changes, for example by running the testsuite. | |
− | When doing changes, it is always good to test | ||
=== Running the testsuite === | === Running the testsuite === | ||
+ | The readme file in the fpc/tests directory contains more complete test suite instructions. | ||
− | cd fpc | + | cd fpc |
− | make clean all | + | make clean all |
− | cd tests | + | cd tests |
− | make clean all digest | + | make clean all digest |
− | You'll get something like at the end: | + | You'll get something like this at the end: |
... | ... | ||
/FPC/home/fpc/bin/digest output/i386-linux/log | /FPC/home/fpc/bin/digest output/i386-linux/log | ||
Line 69: | Line 62: | ||
== Recommended readings == | == Recommended readings == | ||
+ | Unfortunately, there is no documentation about the internals of the 2.x.x compiler yet. However, there is a documentation of the internals of 1.0.x which should give first clues: http://www.stack.nl/~marcov/comparch.pdf | ||
+ | |||
+ | Further, some information about the 2.x.x will be collected here: [[FPC internals]] | ||
− | + | = See also = | |
+ | * [[Control Pascal Tutorial]] - a simple way to start with no installation needed | ||
+ | * [[Compilers]] - another way to start with an installation | ||
− | + | [[Category:Tutorials]] | |
+ | [[Category:FPC]] | ||
+ | [[Category: Control Pascal]] |
Revision as of 14:46, 13 March 2017
How to start
Setting up the development environment
- Install the most recent FPC release for your operating system, get it here
- Get the latest FPC source via subversion, read here how to do so.
- Test your setup:
- Change to the directory fpc
- type make all and test see if it works without problems. If you've problems with the build, or for a general background info for the process, be sure to check the buildfaq.
- If you wish to do so, you can install the newly generated compiler with make install (This may need sudo).
Now you're ready to modify the compiler.
Directory layout of the compiler
The compiler sources are located in fpc/compiler and its subdirectories.
- fpc/ the main directory
- compiler/ files common for all target processors.
- The processor specific files are in subdirectories alpha, arm, powerpc, i386 (i386 only), ia64, m68k, mips, powerpc, powerpc64, sparc, x86 (x86 general) and x86-64 (x86-64 only).
- systems/ information files for the supported operating systems.
- The i_*.pas files contain the information that is necessary for either hosting or building a compiler compiling for this target.
- The t_*.pas files contain the code which is necessary if a compiler is built for compiling for this particular target.
- msg/ compiler messages in various languages.
- utils/ mainly help programs for compiler development. The are usually not important at the beginning.
- compiler/ files common for all target processors.
Building the compiler
To build the compiler only, a make in fpc/compiler is enough. However, if you want to test the generated compiler and you aren't building a cross compiler, better do a make cycle. This tests if the modified compiler can compile itself and the rtl.
Building a cross compiler
Building a cross compiler for another processor target is simple as well, just do a make CPU_TARGET=<processor target>.
Available processor targets for the current vresion are: arm, ia64, i386, powerpc, ppc64, sparc and x86_64. However, some of them might not work at the moment.
Testing changes
When doing changes, it is always good to test these changes, for example by running the testsuite.
Running the testsuite
The readme file in the fpc/tests directory contains more complete test suite instructions.
cd fpc make clean all cd tests make clean all digest
You'll get something like this at the end:
... /FPC/home/fpc/bin/digest output/i386-linux/log Total = 2975 (28:2947) Total number of compilations = 1692 (12:1680) Successfully compiled = 1361 Successfully failed = 319 Compilation failures = 12 Compilation that did not fail while they should = 0 Total number of runs = 1283 (16:1267) Successful runs = 1267 Failed runs = 16 ...
The important line is
Total = 2975 (28:2947)
It shows how much tests were run: 2975, how much failed: 28 and now much succeded: 2947. If you want to know what failed, see fpc/tests/output/<target>/longlog and fpc/tests/output/<target>/log.
Recommended readings
Unfortunately, there is no documentation about the internals of the 2.x.x compiler yet. However, there is a documentation of the internals of 1.0.x which should give first clues: http://www.stack.nl/~marcov/comparch.pdf
Further, some information about the 2.x.x will be collected here: FPC internals
See also
- Control Pascal Tutorial - a simple way to start with no installation needed
- Compilers - another way to start with an installation