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