Sign in Join

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

Mailing lists / fpc-devel / 2015-02

RTTI interface & variant late binding issue (mORMot)

74 messages · 12 people · –

Reply by email Subscribe to this list Your subscription

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

Alfred

Hello to all,

While enjoying variant late binding for a couple of month now, I would like to ask for an update on the status of RTTI.

The mORMot developer has designed a work-around for the missing RTTI. This works well.
But it would be (much) nicer to be able to use RTTI without workaround.

Does anybody have some info about the status of this (feature) request ?

Thanks !

Reply by email

Florian Klämpfl
to Alfred
Alfred wrote 9 lines
Hello to all, While enjoying variant late binding for a couple of month now, I would like to ask for an update on the status of RTTI. The mORMot developer has designed a work-around for the missing RTTI. This works well. But it would be (much) nicer to be able to use RTTI without workaround. Does anybody have some info about the status of this (feature) request ?

No more than: http://bugs.freepascal.org/view.php?id=26774

Reply by email

Maciej Izak
to Alfred: While enjoying variant late binding for a couple of month now, I would like to ask for an…

I am working on "Invoke" method from RTTI module and TValue. "Invoke" is important for attributes, and for ObjAuto module.

Some related work to RTTI you can find in this branch:

http://svn.freepascal.org/cgi-bin/viewvc.cgi/branches/joost/?view=log

2015-02-05 11:23 GMT+01:00 Alfred :

Show quoted text 11 lines
While enjoying variant late binding for a couple of month now, I would like to ask for an update on the status of RTTI. The mORMot developer has designed a work-around for the missing RTTI. This works well. But it would be (much) nicer to be able to use RTTI without workaround. Does anybody have some info about the status of this (feature) request ?

Regards,

Maciej Izak

Reply by email

Michael Van Canneyt
to Alfred: While enjoying variant late binding for a couple of month now, I would like to ask for an…
Alfred wrote 8 lines
Hello to all,   While enjoying variant late binding for a couple of month now, I would like to ask for an update on the status of RTTI.   The mORMot developer has designed a work-around for the missing RTTI. This works well. But it would be (much) nicer to be able to use RTTI without workaround.   Does anybody have some info about the status of this (feature) request ?

If you are referring to http://bugs.freepascal.org/view.php?id=26774

Work on it was started by Steve Hildebrandt, but I got the impression that due to the cross-platform nature of FPC he ran into some problems. I may be wrong, though.
I do not know enough about the compiler internals to assess the situation.

Michael.

Reply by email

Steve Hildebrandt
to Michael Van Canneyt
Michael Van Canneyt wrote 24 lines
On Thu, 5 Feb 2015, Alfred wrote: > Hello to all, > > While enjoying variant late binding for a couple of month now, I > would like to ask for an update on the status of RTTI. > > The mORMot developer has designed a work-around for the missing RTTI. > This works well. > But it would be (much) nicer to be able to use RTTI without workaround. > > Does anybody have some info about the status of this (feature) request ? If you are referring to http://bugs.freepascal.org/view.php?id=26774 Work on it was started by Steve Hildebrandt, but I got the impression that due to the cross-platform nature of FPC he ran into some problems. I may be wrong, though. I do not know enough about the compiler internals to assess the situation. Michael.

