How to start: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | # How to start | |
| 2 | 2 | ||
| 3 | 3 | ## Setting up the development environment | |
| 4 | 4 | ||
| 5 | 5 | 1. Install the most recent official FPC release for your operating system, get it [here](http://www.freepascal.org/sdown.html) | |
| 6 | 6 | 2. Get the latest FPC source from the repository, read [here](http://www.freepascal.org/develop.html) how to do so. | |
| 7 | 7 | 3. Test your setup: | |
| 8 | 8 | 1. Change to the directory `fpc` | |
| 9 | 9 | 2. 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]]. | |
| 10 | 10 | 3. If you wish to do so, you can install the newly generated compiler with `make install` (This may need sudo). | |
| 11 | 11 | ||
| 12 | 12 | Now you're ready to modify the compiler. | |
| 13 | 13 | ||
| 14 | 14 | ## Directory layout of the compiler | |
| 15 | 15 | ||
| 16 | 16 | The compiler sources are located in fpc/compiler and its subdirectories. | |
| 17 | 17 | ||
| 18 | 18 | - `fpc/` the main directory | |
| 19 | 19 | - `compiler/` files common for all target processors. | |
| 20 | 20 | - 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). | |
| 21 | 21 | - `systems/` information files for the supported operating systems. | |
| 22 | 22 | ||
| 23 | 23 | The `i_*.pas` files contain the information that is necessary for either hosting or building a compiler compiling for this target. | |
| 24 | 24 | ||
| 25 | 25 | The `t_*.pas` files contain the code which is necessary if a compiler is built for compiling for this particular target. | |
| 26 | 26 | - `msg/` compiler messages in various languages. | |
| 27 | 27 | - `utils/` mainly help programs for compiler development. The are usually not important at the beginning. | |
| 28 | 28 | ||
| 29 | 29 | ## Building the compiler | |
| 30 | 30 | ||
| 31 | 31 | 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. | |
| 32 | 32 | ||
| 33 | 33 | ### Building a cross compiler | |
| 34 | 34 | ||
| 35 | 35 | See [[Cross compiling]]. | |
| 36 | 36 | ||
| 37 | 37 | ## Testing changes | |
| 38 | 38 | ||
| 39 | 39 | When doing changes, it is always good to test these changes, for example by running the testsuite. | |
| 40 | 40 | ||
| 41 | 41 | ### Running the testsuite | |
| 42 | 42 | ||
| 43 | 43 | The readme file in the fpc/tests directory contains more complete test suite instructions. | |
| 44 | 44 | ||
| 45 | - | ||
| 46 | - | ||
| 47 | - | ||
| 48 | - | ||
| 45 | + | ```text | |
| 46 | + | cd fpc | |
| 47 | + | make clean all | |
| 48 | + | cd tests | |
| 49 | + | make clean all digest | |
| 50 | + | ``` | |
| 49 | 51 | ||
| 50 | 52 | You'll get something like this at the end: | |
| 51 | 53 | ||
| 52 | - | ||
| 53 | - | ||
| 54 | - | ||
| 55 | - | ||
| 56 | - | ||
| 57 | - | ||
| 58 | - | ||
| 59 | - | ||
| 60 | - | ||
| 61 | - | ||
| 62 | - | ||
| 63 | - | ||
| 54 | + | ```text | |
| 55 | + | ... | |
| 56 | + | /FPC/home/fpc/bin/digest output/i386-linux/log | |
| 57 | + | Total = 2975 (28:2947) | |
| 58 | + | Total number of compilations = 1692 (12:1680) | |
| 59 | + | Successfully compiled = 1361 | |
| 60 | + | Successfully failed = 319 | |
| 61 | + | Compilation failures = 12 | |
| 62 | + | Compilation that did not fail while they should = 0 | |
| 63 | + | Total number of runs = 1283 (16:1267) | |
| 64 | + | Successful runs = 1267 | |
| 65 | + | Failed runs = 16 | |
| 66 | + | ... | |
| 67 | + | ``` | |
| 64 | 68 | ||
| 65 | 69 | The important line is | |
| 66 | 70 | ||
| 67 | - | ||
| 71 | + | ```text | |
| 72 | + | Total = 2975 (28:2947) | |
| 73 | + | ``` | |
| 68 | 74 | ||
| 69 | 75 | 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`. | |
| 70 | 76 | ||
| 71 | 77 | ## Recommended readings | |
| 72 | 78 | ||
| 73 | 79 | 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> | |
| 74 | 80 | ||
| 75 | 81 | Further, some information about the 2.x.x will be collected here: [[FPC internals]] | |
| 76 | 82 | ||
| 77 | 83 | # See also | |
| 78 | 84 | ||
| 79 | 85 | - [[Control Pascal Tutorial]] - a simple way to start with no installation needed | |
| 80 | 86 | - [[Compilers]] - another way to start with an installation | |
| 81 | 87 | ||
| 82 | 88 | --- | |
| 83 | 89 | *From the Free Pascal wiki, page "How to start", as it stood on 2022-09-11 after a change by PierceNg, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 84 | 90 | Category: Control Pascal | |
| 85 | 91 | Category: FPC | |
| 86 | 92 | Category: Tutorials |
