Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2020-08

Planning to experiment with FPC extentions

7 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Boian Mitov

Hello everyone,

I have been planning for long time to try to add support for advanced RTTI to FPC, but never had the chance to work on it. I don’t even know how to start. Is there any information on how to setup for recompiling the compiler sources and even where the sources and the project files for the compiler are? Can someone help me setup so I can start to study the code and see how I can start working on it?

With best regards,
Boian Mitov

------------------------------------------------------- Mitov Software
www.mitov.com
-------------------------------------------------------

Reply by email

Ryan Joseph
to Boian Mitov

I started by using lazbuild with one of the .lpi files included in the fpc sources (add debug information when building also).

lazbuild /fpc/compiler/ppcx64.lpi

Next thing to do is put a syntax error in a example program and build it using the compiler (/fpc/compiler/ppcx64 myprog.pas for example) and a debugger (I use VSCode on macOS now but Lazarus works). Step through the compiler line by line until you understand the basics of where you are. Eventually add more syntaxes to your example program and step around in the debugger to analyze how it works.

That's basically all the information there is sadly. I thought of making a little screencast video of myself doing this but I'm not sure how useful that would be.

Show quoted text 7 lines
On Aug 26, 2020, at 7:57 AM, Boian Mitov via fpc-devel wrote: Hello everyone, I have been planning for long time to try to add support for advanced RTTI to FPC, but never had the chance to work on it. I don’t even know how to start. Is there any information on how to setup for recompiling the compiler sources and even where the sources and the project files for the compiler are? Can someone help me setup so I can start to study the code and see how I can start working on it?

Regards,
Ryan Joseph

Reply by email

Christo Crause
to Boian Mitov: I have been planning for long time to try to add support for advanced RTTI to FPC, but…

On Wed, 26 Aug 2020, 03:02 Boian Mitov via fpc-devel, <

Show quoted text 10 lines
wrote: I have been planning for long time to try to add support for advanced RTTI to FPC, but never had the chance to work on it. I don’t even know how to start. Is there any information on how to setup for recompiling the compiler sources and even where the sources and the project files for the compiler are? Can someone help me setup so I can start to study the code and see how I can start working on it?

This page has a summary of where one can locate the source: https://www.freepascal.org/develop.html

The official repository uses svn. I find it a bit easier to work with git, this is a good place to fork from if you prefer git: https://github.com/graemeg/freepascal

As Ryan mentioned, start with one of the Lazarus projects in the compiler folder, this is a quick why to modify, compile and test. Once you are satisfied the next step is to build the whole tree (compiler, rtl, packages, utilities) using make. If this works, run the test suite in the tests folder.

Good luck!

Reply by email

Sven Barth
to Boian Mitov: I have been planning for long time to try to add support for advanced RTTI to FPC, but…

Boian Mitov via fpc-devel schrieb am Mi.,
26. Aug. 2020, 03:02:

Show quoted text 10 lines
Hello everyone, I have been planning for long time to try to add support for advanced RTTI to FPC, but never had the chance to work on it. I don’t even know how to start. Is there any information on how to setup for recompiling the compiler sources and even where the sources and the project files for the compiler are? Can someone help me setup so I can start to study the code and see how I can start working on it?

It would be great if we'd get Extended RTTI support.

As others already wrote, the sources are available in SVN, though we also have an unofficial Git mirror. I personally use git-svn.

Building the source is done using

make all FPMAKEOPT="-T <Threads>" -j <Threads>

Where <Threads> is the number of threads that should be used while building (I usually use the number of CPU cores).

Before you do any changes I suggest to do a full build and a testsuite run once. For the testsuite you go to the tests directory and run

make full TEST_FPC=/path/to/created/ppc - j <Threads>

The ppc will be for example compiler/ppcx64 for a x84_64 compiler on Linux or compiler/ppc386.exe for a i386 Windows.
Sidenote: if you use a Lazarus project to build the compiler the path will be compiler/<CPU>/pp(.exe)

After you've run the testsuite I suggest you to backup the tests/output/<CPU>-<OS>/faillist file. This will be your baseline that you need to compare against when developing a new feature.

Regarding the topic of Extended RTTI itself, please also take note of this: https://foundation.freepascal.org/projects/project-1 I had written up some requirements for the Extended RTTI for the Foundation and that information is still valid. For further question you can ask them here on the list (especially general build questions or about compiler internals).

Regards,
Sven

Reply by email

Jonas Maebe
to Boian Mitov: I have been planning for long time to try to add support for advanced RTTI to FPC, but…
Boian Mitov wrote 7 lines
I have been planning for long time to try to add support for advanced RTTI to FPC, but never had the chance to work on it. I don’t even know how to start. Is there any information on how to setup for recompiling the compiler sources and even where the sources and the project files for the compiler are? Can someone help me setup so I can start to study the code and see how I can start working on it?

The RTTI generation is in ncgrtti.pas. It makes use of the typed const builder, which is one of the few parts of the compiler that's documented: https://wiki.freepascal.org/Generating_initialised_data (although that documentation hasn't been updated in quite a while, so it may be a bit out of date).

Jonas

Reply by email

Ryan Joseph
to Boian Mitov: I have been planning for long time to try to add support for advanced RTTI to FPC, but…

Boian just today I made a little patch for a bug in the compiler (https://bugs.freepascal.org/view.php?id=37650) and I recorded a short 8 min video showing the process. I'm admittedly pretty terrible at making videos but it may be useful to just see the basics. I'm using VSCode as the editor/debugger and I go into how that works with Pascal but obviously you could do this with Lazarus (I prefer the debugger in VSCode so I use that when I'm doing debugger heavy work).

https://www.youtube.com/watch?v=eqUCPJYoEAo

Regards,
Ryan Joseph

Reply by email

Jonas Maebe
to Ryan Joseph
Ryan Joseph wrote
Boian just today I made a little patch for a bug in the compiler (https://bugs.freepascal.org/view.php?id=37650) and I recorded a short 8 min video showing the process. I'm admittedly pretty terrible at making videos but it may be useful to just see the basics. I'm using VSCode as the editor/debugger and I go into how that works with Pascal but obviously you could do this with Lazarus (I prefer the debugger in VSCode so I use that when I'm doing debugger heavy work). https://www.youtube.com/watch?v=eqUCPJYoEAo

Small tip: _the_ place to put your breakpoint in the compiler to catch syntax errors, internal errors, and basically any other kind of error that's not a crash/runtime error is verbose.GenerateError

Jonas

Reply by email