Your assesment is correct.
I have a version that is nearly complete for Windows(for other platforms I have't done anything). But to have RTTI on all platforms, that is still delphi compatible is not possible(at least for me), due to the nature of some architetures / calling conventions. When I have some free time(after the tests for this semester) I will probably be able to post a patch.

Steve

Reply by email

Florian Klämpfl
to Steve Hildebrandt
Steve Hildebrandt wrote 28 lines
Am 06.02.2015 um 09:49 schrieb Michael Van Canneyt: > > > On Thu, 5 Feb 2015, Alfred wrote: > >> Hello to all, >> >> While enjoying variant late binding for a couple of month now, I would like to ask for an update >> on the status of RTTI. >> >> The mORMot developer has designed a work-around for the missing RTTI. This works well. >> But it would be (much) nicer to be able to use RTTI without workaround. >> >> Does anybody have some info about the status of this (feature) request ? > > If you are referring to http://bugs.freepascal.org/view.php?id=26774 > > Work on it was started by Steve Hildebrandt, but I got the impression that > due to the cross-platform nature of FPC he ran into some problems. I may be wrong, though. I do > not know enough about the compiler internals to assess the situation. > > Michael. Your assesment is correct. I have a version that is nearly complete for Windows(for other platforms I have't done anything). But to have RTTI on all platforms, that is still delphi compatible is not possible(at least for me), due to the nature of some architetures / calling conventions. When I have some free time(after the tests for this semester) I will probably be able to post a patch.

Would it be possible that you post the current state of the patch somewhere? So people can look/work on it.

Reply by email

Sven Barth
to Steve Hildebrandt: Your assesment is correct. I have a version that is nearly complete for Windows(for other…
Steve Hildebrandt wrote 33 lines
Am 06.02.2015 um 09:49 schrieb Michael Van Canneyt: > > > On Thu, 5 Feb 2015, Alfred wrote: > >> Hello to all, >> >> While enjoying variant late binding for a couple of month now, I >> would like to ask for an update on the status of RTTI. >> >> The mORMot developer has designed a work-around for the missing RTTI. >> This works well. >> But it would be (much) nicer to be able to use RTTI without workaround. >> >> Does anybody have some info about the status of this (feature) request ? > > If you are referring to http://bugs.freepascal.org/view.php?id=26774 > > Work on it was started by Steve Hildebrandt, but I got the impression > that > due to the cross-platform nature of FPC he ran into some problems. I > may be wrong, though. I do not know enough about the compiler > internals to assess the situation. > > Michael. Your assesment is correct. I have a version that is nearly complete for Windows(for other platforms I have't done anything). But to have RTTI on all platforms, that is still delphi compatible is not possible(at least for me), due to the nature of some architetures / calling conventions. When I have some free time(after the tests for this semester) I will probably be able to post a patch.

You don't need to implement Invoke for all platforms for now. Just raise an exception and hopefully platform maintainers will take it from there. The most important part is that the parameter description is flexible enough to potentially allow for all platforms to be supported.

Regards,
Sven

Reply by email

Steve Hildebrandt
to Sven Barth
Sven Barth wrote 45 lines
On 06.02.2015 19:49, Steve Hildebrandt wrote: > > Am 06.02.2015 um 09:49 schrieb Michael Van Canneyt: >> >> >> On Thu, 5 Feb 2015, Alfred wrote: >> >>> Hello to all, >>> >>> While enjoying variant late binding for a couple of month now, I >>> would like to ask for an update on the status of RTTI. >>> >>> The mORMot developer has designed a work-around for the missing RTTI. >>> This works well. >>> But it would be (much) nicer to be able to use RTTI without >>> workaround. >>> >>> Does anybody have some info about the status of this (feature) >>> request ? >> >> If you are referring to http://bugs.freepascal.org/view.php?id=26774 >> >> Work on it was started by Steve Hildebrandt, but I got the impression >> that >> due to the cross-platform nature of FPC he ran into some problems. I >> may be wrong, though. I do not know enough about the compiler >> internals to assess the situation. >> >> Michael. > Your assesment is correct. > I have a version that is nearly complete for Windows(for other platforms > I have't done anything). But to have RTTI on all platforms, that is > still delphi compatible is not possible(at least for me), due to the > nature of some architetures / calling conventions. > When I have some free time(after the tests for this semester) I will > probably be able to post a patch. You don't need to implement Invoke for all platforms for now. Just raise an exception and hopefully platform maintainers will take it from there. The most important part is that the parameter description is flexible enough to potentially allow for all platforms to be supported. Regards, Sven

And here is the problem, depending on the calling convention it may not fit into the delphi compatible RTTI layout.
If more information is needed than a stack offset or a single register index, you will need to acomodate that somehow.

Steve

Reply by email

Sven Barth
to Steve Hildebrandt
Steve Hildebrandt wrote 12 lines
> You don't need to implement Invoke for all platforms for now. Just > raise an exception and hopefully platform maintainers will take it > from there. The most important part is that the parameter description > is flexible enough to potentially allow for all platforms to be > supported. > > Regards, > Sven And here is the problem, depending on the calling convention it may not fit into the delphi compatible RTTI layout. If more information is needed than a stack offset or a single register index, you will need to acomodate that somehow.

How does the information record look currently? Our RTTIs aren't 100% compatible anyway, so I wouldn't mind if we add needed fields for other platforms. Of course we'd first need to know whether any other platform has such needs...
At least for m68k I can say that register index and stack offset should be enough.

Regards,
Sven

Reply by email

Florian Klämpfl
to Sven Barth
Sven Barth wrote 18 lines
On 07.02.2015 11:45, Steve Hildebrandt wrote: >> You don't need to implement Invoke for all platforms for now. Just >> raise an exception and hopefully platform maintainers will take it >> from there. The most important part is that the parameter description >> is flexible enough to potentially allow for all platforms to be >> supported. >> >> Regards, >> Sven > And here is the problem, depending on the calling convention it may not > fit into the delphi compatible RTTI layout. > If more information is needed than a stack offset or a single register > index, you will need to acomodate that somehow. How does the information record look currently? Our RTTIs aren't 100% compatible anyway, so I wouldn't mind if we add needed fields for other platforms. Of course we'd first need to know whether any other platform has such needs... At least for m68k I can say that register index and stack offset should be enough.

x86-64 (PowerPC too) is pretty compilcated in this regard: single parameters can span across multiple registers. IIRC some ABIs even require mixed integer/fpu/stack locations for one parameter.

Reply by email

Florian Klämpfl
to Florian Klämpfl
Florian Klämpfl wrote 22 lines
Am 07.02.2015 um 11:54 schrieb Sven Barth: > On 07.02.2015 11:45, Steve Hildebrandt wrote: >>> You don't need to implement Invoke for all platforms for now. Just >>> raise an exception and hopefully platform maintainers will take it >>> from there. The most important part is that the parameter description >>> is flexible enough to potentially allow for all platforms to be >>> supported. >>> >>> Regards, >>> Sven >> And here is the problem, depending on the calling convention it may not >> fit into the delphi compatible RTTI layout. >> If more information is needed than a stack offset or a single register >> index, you will need to acomodate that somehow. > > How does the information record look currently? Our RTTIs aren't 100% compatible anyway, so I > wouldn't mind if we add needed fields for other platforms. Of course we'd first need to know whether > any other platform has such needs... > At least for m68k I can say that register index and stack offset should be enough. x86-64 (PowerPC too) is pretty compilcated in this regard: single parameters can span across multiple registers. IIRC some ABIs even require mixed integer/fpu/stack locations for one parameter.

Just an idea: What about serializing TCGPara/TCGParalocation?

Reply by email

Maciej Izak
to Sven Barth: You don't need to implement Invoke for all platforms for now. Just raise an exception and…

Ehm. It's unfair. I arleady posted some time ago that "Invoke" is done for windows by me... Then you posted that we need version for all platforms... Double standards in community? :\
7 lut 2015 11:28 "Sven Barth" napisał(a):

Show quoted text 52 lines
On 06.02.2015 19:49, Steve Hildebrandt wrote: > > Am 06.02.2015 um 09:49 schrieb Michael Van Canneyt: > >> >> >> On Thu, 5 Feb 2015, Alfred wrote: >> >> Hello to all, >>> >>> While enjoying variant late binding for a couple of month now, I >>> would like to ask for an update on the status of RTTI. >>> >>> The mORMot developer has designed a work-around for the missing RTTI. >>> This works well. >>> But it would be (much) nicer to be able to use RTTI without workaround. >>> >>> Does anybody have some info about the status of this (feature) request ? >>> >> >> If you are referring to http://bugs.freepascal.org/view.php?id=26774 >> >> Work on it was started by Steve Hildebrandt, but I got the impression >> that >> due to the cross-platform nature of FPC he ran into some problems. I >> may be wrong, though. I do not know enough about the compiler >> internals to assess the situation. >> >> Michael. >> > Your assesment is correct. > I have a version that is nearly complete for Windows(for other platforms > I have't done anything). But to have RTTI on all platforms, that is > still delphi compatible is not possible(at least for me), due to the > nature of some architetures / calling conventions. > When I have some free time(after the tests for this semester) I will > probably be able to post a patch. > You don't need to implement Invoke for all platforms for now. Just raise an exception and hopefully platform maintainers will take it from there. The most important part is that the parameter description is flexible enough to potentially allow for all platforms to be supported. Regards, Sven _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Jonas Maebe
to Florian Klämpfl: Just an idea: What about serializing TCGPara/TCGParalocation?
Florian Klämpfl wrote
Just an idea: What about serializing TCGPara/TCGParalocation?

The main issue I see with that is that this format changes from time to time. I'll probably have to change it again to fully support the ppc64le ABI.

To me, the optimal solution would be to simply use libffi (you would only need logic to translate the rtti for the parameter types to libffi format, and it would automagically work for all platforms), but since that's an external dependency I guess that's not acceptable. I'm however definitely not looking forward to reimplementing parameter passing/loading and calling routines for all platforms again inside the rtl.

Jonas

Reply by email

Sven Barth
to Maciej Izak: Ehm. It's unfair. I arleady posted some time ago that "Invoke" is done for windows by…
Maciej Izak wrote
Ehm. It's unfair. I arleady posted some time ago that "Invoke" is done for windows by me... Then you posted that we need version for all platforms... Double standards in community? :\

It's a bit hard to keep the overview when volunteers from outside are working without communicating with us. That was the first update I read from Steve since he said that he's going to work on extended RTTI a few months back and to be frankly honest: I simply forgot your mail from the fifth (or do you mean a different one?) among my normal daily work. So I'm sorry if it came of as having double standards we're just human beings after all...

Would you please elaborate what exactly you are working on? Maybe we can find synergies between your work and Steve's.

And of course we need a cross platform solution. It won't work for us to have it just for Windows. At least the main platforms i386-win32, x86_64-win64, i386-linux, x86_64-linux, i386-darwin and x86_64-darwin should be covered. Immediately followed by arm-linux and arm-darwin with aarch64-darwin not so far behind I suspect... Though most work should be per CPU-platform and not per-target anyway...

Regards,
Sven

Reply by email

Florian Klämpfl
to Jonas Maebe: The main issue I see with that is that this format changes from time to time. I'll…
Jonas Maebe wrote 11 lines
On 07/02/15 11:58, Florian Klämpfl wrote: > Just an idea: What about serializing TCGPara/TCGParalocation? The main issue I see with that is that this format changes from time to time. I'll probably have to change it again to fully support the ppc64le ABI. To me, the optimal solution would be to simply use libffi (you would only need logic to translate the rtti for the parameter types to libffi format, and it would automagically work for all platforms), but since that's an external dependency I guess that's not acceptable.

Well, the technical aspect is one thing, but its license is another issue. Violating it happens too quick.

Show quoted text 10 lines
I'm however definitely not looking forward to reimplementing parameter passing/loading and calling routines for all platforms again inside the rtl. Jonas _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Steve Hildebrandt
to Maciej Izak: Ehm. It's unfair. I arleady posted some time ago that "Invoke" is done for windows by…
Maciej Izak wrote 5 lines
Ehm. It's unfair. I arleady posted some time ago that "Invoke" is done for windows by me... Then you posted that we need version for all platforms... Double standards in community? :\

To clarify what I have done:
I implemented RTTI in a delphi compatible way that could be used for "invoke" or other shenanigans, while this works nice if we need to 1 offset / 1 register index,
it will not work as it is for each and every convention that is supported by fpc. What I haven't done is build TValue.invoke or somthing similar.

The calling code for x86_64 invoke or stdcall should be somwhat different. Consequence is someone will need to implement invoke for each convention so it works with the provided information.

The questions I have is, how is the information you use for invoke organised? like delphi?

Since I have some project and tests going on for university I have no problem to stop working on it.
I started the work quite a while back and only becouse I needed some of it for my own projects.

mfg Steve

Reply by email

patspiper
to Sven Barth: It's a bit hard to keep the overview when volunteers from outside are working without…
Sven Barth wrote 22 lines
On 07.02.2015 12:10, Maciej Izak wrote: > Ehm. It's unfair. I arleady posted some time ago that "Invoke" is done > for windows by me... Then you posted that we need version for all > platforms... Double standards in community? :\ It's a bit hard to keep the overview when volunteers from outside are working without communicating with us. That was the first update I read from Steve since he said that he's going to work on extended RTTI a few months back and to be frankly honest: I simply forgot your mail from the fifth (or do you mean a different one?) among my normal daily work. So I'm sorry if it came of as having double standards we're just human beings after all... Would you please elaborate what exactly you are working on? Maybe we can find synergies between your work and Steve's. And of course we need a cross platform solution. It won't work for us to have it just for Windows. At least the main platforms i386-win32, x86_64-win64, i386-linux, x86_64-linux, i386-darwin and x86_64-darwin should be covered. Immediately followed by arm-linux and arm-darwin with aarch64-darwin not so far behind I suspect... Though most work should be per CPU-platform and not per-target anyway...

arm-winCE and arm-android?

Stephano

Reply by email

Florian Klämpfl
to Sven Barth: It's a bit hard to keep the overview when volunteers from outside are working without…
Sven Barth wrote 7 lines
On 07.02.2015 12:10, Maciej Izak wrote: > Ehm. It's unfair. I arleady posted some time ago that "Invoke" is done > for windows by me... Then you posted that we need version for all > platforms... Double standards in community? :\ It's a bit hard to keep the overview when volunteers from outside are working without communicating with us.

That's why I propose that people do they work in a branch of the central svn :)

That was the first update I read from Steve since he said that he's going to work on

extended RTTI a few months back and to be frankly honest: I simply forgot your mail from the fifth (or do you mean a different one?) among my normal daily work. So I'm sorry if it came of as having double standards we're just human beings after all...

Reply by email

Arnaud Bouchez

Just to be clear, because it sounds like there is some confusion in the discussion.

About http://bugs.freepascal.org/view.php?id=26774

1. We do NOT need Invoke() implemented.
2. We do NOT need extended RTTI as available since Delphi 2010, nor features like attributes.
3. We do NOT need 100% compatibility with Delphi - it is fine to have some diverse data layout.
4. There should not be huge platform specific work.

Because:

1. We have our own low-level Invoke, for x86 and x64 platforms, working on both Windows and Linux.
Note: you can take a look at how we defined the asm stubs, in mORMot.pas
- much better design than the RTTI.pas or RIO.pas code IMHO - see http://blog.synopse.info/post/2012/03/07/Interface-based-services-implementation-details

2. We need only the RTTI as available since Delphi 6 for IInvokable methods arguments.

3. We already introduced some FPC-specific code, e.g. to follow RTTI data alignment on platforms which demand it.

4. By design, point 2 is mostly platform-independent, and some details (like calling conventions) do already exist for other part of the existing FPC RTTI.
What is needed by this bug report is to have
objectdef_rtti_interface_full(def:tobjectdef) implemented in ncgrtti.pas.

Any new input is welcome!

Arnaud

Reply by email

Jonas Maebe
to Florian Klämpfl: Well, the technical aspect is one thing, but its license is another issue. Violating it…
Florian Klämpfl wrote 8 lines
Am 07.02.2015 um 12:14 schrieb Jonas Maebe: > To me, the optimal solution would be to simply use libffi (you would > only need logic to translate the rtti for the parameter types to libffi > format, and it would automagically work for all platforms), but since > that's an external dependency I guess that's not acceptable. Well, the technical aspect is one thing, but its license is another issue. Violating it happens too quick.

The libffi license is basically a BSD license, that's no problem at all: https://github.com/atgreen/libffi/blob/master/LICENSE

Jonas

Reply by email

Florian Klämpfl
to Jonas Maebe
Jonas Maebe wrote 11 lines
On 07/02/15 12:34, Florian Klämpfl wrote: > Am 07.02.2015 um 12:14 schrieb Jonas Maebe: >> To me, the optimal solution would be to simply use libffi (you would >> only need logic to translate the rtti for the parameter types to libffi >> format, and it would automagically work for all platforms), but since >> that's an external dependency I guess that's not acceptable. > > Well, the technical aspect is one thing, but its license is another issue. Violating it happens too > quick. The libffi license is basically a BSD license,

This is already the issue :)

that's no problem at all:

There is imo a big one: just compiling a small program containing libffi and give it to another person without a libffi copyright notice is a license violation.

Using libffi in core parts of the rtl would mean even the smallest fpc program would need to come with a libffi copyright notice either by a readme or some command line option to display copyrights.

Reply by email

Sven Barth
to patspiper: arm-winCE and arm-android? Stephano
patspiper wrote 23 lines
On 07/02/15 13:30, Sven Barth wrote: > On 07.02.2015 12:10, Maciej Izak wrote: >> Ehm. It's unfair. I arleady posted some time ago that "Invoke" is done >> for windows by me... Then you posted that we need version for all >> platforms... Double standards in community? :\ > > It's a bit hard to keep the overview when volunteers from outside are > working without communicating with us. That was the first update I > read from Steve since he said that he's going to work on extended RTTI > a few months back and to be frankly honest: I simply forgot your mail > from the fifth (or do you mean a different one?) among my normal daily > work. So I'm sorry if it came of as having double standards we're just > human beings after all... > > Would you please elaborate what exactly you are working on? Maybe we > can find synergies between your work and Steve's. > > And of course we need a cross platform solution. It won't work for us > to have it just for Windows. At least the main platforms i386-win32, > x86_64-win64, i386-linux, x86_64-linux, i386-darwin and x86_64-darwin > should be covered. Immediately followed by arm-linux and arm-darwin > with aarch64-darwin not so far behind I suspect... Though most work > should be per CPU-platform and not per-target anyway...

Considering calling conventions arm-android and arm-linux are the same. And if arm-wince doesn't have any special differences to other arm targets like e.g. x86_64-win64 does in comparison to other x86_64 targets then this should be solved together with arm-linux as well. As I said: it's mostly CPU specific stuff. So if one target of the platform works the others should work as well as long as they use the same calling conventions.

Regards,
Sven

Reply by email

Sven Barth
to Florian Klämpfl: That's why I propose that people do they work in a branch of the central svn :) That was…
Florian Klämpfl wrote 10 lines
Am 07.02.2015 um 12:30 schrieb Sven Barth: > On 07.02.2015 12:10, Maciej Izak wrote: >> Ehm. It's unfair. I arleady posted some time ago that "Invoke" is done >> for windows by me... Then you posted that we need version for all >> platforms... Double standards in community? :\ > > It's a bit hard to keep the overview when volunteers from outside are working without communicating > with us. That's why I propose that people do they work in a branch of the central svn :)

Agreed.

Regards,
Sven

Reply by email

Michael Van Canneyt
to Jonas Maebe: The libffi license is basically a BSD license, that's no problem at all:…
Jonas Maebe wrote 12 lines
On 07/02/15 12:34, Florian Klämpfl wrote: > Am 07.02.2015 um 12:14 schrieb Jonas Maebe: >> To me, the optimal solution would be to simply use libffi (you would >> only need logic to translate the rtti for the parameter types to libffi >> format, and it would automagically work for all platforms), but since >> that's an external dependency I guess that's not acceptable. > > Well, the technical aspect is one thing, but its license is another issue. Violating it happens too > quick. The libffi license is basically a BSD license, that's no problem at all: https://github.com/atgreen/libffi/blob/master/LICENSE

I am not a proponent of third-party dependencies.

Then, there is a practical issue:
I doubt libffi knows the Delphi calling conventions and the pascal calling convention where the callee clears the stack (or was it vice versa)? Since that is our main target group, I consider this a serious problem.

Thirdly, from looking at the use of this library, you will have to implement some kind of layer in between anyway that describes the function, so I do not really see the gain.

Michael.

Reply by email

Michael Van Canneyt
to Jonas Maebe: The main issue I see with that is that this format changes from time to time. I'll…
Jonas Maebe wrote 6 lines
On 07/02/15 11:58, Florian Klämpfl wrote: > Just an idea: What about serializing TCGPara/TCGParalocation? The main issue I see with that is that this format changes from time to time. I'll probably have to change it again to fully support the ppc64le ABI.

Nevertheless, Florian's proposal seems to me like the optimal solution.

As far as I can see the compiler just needs to simply write a small block with the needed info in the generated executable. The RTL just needs to match this.

That this changes from time to time, I consider much less of a problem. The .ppu files also change regularly, that is just how things are...

As soon as a new platform appears you need to wait for libffi etc; the correct version needs to be installed and whatnot. I doubt this will cause less problems.

Michael.

Reply by email

Jonas Maebe
to Florian Klämpfl: This is already the issue :) There is imo a big one: just compiling a small program…
Florian Klämpfl wrote 6 lines
Am 07.02.2015 um 13:07 schrieb Jonas Maebe: There is imo a big one: just compiling a small program containing libffi and give it to another person without a libffi copyright notice is a license violation. Using libffi in core parts of the rtl would mean even the smallest fpc program would need to come with a libffi copyright notice either by a readme or some command line option to display copyrights.

Then I would like at least a "manager-style" solution (like with the widestring/thread manager). I really do not want to be forced to duplicate this work for every single platform I support. The mess with fcl-res is already bad enough.

Jonas

Reply by email

Jonas Maebe
to Michael Van Canneyt: I am not a proponent of third-party dependencies. Then, there is a practical issue: I…
Michael Van Canneyt wrote 7 lines
On Sat, 7 Feb 2015, Jonas Maebe wrote: > The libffi license is basically a BSD license, that's no problem at all: > https://github.com/atgreen/libffi/blob/master/LICENSE I am not a proponent of third-party dependencies.

I am not a proponent of reimplementing everything but the kitchen sink because of other people's adversity to reusing existing solutions.

Show quoted text 5 lines
Then, there is a practical issue: I doubt libffi knows the Delphi calling conventions and the pascal calling convention where the callee clears the stack (or was it vice versa)? Since that is our main target group, I consider this a serious problem.

It does support those calling conventions.

Thirdly, from looking at the use of this library, you will have to implement some kind of layer in between anyway that describes the function, so I do not really see the gain.

The gain is that you implement this once and it will work for all platforms, rather than that you have to reimplement it for every single architecture (and depending on the implementation: every single calling convention too) combination that we support.

Jonas

Reply by email

Florian Klämpfl
to Jonas Maebe
Jonas Maebe wrote 11 lines
On 07/02/15 13:19, Michael Van Canneyt wrote: > > On Sat, 7 Feb 2015, Jonas Maebe wrote: > >> The libffi license is basically a BSD license, that's no problem at all: >> https://github.com/atgreen/libffi/blob/master/LICENSE > > I am not a proponent of third-party dependencies. I am not a proponent of reimplementing everything but the kitchen sink because of other people's adversity to reusing existing solutions.

Indeed, but even leaving the very unpleasant license aside, depending on third party libraries depending on libc is an issue on linux and an even bigger issue on windows not to mention rare platforms like amiga or msdos. While using libffi might work for the platforms you are mainly using, for most other platforms third party dependencies are a pain.

Reply by email

Michael Van Canneyt
to Jonas Maebe: I am not a proponent of reimplementing everything but the kitchen sink because of other…
Jonas Maebe wrote 11 lines
On 07/02/15 13:19, Michael Van Canneyt wrote: > > On Sat, 7 Feb 2015, Jonas Maebe wrote: > >> The libffi license is basically a BSD license, that's no problem at all: >> https://github.com/atgreen/libffi/blob/master/LICENSE > > I am not a proponent of third-party dependencies. I am not a proponent of reimplementing everything but the kitchen sink because of other people's adversity to reusing existing solutions.

I don't mind reusing existing solutions, I often do so.

But keeping dependencies on external libs to a minimum is also a concern.

Show quoted text 7 lines
> Then, there is a practical issue: > I doubt libffi knows the Delphi calling conventions and the pascal > calling convention where the callee clears the stack (or was it vice > versa)? Since that is our main target group, I consider this a serious > problem. It does support those calling conventions.

Well.
Prior to posting my statement, I checked, and it is not in the list of supported architectures.

But diving in the source I see it is indeed supported. OK, that alleviates this problem.

At least I suggest that if this path is taken, then it is done using a 'manager' approach such as for the rest of functionality that introduces a dependency. This allows to re-use the work of Steve without external dependencies on common (read: x86) platforms, and maybe implement native solutions for some common platforms, for people that want it.

Michael.

Reply by email

Michael Van Canneyt
to Florian Klämpfl: Indeed, but even leaving the very unpleasant license aside, depending on third party…
Florian Klämpfl wrote 17 lines
Am 07.02.2015 um 13:59 schrieb Jonas Maebe: > On 07/02/15 13:19, Michael Van Canneyt wrote: >> >> On Sat, 7 Feb 2015, Jonas Maebe wrote: >> >>> The libffi license is basically a BSD license, that's no problem at all: >>> https://github.com/atgreen/libffi/blob/master/LICENSE >> >> I am not a proponent of third-party dependencies. > > I am not a proponent of reimplementing everything but the kitchen sink > because of other people's adversity to reusing existing solutions. Indeed, but even leaving the very unpleasant license aside, depending on third party libraries depending on libc is an issue on linux and an even bigger issue on windows not to mention rare platforms like amiga or msdos. While using libffi might work for the platforms you are mainly using, for most other platforms third party dependencies are a pain.

My point too.

Michael.

Reply by email

Sven Barth
to Michael Van Canneyt: Nevertheless, Florian's proposal seems to me like the optimal solution. As far as I can…
Michael Van Canneyt wrote 23 lines
On Sat, 7 Feb 2015, Jonas Maebe wrote: > On 07/02/15 11:58, Florian Klämpfl wrote: >> Just an idea: What about serializing TCGPara/TCGParalocation? > > The main issue I see with that is that this format changes from time to > time. I'll probably have to change it again to fully support the ppc64le > ABI. Nevertheless, Florian's proposal seems to me like the optimal solution. As far as I can see the compiler just needs to simply write a small block with the needed info in the generated executable. The RTL just needs to match this. That this changes from time to time, I consider much less of a problem. The .ppu files also change regularly, that is just how things are... As soon as a new platform appears you need to wait for libffi etc; the correct version needs to be installed and whatnot. I doubt this will cause less problems.

Considering that we aren't the fastest to implement new platforms I don't think that this will be much of a problem.

Looking at their site I noticed however that there are a few platforms that we support that they don't. For example m68k-amiga, i8086-msdos, arm-wince and some of the more exotic targets that we have (GBA, NDS, Wii for example).

So in the end a manager approach as Jonas suggested might be the best approach. Then we can for now implement the main platforms using libffi and implement full FPC ones one at a time.
Of course we need to assure that all necessary information can be provided to the manager and if that should mean that we'll need to divert from Delphi's RTTI format more then so be it.

Regards,
Sven

Reply by email

Marco van de Voort
to Michael Van Canneyt: I am not a proponent of third-party dependencies. Then, there is a practical issue: I…

In our previous episode, Michael Van Canneyt said:

I am not a proponent of third-party dependencies.

(and specially not since we would depend on their RTTI format for this. This is more than something like mysql where a new header can be fixed with a header fix, as soon as the new ffi is default, functionality is broken in old FPC versions)

Reply by email

Florian Klämpfl
to Sven Barth: Considering that we aren't the fastest to implement new platforms I don't think that this…
Sven Barth wrote 27 lines
On 07.02.2015 13:54, Michael Van Canneyt wrote: > > > On Sat, 7 Feb 2015, Jonas Maebe wrote: > >> On 07/02/15 11:58, Florian Klämpfl wrote: >>> Just an idea: What about serializing TCGPara/TCGParalocation? >> >> The main issue I see with that is that this format changes from time to >> time. I'll probably have to change it again to fully support the ppc64le >> ABI. > > Nevertheless, Florian's proposal seems to me like the optimal solution. > > As far as I can see the compiler just needs to simply write a small > block with the needed info in the generated executable. The RTL just > needs to match this. > > That this changes from time to time, I consider much less of a problem. > The .ppu files also change regularly, that is just how things are... > > As soon as a new platform appears you need to wait for libffi etc; > the correct version needs to be installed and whatnot. I doubt this will > cause less problems. Considering that we aren't the fastest to implement new platforms I don't think that this will be much of a problem.

Actually, FPC had win64 support before gcc/binutils.

Show quoted text 7 lines
Looking at their site I noticed however that there are a few platforms that we support that they don't. For example m68k-amiga, i8086-msdos, arm-wince and some of the more exotic targets that we have (GBA, NDS, Wii for example). So in the end a manager approach as Jonas suggested might be the best approach. Then we can for now implement the main platforms using libffi and implement full FPC ones one at a time.

As long as we have no realiable approach to prevent people to violate the libffi license, I wouldn't recommend to do so. Besides this I do not want either that every FPC compiled binary needs to come with a libffi license text.

Of course we need to assure that all necessary information can be provided to the manager and if that should mean that we'll need to divert from Delphi's RTTI format more then so be it.

Reply by email

Sven Barth
to Michael Van Canneyt: I don't mind reusing existing solutions, I often do so. But keeping dependencies on…
Michael Van Canneyt wrote 32 lines
On Sat, 7 Feb 2015, Jonas Maebe wrote: > On 07/02/15 13:19, Michael Van Canneyt wrote: >> >> On Sat, 7 Feb 2015, Jonas Maebe wrote: >> >>> The libffi license is basically a BSD license, that's no problem at >>> all: >>> https://github.com/atgreen/libffi/blob/master/LICENSE >> >> I am not a proponent of third-party dependencies. > > I am not a proponent of reimplementing everything but the kitchen sink > because of other people's adversity to reusing existing solutions. I don't mind reusing existing solutions, I often do so. But keeping dependencies on external libs to a minimum is also a concern. >> Then, there is a practical issue: >> I doubt libffi knows the Delphi calling conventions and the pascal >> calling convention where the callee clears the stack (or was it vice >> versa)? Since that is our main target group, I consider this a serious >> problem. > > It does support those calling conventions. Well. Prior to posting my statement, I checked, and it is not in the list of supported architectures.

"Delphi" is not an architecture. The "register" calling convention is part of the x86 support. If you look at $ffisrc/src/x86/ffitarget.h you'll notice a FFI_REGISTER variable which is the default Delphi calling convention.

Regards,
Sven

Reply by email

Sven Barth
to Florian Klämpfl: Actually, FPC had win64 support before gcc/binutils. As long as we have no realiable…
Florian Klämpfl wrote 30 lines
Am 07.02.2015 um 14:17 schrieb Sven Barth: > On 07.02.2015 13:54, Michael Van Canneyt wrote: >> >> >> On Sat, 7 Feb 2015, Jonas Maebe wrote: >> >>> On 07/02/15 11:58, Florian Klämpfl wrote: >>>> Just an idea: What about serializing TCGPara/TCGParalocation? >>> >>> The main issue I see with that is that this format changes from time to >>> time. I'll probably have to change it again to fully support the ppc64le >>> ABI. >> >> Nevertheless, Florian's proposal seems to me like the optimal solution. >> >> As far as I can see the compiler just needs to simply write a small >> block with the needed info in the generated executable. The RTL just >> needs to match this. >> >> That this changes from time to time, I consider much less of a problem. >> The .ppu files also change regularly, that is just how things are... >> >> As soon as a new platform appears you need to wait for libffi etc; >> the correct version needs to be installed and whatnot. I doubt this will >> cause less problems. > > Considering that we aren't the fastest to implement new platforms I don't think that this will be > much of a problem. Actually, FPC had win64 support before gcc/binutils.

Yes, that was one of the glorious exception that I still like to quote when talking about Free Pascal :D

But other then that we aren't normally the first to implement a platform...

Show quoted text 11 lines
> > Looking at their site I noticed however that there are a few platforms that we support that they > don't. For example m68k-amiga, i8086-msdos, arm-wince and some of the more exotic targets that we > have (GBA, NDS, Wii for example). > > So in the end a manager approach as Jonas suggested might be the best approach. Then we can for now > implement the main platforms using libffi and implement full FPC ones one at a time. As long as we have no realiable approach to prevent people to violate the libffi license, I wouldn't recommend to do so. Besides this I do not want either that every FPC compiled binary needs to come with a libffi license text.

Yes, the license might be the biggest problem here...

Regards,
Sven

Reply by email

Michael Van Canneyt
to Sven Barth: "Delphi" is not an architecture. The "register" calling convention is part of the x86…
Sven Barth wrote 12 lines
>>> versa)? Since that is our main target group, I consider this a serious >>> problem. >> >> It does support those calling conventions. > > Well. > Prior to posting my statement, I checked, and it is not in the list of > supported architectures. "Delphi" is not an architecture. The "register" calling convention is part of the x86 support. If you look at $ffisrc/src/x86/ffitarget.h you'll notice a FFI_REGISTER variable which is the default Delphi calling convention.

Yes, I had done so, that is what I meant with 'diving in the sources'.

Michael.

Reply by email

Michael Van Canneyt
to Sven Barth: Yes, that was one of the glorious exception that I still like to quote when talking about…
Sven Barth wrote 12 lines
>> So in the end a manager approach as Jonas suggested might be the best >> approach. Then we can for now >> implement the main platforms using libffi and implement full FPC ones one >> at a time. > > As long as we have no realiable approach to prevent people to violate the > libffi license, I wouldn't > recommend to do so. Besides this I do not want either that every FPC > compiled binary needs to come > with a libffi license text. Yes, the license might be the biggest problem here...

Forgive me my ignorance:
Where does it say that you need to ship the license with the binary ?

Michael.

Reply by email

Florian Klämpfl
to Michael Van Canneyt
Michael Van Canneyt wrote 15 lines
On Sat, 7 Feb 2015, Sven Barth wrote: >>> So in the end a manager approach as Jonas suggested might be the best approach. Then we can for now >>> implement the main platforms using libffi and implement full FPC ones one at a time. >> >> As long as we have no realiable approach to prevent people to violate the libffi license, I wouldn't >> recommend to do so. Besides this I do not want either that every FPC compiled binary needs to come >> with a libffi license text. > > Yes, the license might be the biggest problem here... Forgive me my ignorance: Where does it say that you need to ship the license with the binary ?

https://github.com/atgreen/libffi/blob/master/LICENSE

"software" means probably binary as well as source code.

Reply by email

Sven Barth
to Michael Van Canneyt: Yes, I had done so, that is what I meant with 'diving in the sources'. Michael.
Michael Van Canneyt wrote 19 lines
On Sat, 7 Feb 2015, Sven Barth wrote: >>>> versa)? Since that is our main target group, I consider this a serious >>>> problem. >>> >>> It does support those calling conventions. >> >> Well. >> Prior to posting my statement, I checked, and it is not in the list of >> supported architectures. > > "Delphi" is not an architecture. The "register" calling convention is > part of the x86 support. If you look at $ffisrc/src/x86/ffitarget.h > you'll notice a FFI_REGISTER variable which is the default Delphi > calling convention. Yes, I had done so, that is what I meant with 'diving in the sources'.

Ah, sorry. Somehow I had skipped the paragraph where you said that *blush*

Regards,
Sven

Reply by email

Marco van de Voort
to Florian Klämpfl: https://github.com/atgreen/libffi/blob/master/LICENSE "software" means probably binary as…

In our previous episode, Florian Kl?mpfl said:

Show quoted text 6 lines
> Forgive me my ignorance: > Where does it say that you need to ship the license with the binary ? https://github.com/atgreen/libffi/blob/master/LICENSE "software" means probably binary as well as source code.

Yes, and that makes it GPL incompatible.

To be honest I'm a bit afraid of the situation where some Debian devel sees Lazarus (that has used .invoke somewhere in the LCL in the future) generating GPL incompatible binaries, including the lazarus binary itself.

I think it is better to simply not support the functionality on some targets/archs then rashly use libffi.

Reply by email

Florian Klämpfl
to Sven Barth: Yes, that was one of the glorious exception that I still like to quote when talking about…
Sven Barth wrote 6 lines
> Actually, FPC had win64 support before gcc/binutils. Yes, that was one of the glorious exception that I still like to quote when talking about Free Pascal :D But other then that we aren't normally the first to implement a platform...

Well, quiet logical if we depend on other utils.

Show quoted text 14 lines
>> >> Looking at their site I noticed however that there are a few platforms that we support that they >> don't. For example m68k-amiga, i8086-msdos, arm-wince and some of the more exotic targets that we >> have (GBA, NDS, Wii for example). >> >> So in the end a manager approach as Jonas suggested might be the best approach. Then we can for now >> implement the main platforms using libffi and implement full FPC ones one at a time. > > As long as we have no realiable approach to prevent people to violate the libffi license, I wouldn't > recommend to do so. Besides this I do not want either that every FPC compiled binary needs to come > with a libffi license text. Yes, the license might be the biggest problem here...

But not the only one, libgdb is a good example what the issue with external libraries in core parts of FPC. Typical procedure before release building for win32: try randomly mingw and gdb versions to find a pair which compiles a libgdb *and* results in an IDE with a working debugger. Unfortunaly, even if everything runs at a first glance, there is no guarantee that things work flawless as before because something in the C header could have changed causing random crashes. 700 lines defines and ifdefs (!) at the start of gdbint.pp tell the story.

Reply by email

Jonas Maebe
to Florian Klämpfl: Indeed, but even leaving the very unpleasant license aside, depending on third party…
Florian Klämpfl wrote 16 lines
Am 07.02.2015 um 13:59 schrieb Jonas Maebe: > On 07/02/15 13:19, Michael Van Canneyt wrote: >> >> On Sat, 7 Feb 2015, Jonas Maebe wrote: >> >>> The libffi license is basically a BSD license, that's no problem at all: >>> https://github.com/atgreen/libffi/blob/master/LICENSE >> >> I am not a proponent of third-party dependencies. > > I am not a proponent of reimplementing everything but the kitchen sink > because of other people's adversity to reusing existing solutions. Indeed, but even leaving the very unpleasant license aside, depending on third party libraries depending on libc is an issue on linux and an even bigger issue on windows not to mention rare platforms like amiga or msdos.

Then these rare platforms can use something else, that's why I proposed a manager-style solution. And in spite of all the comments in the previous thread regarding cthreads/cwstring, I did not see a single point that argued that simply having a dependency on libc (especially via something as basic and portable as libffi) would cause problems other than for cross-compiling, even on Linux. It does not depend on particular versioned libc functionality, and this is not 199x anymore where even the name of the Linux (g)libc library was changed every full moon.

Besides, many FPC programs for Linux already depend directly or indirectly on libc anyway via the LCL, cthreads, cwstring, clocale, database units and whatnot. I really think the fear of problems due to this is way overblown (and note that I'm not proposing to have a complete RTL always based on libc — which was another misunderstanding raised in that previous thread; I'm just talking about making use of certain extra functionality used via C libraries).

While using libffi might work for the platforms you are mainly using, for most other platforms third party dependencies are a pain.

What would be a pain is that every time I want to modify something to the implementation of the parameter manager, I would have to go through the RTTI dispatch code of all of our platforms to fix them up (because I know how frustrating it is to have your platform broken all the time if other people change things; that's also why I implemented the codepage-aware functionality for all platforms at the same time, or at least tried to make sure that those changes didn't break them).

What would also be a pain is that every time I add support for a new platform, I would have to implement and debug the parameter loading/dispatching code twice: once in the compiler and once in the RTL.

Regarding some of the other remarks:
* Florian
- libgdb is an officially *unsupported* and extremely low level and very OS-dependent interface to GDB. The problems with using that library are related to specifically depending on that, library not on depending on C libraries in general. I fully agree it's a mess, which is one of the reasons I never even tried to get it working on Mac OS X.
* Marco
- the libffi license is not GPL-incompatible. The requirement to ship the license with binaries is also in the modified BSD license, which is GPL-compatible per the FSF.
- Their "rtti" consists basically of integers of various sizes, arrays, structs (which are plain arrays of elements) and pointers. You can't get more basic than that, and we already have to convert everything down to that level inside the compiler anyway to map Pascal types to the official platform ABIs. It is nevertheless true that an API version change in libffi could break compatibility with existing programs, so you would have to ship libffi together with your program if you'd want to avoid that.
* Michael:
- support for "register" and "pascal" calling conventions is listed in libffi's readme (https://github.com/atgreen/libffi/blob/master/README )
- "As far as I can see the compiler just needs to simply write a small block with the needed info in the generated executable. The RTL just needs to match this. .. That this changes from time to time, I consider much less of a problem. The .ppu files also change regularly, that is just how things are..." -- I think that is quite an insensitive statement, because you won't be the one that will need to make such a change or fix things as a consequence. And it's by no means comparable to a ppu file change. It's only "a fact of life" that such a change would have huge consequences if we choose so.

Look at the code of libffi (or better, don't — see below): we would basically have to duplicate all of that code for the platforms we support into the RTL, since all it does is dispatching and that's exactly what we need. Well, not duplicate, since then we have the same licensing issue as using that library — we have to implement it from scratch without looking at its source code. And in case of x86-64, you won't even be able to base yourself on the compiler source code, because I translated the libffi code largely into Pascal to implement its parameter manager. Seriously: it would mean I can't use libffi anymore for my compiler work, or not work on the dispatching code in the RTL for the same platform. Which means that I either cannot do complete ports by myself anymore, or I cannot make use of the knowledge in libffi when doing so (I also looked a lot at libffi for AArch64, so I won't be able to work on RTL dispatching code for that platform either, even if I wanted to).

Just like I may not be sensitive enough to people's issues with external dependencies on some platforms, I'd like to ask other people to be more sensitive to the work required to add and maintain support for a particular platform in FPC (both compiler and RTL).

Jonas

Reply by email

Marco van de Voort
to Jonas Maebe

In our previous episode, Jonas Maebe said:

Show quoted text 6 lines
> Indeed, but even leaving the very unpleasant license aside, depending on third party libraries > depending on libc is an issue on linux and an even bigger issue on windows not to mention rare > platforms like amiga or msdos. Then these rare platforms can use something else, that's why I proposed a manager-style solution.

That is not a solution, it is moving the problem from you to target maintainers who need to deal with the versioning problems and getting it into distributions.

Just like you don't like maintaining multiple params, I'm not interesting in gettting saddled with an perpetual pain because of dependencies. Getting recent versions to the user, by distribution or own compilation means is hard enough.

So IMHO native solution for invoke, or just don't support it for the target is good enough for me.

Show quoted text 8 lines
And in spite of all the comments in the previous thread regarding cthreads/cwstring, I did not see a single point that argued that simply having a dependency on libc (especially via something as basic and portable as libffi) would cause problems other than for cross-compiling, even on Linux. It does not depend on particular versioned libc functionality, and this is not 199x anymore where even the name of the Linux (g)libc library was changed every full moon.

If the policy is abandonned, it should be done because sb invested time in FPC_USE_LIBC solutions and guided the relevant targets through the change.

Then, with real feedback on issues a decision could be taken.

Such decision of a long standing policy should not be done because of some immediate need of ffi.

Moreover, my ffi weariness is not just because it links to libc, but because of the dependency and breakage of that package too. I don't feel like managing this for such a little feature.

Besides, many FPC programs for Linux already depend directly or indirectly on libc anyway via the LCL, cthreads, cwstring, clocale, database units and whatnot.

But do they distribute cross binary releases (like our .tar) that need to be good for a while?

I'm not against that, but it shouldn't be done rashly, and is unrelated to the ffi yes or no.

which was another misunderstanding raised in that previous thread; I'm just talking about making use of certain extra functionality used via C libraries).

No, you are also talking about having to manage those dependencies in the release process. The release cycles are slow and complicated enough, I don't need anything making it worse.

Show quoted text 7 lines
What would be a pain is that every time I want to modify something to the implementation of the parameter manager, I would have to go through the RTTI dispatch code of all of our platforms to fix them up (because I know how frustrating it is to have your platform broken all the time if other people change things; that's also why I implemented the codepage-aware functionality for all platforms at the same time, or at least tried to make sure that those changes didn't break them).

If the FFI metadata changes you must massively update everything too, and worse, existing releases are suddenly void for new distributions.

- the libffi license is not GPL-incompatible. The requirement to ship the license with binaries is also in the modified BSD license, which is GPL-compatible per the FSF.

True.

Show quoted text 8 lines
- Their "rtti" consists basically of integers of various sizes, arrays, structs (which are plain arrays of elements) and pointers. You can't get more basic than that, and we already have to convert everything down to that level inside the compiler anyway to map Pascal types to the official platform ABIs. It is nevertheless true that an API version change in libffi could break compatibility with existing programs, so you would have to ship libffi together with your program if you'd want to avoid that.

Pushing it on the user is IMHO a nono. They can barely manage building now.

Just like I may not be sensitive enough to people's issues with external dependencies on some platforms, I'd like to ask other people to be more sensitive to the work required to add and maintain support for a particular platform in FPC (both compiler and RTL).

So don't do it. You effectively offer FFI as a crutch. Don't offer the crutch, and keep it native or not on a per target basis.

If you can't afford to add a target just leave it and mark it as such in the documentation.

Reply by email

Jonas Maebe
to Marco van de Voort
Marco van de Voort wrote 12 lines
In our previous episode, Jonas Maebe said: >> Indeed, but even leaving the very unpleasant license aside, depending on third party libraries >> depending on libc is an issue on linux and an even bigger issue on windows not to mention rare >> platforms like amiga or msdos. > > Then these rare platforms can use something else, that's why I proposed > a manager-style solution. That is not a solution, it is moving the problem from you to target maintainers who need to deal with the versioning problems and getting it into distributions.

It is not "moving the problem", it's at most changing one problem into a completely different one. And libffi is probably already in all distributions, because it's used by a.o. CPython and OpenJDK.

So IMHO native solution for invoke, or just don't support it for the target is good enough for me.

That is however unacceptable to me. If it is considered basic functionality (which RTTI is, afaik), then it must be implemented for at least all main targets.

Show quoted text 11 lines
> And in spite of all the comments in the > previous thread regarding cthreads/cwstring, I did not see a single > point that argued that simply having a dependency on libc (especially > via something as basic and portable as libffi) would cause problems > other than for cross-compiling, even on Linux. It does not depend on > particular versioned libc functionality, and this is not 199x anymore > where even the name of the Linux (g)libc library was changed every full > moon. If the policy is abandonned, it should be done because sb invested time in FPC_USE_LIBC solutions and guided the relevant targets through the change.

I explicitly mentioned later on that I did not argue in favour of making the entire RTL libc-based. I'm talking about the rule that nothing at all can depend on libc whatsoever.

Such decision of a long standing policy should not be done because of some immediate need of ffi.

There have been cthreads, cwstring and clocale before. And there will undoubtedly be more in the future. And as mentioned, a manager approach is fine by me.

Moreover, my ffi weariness is not just because it links to libc, but because of the dependency and breakage of that package too. I don't feel like managing this for such a little feature.

I don't feel like reimplementing and mainting the parameter manager in the RTL for "such a little feature" either.

Show quoted text 6 lines
> Besides, many FPC programs for Linux already depend directly or > indirectly on libc anyway via the LCL, cthreads, cwstring, clocale, > database units and whatnot. But do they distribute cross binary releases (like our .tar) that need to be good for a while?

The compiler wouldn't depend on libffi if it's implemented via a manager, because the compiler itself won't make use of that functionality. Should it ever do so anyway, we'll cross that bridge when we get there (although I can't immediately think of a practical scenario where we would want to do that). Someone could even implement an "fplibffi" then if they'd want to, like fpwidestring.

Show quoted text 9 lines
> What would be a pain is that every time I want to modify something to > the implementation of the parameter manager, I would have to go through > the RTTI dispatch code of all of our platforms to fix them up (because I > know how frustrating it is to have your platform broken all the time if > other people change things; that's also why I implemented the > codepage-aware functionality for all platforms at the same time, or at > least tried to make sure that those changes didn't break them). If the FFI metadata changes you must massively update everything too,

No, that's my main point: even if that would happen, then you only have to update things in one place (the mapping from our generic RTTI to libffi's generic parameter description). While if things would change in the compiler when you have a Pascal implementation for every platform, then you possibly have to change this Pascal implementation for every platform.

Show quoted text 10 lines
> - Their "rtti" consists basically of integers of various sizes, arrays, > structs (which are plain arrays of elements) and pointers. You can't get > more basic than that, and we already have to convert everything down to > that level inside the compiler anyway to map Pascal types to the > official platform ABIs. It is nevertheless true that an API version > change in libffi could break compatibility with existing programs, so > you would have to ship libffi together with your program if you'd want > to avoid that. Pushing it on the user is IMHO a nono. They can barely manage building now.

"The user" already has to deal with this for every single Lazarus program.

Show quoted text 7 lines
> Just like I may not be sensitive enough to people's issues with external > dependencies on some platforms, I'd like to ask other people to be more > sensitive to the work required to add and maintain support for a > particular platform in FPC (both compiler and RTL). So don't do it. You effectively offer FFI as a crutch. Don't offer the crutch, and keep it native or not on a per target basis.

Using a library as intended is not a crutch.

If you can't afford to add a target just leave it and mark it as such in the documentation.

Which won't confuse or annoy users at all...

Jonas

Reply by email

Michael Van Canneyt
to Arnaud Bouchez: Just to be clear, because it sounds like there is some confusion in the discussion. About…
Arnaud Bouchez wrote 16 lines
Just to be clear, because it sounds like there is some confusion in the discussion. About http://bugs.freepascal.org/view.php?id=26774 1. We do NOT need Invoke() implemented. 2. We do NOT need extended RTTI as available since Delphi 2010, nor features like attributes. 3. We do NOT need 100% compatibility with Delphi - it is fine to have some diverse data layout. 4. There should not be huge platform specific work. Because: 1. We have our own low-level Invoke, for x86 and x64 platforms, working on both Windows and Linux.

That may be so, but if we implement a solution, we don't want people to have to redo everything you did.

So we prefer to implement invoke as part of the process.

Michael.

Reply by email

Michael Van Canneyt
to Jonas Maebe: It is not "moving the problem", it's at most changing one problem into a completely…
Jonas Maebe wrote 6 lines
> Such decision of a long standing policy should not be done because of some > immediate need of ffi. There have been cthreads, cwstring and clocale before. And there will undoubtedly be more in the future. And as mentioned, a manager approach is fine by me.

For me, that is good enough. It leaves open the possibility of native implementations. Given that Arnaud has an implementation for x86 and x64 (windows/linux), that can be used to implement a manager implementation for these platforms, this covers the main platforms. Most likely some other people will implement the calls for other platforms.

I don't see how this case differs from cthreads, clocale or cwstring: Like always, we offer the choice.

Michael.

Reply by email

Maciej Izak
to Sven Barth: It's a bit hard to keep the overview when volunteers from outside are working without…

2015-02-07 12:30 GMT+01:00 Sven Barth :

Show quoted text 5 lines
Would you please elaborate what exactly you are working on? Maybe we can find synergies between your work and Steve's.

I checked my old code from 2006 (!) : my invoke implementation is affected by PascalScript BSD like license :\ ... So my implementation is useless.

My current work is probably useless too - now I am working on new operators to make this fast TValue implementation multiplatform:

http://www.cromis.net/blog/2013/02/tanyvalue-an-attempt-to-make-the-best-variable-data-container/

To achieve this I need to create new special record operators:

====== code begin ======
{$MODESWITCH MANAGEMENTOPERATORS}
  TValue = record
    ...
    class operator Initialize(Data, TypeInfo: Pointer): pointer;
    class operator Finalize(Data, TypeInfo: Pointer): pointer;
    class operator Copy(Source, Dest, TypeInfo: Pointer): pointer;
  end;
====== code end ======

Regards,

Maciej Izak ()

Reply by email

Sven Barth
to Maciej Izak: 2015-02-07 12:30 GMT+01:00 Sven Barth : I checked my old code from 2006 (!) : my invoke…
"Maciej Izak" wrote 12 lines
To achieve this I need to create new special record operators: ====== code begin ====== {$MODESWITCH MANAGEMENTOPERATORS} TValue = record ... class operator Initialize(Data, TypeInfo: Pointer): pointer; class operator Finalize(Data, TypeInfo: Pointer): pointer; class operator Copy(Source, Dest, TypeInfo: Pointer): pointer; end; ====== code end ======

This is /really/ bad design. If you want such operators they would need to be defined like this:

  TValue = record
    ...
    class operator Initialize(var aRec: TValue);
   class operator Finalize(var aRec: TValue);
    class operator Copy(constref aSource: TValue; var aDest: TValue);
  end;
====== code end ======

Regards,
Sven

Reply by email

Alfred
to Steve Hildebrandt

Hello Steve, all,

I would like to report 100% success with the latest RTTI patches !!!!

The mORMot framework is now able to use RTTI the same way as under Delphi.
No trickery needed anymore !!

I would like to express my gratitude for the work done by the development-team.
Hopefully this patch will be included soon in trunk.

One (first) request:
Would it be ok to add pfConstRef to the TParamFlag in typinfo.pp ?

One (second) request:
The same RTTI on ARM would also be very welcome.
As stated before, my interest is running mORMot on ARM (e.g. Raspberry Pi[2]).

Many thanks, Alfred.

Reply by email

Steve Hildebrandt
to Alfred
Alfred wrote
Hello Steve, all, I would like to report 100% success with the latest RTTI patches !!!!

Nice to hear.
If anything is not compatible with the information delphi provides please report back to me.

One (first) request: Would it be ok to add pfConstRef to the TParamFlag in typinfo.pp ?

The RTTI should already be generated the enum value was simply missing. See attached Patch.

One (second) request: The same RTTI on ARM would also be very welcome. As stated before, my interest is running mORMot on ARM (e.g. Raspberry Pi[2]).

Since I'm unable to test it myself right now, I could only try to write this blind and let somebody else do the testing.
It would also help to know what calling conventions are supported and how they work if they are not compareable to the i386/x64 ones. (Link to a good documentation or a short write up) The other way this could work is, if somebody with an ARM system takes over and I explain where compiler changes need to be made.

mfg Steve

Reply by email

Alfred
to Steve Hildebrandt

Well. About the non compatible. I can only detect these:

1)
RTTICount: Word; //$FFFF if there is no further info, or the value of Count
I did not see it set to $FFFF in case of missing RTTI. As Delphi reportedly does.
But perhaps this has already been done somewhere else.

But, in my opinion, this is not of much importance

2)
Properties are in front of methods.
This is different from Delphi.
But I know that this cannot be changed.
That would break a whole lot of code !
And again, if you are aware of this: no , for me, this is all ok now !!

And I am willing to test on simple ARM (Pi[2], BBB). If you provide me with code !

Thanks again, Alfred.

------ Origineel bericht ------
Van: "Steve Hildebrandt"
Aan:
Verzonden: 25-2-2015 19:16:17
Onderwerp: Re: [fpc-devel] RTTI interface & variant late binding issue (mORMot)

Show quoted text 28 lines
Am 25.02.2015 um 18:47 schrieb Alfred: >Hello Steve, all, > >I would like to report 100% success with the latest RTTI patches !!!! > Nice to hear. If anything is not compatible with the information delphi provides please report back to me. >One (first) request: >Would it be ok to add pfConstRef to the TParamFlag in typinfo.pp ? > The RTTI should already be generated the enum value was simply missing. See attached Patch. >One (second) request: >The same RTTI on ARM would also be very welcome. >As stated before, my interest is running mORMot on ARM (e.g. Raspberry >Pi[2]). > Since I'm unable to test it myself right now, I could only try to write this blind and let somebody else do the testing. It would also help to know what calling conventions are supported and how they work if they are not compareable to the i386/x64 ones. (Link to a good documentation or a short write up) The other way this could work is, if somebody with an ARM system takes over and I explain where compiler changes need to be made. mfg Steve

Reply by email

Steve Hildebrandt
to Alfred
Alfred wrote 8 lines
Well. About the non compatible. I can only detect these: 1) RTTICount: Word; //$FFFF if there is no further info, or the value of Count I did not see it set to $FFFF in case of missing RTTI. As Delphi reportedly does. But perhaps this has already been done somewhere else. But, in my opinion, this is not of much importance

In my opinion this is never the case the way the RTTI is currently generated so this shouldn't be an issue.

Show quoted text 7 lines
2) Properties are in front of methods. This is different from Delphi. But I know that this cannot be changed. That would break a whole lot of code ! And again, if you are aware of this: no problems at all.
Here the opinion of others would be nice, since the RTTI was partly
generated but not added to "typinfo.pas".
Original:
tkInterface:
               (
                IntfParent: PTypeInfo;
                IntfFlags : TIntfFlagsBase;
                GUID: TGUID;
                IntfUnit: ShortString;
                {
                IntfProps: array of TPropInfo;
                }
               );
//useless since you would not know how many properties there are
Current:
tkInterface:
               (
                IntfParent: PTypeInfo;
                IntfFlags : TIntfFlagsBase;
                GUID: TGUID;
                IntfUnit: ShortString;
                {
                IntfPropCount: Word;
                IntfProps: array[0..IntfPropCount-1] of TPropInfo;
                IntfMethTable : TIntfMethodTable;
                }
               );
//I simply assumed this to be the easier change. Still would break some
code, if property RTTI for interfaces was ever used anywhere.

How would the layout in Delphi look like?

And I am willing to test on simple ARM (Pi[2], BBB). If you provide me with code !

It seemed simple enough see attached Patch.
ParReg: r0-r3=0..3

mfg Steve

Reply by email

Steve Hildebrandt
to Steve Hildebrandt
Steve Hildebrandt wrote 6 lines
Am 25.02.2015 um 20:37 schrieb Alfred: > And I am willing to test on simple ARM (Pi[2], BBB). > If you provide me with code ! It seemed simple enough see attached Patch. ParReg: r0-r3=0..3

Forgot to commit some parts of it sorry.
Also if reg < 255 and off > 0 it is the offset for the register. For example reg=0 and off=4 means upper 32 bit of the mm register 0.

Since this is all experimetal and there is no convention to uphold for the values ParaReg and ParaOff
I'm open to suggestions.

mfg Steve

Reply by email

Steve Hildebrandt
to Steve Hildebrandt
Steve Hildebrandt wrote 15 lines
Am 25.02.2015 um 21:12 schrieb Steve Hildebrandt: > > Am 25.02.2015 um 20:37 schrieb Alfred: >> And I am willing to test on simple ARM (Pi[2], BBB). >> If you provide me with code ! > It seemed simple enough see attached Patch. > ParReg: r0-r3=0..3 Forgot to commit some parts of it sorry. Also if reg < 255 and off > 0 it is the offset for the register. For example reg=0 and off=4 means upper 32 bit of the mm register 0. Since this is all experimetal and there is no convention to uphold for the values ParaReg and ParaOff I'm open to suggestions.

mfg Steve

Reply by email

Alfred
to Steve Hildebrandt

Hello Steve,

After much testing on ARM (RPi2), included a test-program that works on both i386 and ARM, with your RTTI patches.

As you can see, a lot of alignment issues. But its working 100% !!!

(My) Conclusion:
New RTTI info also available now on ARM. And working. Thanks !!

Some alignment problems have to be solved yet.
I hope that the included file gives you some clues.

Thanks, Alfred.

Reply by email

Alfred
to Arnaud Bouchez: Just to be clear, because it sounds like there is some confusion in the discussion. About…

Hello again to all,

I am enjoying variant late binding AND interface RTTI for a while now ! Thanks again !

As far as I know, the patch for RTTI has not yet been included in trunk. But correct me if I am wrong.

I would like to ask to include the RTTI patch for i386 in trunk. With i386 interface RTTI, FPC is on level with Kylix for the RTTI part.

To ease introduction, I would like to suggest to include a new HASINTERFACERTTI flag, which will let the FPC user know, the new RTTI is available for use.

At this moment, it will only be i386.
But I hope also ARM will be included in the trunk. On my Raspberry Pi2, the new RTTI works flawless.

Thanks in advance.

Reply by email

Michael Van Canneyt
to Alfred
Alfred wrote 16 lines
Hello again to all, I am enjoying variant late binding AND interface RTTI for a while now ! Thanks again ! As far as I know, the patch for RTTI has not yet been included in trunk. But correct me if I am wrong. I would like to ask to include the RTTI patch for i386 in trunk. With i386 interface RTTI, FPC is on level with Kylix for the RTTI part. To ease introduction, I would like to suggest to include a new HASINTERFACERTTI flag, which will let the FPC user know, the new RTTI is available for use. At this moment, it will only be i386.

I can't remember when I last used i386 code. Must have been more than 10 years ago.

But I hope also ARM will be included in the trunk. On my Raspberry Pi2, the new RTTI works flawless.

The core developers are divided on the approach to take. Hence it is not yet included. The code is highly non-portable, which means that each platform must be maintained separately. This means additional pressure on people who maintain these other platforms.

The idea is to use a manager approach (as for instance for threads, locale, widestrings) using a libffi wrapper as fallback for platforms for which no native manager is available. (see https://sourceware.org/libffi/)

However this means the RTTI info must be written in a format that can be fed directly to libffi. (or using a conversion routine). In each case, additional work is needed.

My - and Florian Klaempfl's, if I understood correctly - idea is to include what exists, and then modify the code as needed so it can work with libffi. Others fear that this will mean the ffi wrapper will not get written anytime soon.

Michael.

Reply by email

Jonas Maebe
to Michael Van Canneyt
Michael Van Canneyt wrote
My - and Florian Klaempfl's, if I understood correctly - idea is to include what exists, and then modify the code as needed so it can work with libffi. Others fear that this will mean the ffi wrapper will not get written anytime soon.

The entire code will have to be rewritten to add support for any other platform regardless of whether libffi is used or not. I'm not even sure if the current code can work for ARMHF and floating point parameters (which have to be passed in vector registers).

Again: it has nothing to do with libffi in particular, and everything with not being generic (although if it's generic, that will obviously also help a manager/libffi implementation).

Jonas

Reply by email

silvioprog
to Michael Van Canneyt: I can't remember when I last used i386 code. Must have been more than 10 years ago. The…

On Sun, Mar 22, 2015 at 6:38 AM, Michael Van Canneyt <

Show quoted text 42 lines
wrote: On Sun, 22 Mar 2015, Alfred wrote: > Hello again to all, > > I am enjoying variant late binding AND interface RTTI for a while now ! > Thanks again ! > > As far as I know, the patch for RTTI has not yet been included in trunk. > But correct me if I am wrong. > > I would like to ask to include the RTTI patch for i386 in trunk. > With i386 interface RTTI, FPC is on level with Kylix for the RTTI part. > > To ease introduction, I would like to suggest to include a new > HASINTERFACERTTI flag, which will let the FPC user know, the new RTTI is > available for use. > > At this moment, it will only be i386. > I can't remember when I last used i386 code. Must have been more than 10 years ago. But I hope also ARM will be included in the trunk. > On my Raspberry Pi2, the new RTTI works flawless. > The core developers are divided on the approach to take. Hence it is not yet included. The code is highly non-portable, which means that each platform must be maintained separately. This means additional pressure on people who maintain these other platforms. The idea is to use a manager approach (as for instance for threads, locale, widestrings) using a libffi wrapper as fallback for platforms for which no native manager is available. (see https://sourceware.org/libffi/)

It seems that somebody implemented that in FPC:

https://code.google.com/p/la-pe/

Not tested yet.

Show quoted text 10 lines
However this means the RTTI info must be written in a format that can be fed directly to libffi. (or using a conversion routine). In each case, additional work is needed. My - and Florian Klaempfl's, if I understood correctly - idea is to include what exists, and then modify the code as needed so it can work with libffi. Others fear that this will mean the ffi wrapper will not get written anytime soon. Michael.
Silvio Clécio My public projects - github.com/silvioprog

Reply by email

Michael Van Canneyt
to Jonas Maebe: The entire code will have to be rewritten to add support for any other platform…
Jonas Maebe wrote 14 lines
On 22/03/15 10:38, Michael Van Canneyt wrote: > My - and Florian Klaempfl's, if I understood correctly - idea is to > include what exists, and then modify the code as needed so it can work > with libffi. Others fear that this will mean the ffi wrapper will not > get written anytime soon. The entire code will have to be rewritten to add support for any other platform regardless of whether libffi is used or not. I'm not even sure if the current code can work for ARMHF and floating point parameters (which have to be passed in vector registers). Again: it has nothing to do with libffi in particular, and everything with not being generic (although if it's generic, that will obviously also help a manager/libffi implementation).

True. I just used libffi as one way out using a "generic approach".

Michael.

Reply by email

Steve Hildebrandt
to Michael Van Canneyt: I can't remember when I last used i386 code. Must have been more than 10 years ago. The…
Michael Van Canneyt wrote 50 lines
On Sun, 22 Mar 2015, Alfred wrote: > Hello again to all, > > I am enjoying variant late binding AND interface RTTI for a while now ! > Thanks again ! > > As far as I know, the patch for RTTI has not yet been included in trunk. > But correct me if I am wrong. > > I would like to ask to include the RTTI patch for i386 in trunk. > With i386 interface RTTI, FPC is on level with Kylix for the RTTI part. > > To ease introduction, I would like to suggest to include a new > HASINTERFACERTTI flag, which will let the FPC user know, the new RTTI > is available for use. > > At this moment, it will only be i386. I can't remember when I last used i386 code. Must have been more than 10 years ago. > But I hope also ARM will be included in the trunk. > On my Raspberry Pi2, the new RTTI works flawless. The core developers are divided on the approach to take. Hence it is not yet included. The code is highly non-portable, which means that each platform must be maintained separately. This means additional pressure on people who maintain these other platforms. The idea is to use a manager approach (as for instance for threads, locale, widestrings) using a libffi wrapper as fallback for platforms for which no native manager is available. (see https://sourceware.org/libffi/) However this means the RTTI info must be written in a format that can be fed directly to libffi. (or using a conversion routine). In each case, additional work is needed. My - and Florian Klaempfl's, if I understood correctly - idea is to include what exists, and then modify the code as needed so it can work with libffi. Others fear that this will mean the ffi wrapper will not get written anytime soon. Michael.

As I see it there is no generall problem with my approach. While the location(paramgr), the interface(get_para_regoff) and the stored data(reg: Byte; off: LongInt) are worth some discussion, I think whatever kind of manager like approach will be taken, will turn out to be not realy different from what I already did.

procedure get_para_regoff(proccalloption: tproccalloption; paraloc:
pcgparalocation; out reg: Byte; out off: LongInt);

Currently the default implementation does nothing but zero the reg and off. This would be the place for a potential libffi implementation or any "generic" solution chosen.
While leaving the possibility of specific corrections if need be by overriding get_para_regoff.

Maybe it is just me missing the bigger picture, so please correct me if I am wrong.

mfg Steve

Reply by email

Jonas Maebe
to Steve Hildebrandt

Steve Hildebrandt wrote on Mon, 23 Mar 2015:

Show quoted text 12 lines
As I see it there is no generall problem with my approach. While the location(paramgr), the interface(get_para_regoff) and the stored data(reg: Byte; off: LongInt) are worth some discussion, I think whatever kind of manager like approach will be taken, will turn out to be not realy different from what I already did. procedure get_para_regoff(proccalloption: tproccalloption; paraloc: pcgparalocation; out reg: Byte; out off: LongInt); Currently the default implementation does nothing but zero the reg and off. This would be the place for a potential libffi implementation or any "generic" solution chosen.

The encoded information cannot be specific to a particular kind of consumer. The encoding format should be sufficiently generic to be able to represent the data required for all platforms, and to provide all the information required by any implementation that will use this information to call routines. The purpose of "manager" units is plug & play: you just add one to the uses clause of your main program, and it works. It cannot require compiling the entire FPC source tree and all used units with a particular command line option.

Show quoted text 5 lines
While leaving the possibility of specific corrections if need be by overriding get_para_regoff. Maybe it is just me missing the bigger picture, so please correct me if I am wrong.

One example: on some PowerPC64 ABIs, if the last bytes of a record do not fill an entire (64 bit) register (e.g. because 5 bytes are left at the end), they must be passed in most significant bits of that register. In the compiler this is encoded as a "shift value" for that parameter. So you need to be able to encode these shift values in the RTTI.

Custom-encoding everything in a platform-specific way into these reg and offset fields (which then wouldn't have any relation to actual registers or offset values anymore in many cases) would lead to requiring platform-specific decoders in the RTL, which I very much would like to avoid.

I'm also not certain whether over time 255 registers will be enough if you also consider vector registers and all kinds of sub registers that are possible there (single precision scalar, double precision scalar, quad precision scaler (?), 32 bit vector (?), 64 bit vector, 128 bit vector, 256 bit vector -- all times the number of vector parameter registers).

Jonas

Reply by email

Steve Hildebrandt
to Jonas Maebe
Jonas Maebe wrote 24 lines
Steve Hildebrandt wrote on Mon, 23 Mar 2015: > As I see it there is no generall problem with my approach. While the > location(paramgr), the interface(get_para_regoff) and the stored > data(reg: Byte; off: LongInt) are worth some discussion, > I think whatever kind of manager like approach will be taken, will > turn out to be not realy different from what I already did. > > procedure get_para_regoff(proccalloption: tproccalloption; paraloc: > pcgparalocation; out reg: Byte; out off: LongInt); > > Currently the default implementation does nothing but zero the reg > and off. > This would be the place for a potential libffi implementation or any > "generic" solution chosen. The encoded information cannot be specific to a particular kind of consumer. The encoding format should be sufficiently generic to be able to represent the data required for all platforms, and to provide all the information required by any implementation that will use this information to call routines. The purpose of "manager" units is plug & play: you just add one to the uses clause of your main program, and it works. It cannot require compiling the entire FPC source tree and all used units with a particular command line option.

I agree that we need a better format as said above this is worth discussing, but unless someone knows all the edge cases we are unable to design the data format.
The only thing that comes to my mind is either have different RTTI data per platform and generic access, or store all information that is neccessary for all supported platforms.
Adding the manager to the main program, does only one thing it moves the information generation from compile to run time(not so good), while you gain no advantage?
An arm abi manager will be of little use in a win64 program, so there are only 2 implementations of importance fallback and win64. Also there is no aditional cmd option we realy need, since we know what platform we target while generating the RTTI.
Or are you reffering to compilerswitches related to how much RTTI data is generated?

Show quoted text 13 lines
> While leaving the possibility of specific corrections if need be by > overriding get_para_regoff. > > Maybe it is just me missing the bigger picture, so please correct me > if I am wrong. One example: on some PowerPC64 ABIs, if the last bytes of a record do not fill an entire (64 bit) register (e.g. because 5 bytes are left at the end), they must be passed in most significant bits of that register. In the compiler this is encoded as a "shift value" for that parameter. So you need to be able to encode these shift values in the RTTI.

In order to support this you would simply need to open up the interface to suit your needs, e.g. add an additional parameter that defaults to some value if it is of no use.
If another field shift is needed, we can either encode it somhow, store it, or generate it at runtime.

Show quoted text 15 lines
Custom-encoding everything in a platform-specific way into these reg and offset fields (which then wouldn't have any relation to actual registers or offset values anymore in many cases) would lead to requiring platform-specific decoders in the RTL, which I very much would like to avoid. I'm also not certain whether over time 255 registers will be enough if you also consider vector registers and all kinds of sub registers that are possible there (single precision scalar, double precision scalar, quad precision scaler (?), 32 bit vector (?), 64 bit vector, 128 bit vector, 256 bit vector -- all times the number of vector parameter registers). Jonas

if we know we may have more than 255 registers nothings stops us from using a QWord or whatever we need.
This kind of RTTI will need to be interpreted no matter what, all we can do is make this a simple process.
Since supporting things like TValue.invoke, will need an assembler call frame that is written once per platform(if you are lucky you may be able to reuse parts).

As I see it:
we have platform specific data
we need a method for writing this data into the generated RTTI (encoded or raw)
we need a gracefull way of handling not generated data this should happen at compile time

either :
TABIData = record
   {$IF defined(i386) or defined(x64)}
   reg : Byte;
   off : Integer;
   {$ELSE} {$IF defined(ppc64)}
   reg : Byte;
   shift : Byte;
   {$IFEND}
   {$IFEND}
   ....
end;
or:
TABIData = record
case platform of
   i386, arm, x64: (
     reg : Byte;
     off : Integer;
   );
   ppc64: (
     reg : Byte;
     shift : Byte;
   );
end;

mfg Steve

Reply by email

Florian Klämpfl
to Steve Hildebrandt: Here ist the current state of affairs for i386 only right now. The Patches are currently…
Steve Hildebrandt wrote
Here ist the current state of affairs for i386 only right now. The Patches are currently based on

I've created an svn branch for the patches: http://svn.freepascal.org/svn/fpc/branches/interfacertti (if anybody is interested to contribute, just drop me a note so I can create an account with write access to it). I plan to commit the patches Steve submitted so far to this branch. However, I am missing the 0004-... .patch. Did I overlook something or is there simply no patch with number 0004?

Reply by email

Steve Hildebrandt
to Florian Klämpfl
Florian Klämpfl wrote 13 lines
Am 20.02.2015 um 19:21 schrieb Steve Hildebrandt: > Here ist the current state of affairs for i386 only right now. > > The Patches are currently based on I've created an svn branch for the patches: http://svn.freepascal.org/svn/fpc/branches/interfacertti (if anybody is interested to contribute, just drop me a note so I can create an account with write access to it). I plan to commit the patches Steve submitted so far to this branch. However, I am missing the 0004-... .patch. Did I overlook something or is there simply no patch with number 0004? _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Here are all changes I made again.
I would like to have an account.

mfg Steve

Reply by email

Alfred
to Steve Hildebrandt

Please do include me !

I have included the rtti-patch (diff) based on the current (today :
30566) trunk.

Its nothing else than the patch-set from Steve, but with one change:

for k:=0 to def.paras.count-1 do
begin

     para:=tparavarsym(def.paras[k]);
     {note from Alf:}
     {this was in the first patch set by Steve}
     {left out by Steve in the current patch}
     {?}
     {
     if (vo_is_hidden_para in para.varoptions) and not
        (vo_is_self in para.varoptions) then
        continue;
     }

Thanks, Alf.

Reply by email

Steve Hildebrandt
to Alfred
Alfred wrote 17 lines
Please do include me ! I have included the rtti-patch (diff) based on the current (today : 30566) trunk. Its nothing else than the patch-set from Steve, but with one change: for k:=0 to def.paras.count-1 do begin para:=tparavarsym(def.paras[k]); {note from Alf:} {this was in the first patch set by Steve} {left out by Steve in the current patch} {?} { if (vo_is_hidden_para in para.varoptions) and not (vo_is_self in para.varoptions) then continue; } Thanks, Alf.

This was made, when I started actually using the generated RTTI. It was kind of problematic to invoke a method, if you have no information how to pass the self parameter along.

mfg Steve

Reply by email

Steve Hildebrandt
to Steve Hildebrandt
Steve Hildebrandt wrote 25 lines
Am 13.04.2015 um 09:38 schrieb Alfred: > Please do include me ! > I have included the rtti-patch (diff) based on the current (today : > 30566) trunk. > Its nothing else than the patch-set from Steve, but with one change: > for k:=0 to def.paras.count-1 do > begin > para:=tparavarsym(def.paras[k]); > {note from Alf:} > {this was in the first patch set by Steve} > {left out by Steve in the current patch} > {?} > { > if (vo_is_hidden_para in para.varoptions) and not > (vo_is_self in para.varoptions) then > continue; > } > Thanks, Alf. This was made, when I started actually using the generated RTTI. It was kind of problematic to invoke a method, if you have no information how to pass the self parameter along. mfg Steve

I think something got mixed up here.
I got confused and didn't look into things properly, sorry. The Patches are alright as they are, but the unified diff seems incorrect.

+ if (vo_is_hidden_para in para.varoptions) and not
+ (vo_is_self in para.varoptions) then
+ continue;

should be included see "[PATCH 2/6] Added base for Reg/Off calculation to paramgr"

I've also attached a simple test.
If you would rather have a unified diff, I can provide it.

mfg Steve

Reply by email

Alfred
to Steve Hildebrandt

Everything works as expected now (my programs, as well as your recent TestInterfaceRTTI.lpr), if
+ if (vo_is_hidden_para in para.varoptions) and not
+ (vo_is_self in para.varoptions) then
+ continue;
is included in the ncgrtti.pas patch !!
Without it: no success.

I think it would be good to provide a working/correct unified diff against trunk.

With this message, I have included a diff of your patches. Could you please check ?
If correct, this could be the starting point for
http://svn.freepascal.org/svn/fpc/branches/interfacertti

Greetings.

Reply by email