#1 2018-09-12 05:31:51

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Latest mORMot.pas does not compile under latest FPC.

Latest mORMot.pas does not compile using latest FPC for both i386-win32 and x86_64-linux. The line and msg shown are below.

Line 56264:             ParamName := @VMP^.Name;  
mORMot.pas(56264,30) Error: Variable identifier expected

The reason is in FPC 3.3.1-r39711 (installed using fpcupdeluxe), Name becomes a property. NamePtr should be used.

ParamName := VMP^.NamePtr;  

PS: It seems that anonymous cannot create ticket now ? There is no create ticket on the tickets link.

Last edited by ComingNine (2018-09-12 08:09:31)

Offline

#2 2018-09-12 18:09:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Latest mORMot.pas does not compile under latest FPC.

Dup question.

Search the forum first.

Offline

#3 2018-09-16 04:12:46

ComingNine
Member
Registered: 2010-07-29
Posts: 294

Re: Latest mORMot.pas does not compile under latest FPC.

Just curious: do you plan not to fix it ? big_smile

Offline

#4 2018-09-18 06:45:55

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Latest mORMot.pas does not compile under latest FPC.

ComingNine wrote:

Just curious: do you plan not to fix it ? big_smile

I am waiting for this too.  AB gives the best support to an opensource project I have ever seen.  Usually fixes come very fast. If not there is reason.  Maybe his main job requires more of his time now ...  I think we better trust him on task scheduling.

Also this could be an issue which needs to be fixed by the FPC team.

Last edited by Leslie7 (2018-09-18 06:47:04)

Offline

#5 2018-09-18 09:23:48

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Latest mORMot.pas does not compile under latest FPC.

The problem is that FPC trunk - at least in this case. maybe more generally - does not handle  the address operator for a record property with a getter.


This solves the problem and makes sense performance-wise, but directly accessing the underlying pointer may violate a design principle: 

   ParamName := VMP^.NamePtr;

Last edited by Leslie7 (2018-09-18 11:46:34)

Offline

#6 2018-09-18 11:50:47

JD
Member
Registered: 2015-08-20
Posts: 118

Re: Latest mORMot.pas does not compile under latest FPC.

I had the same problem. I keep two versions of Lazarus: NewPascal (with FPC 3.1.1) and Lazarus 1.8.4/FPC 3.0.4 stable on my system. This was OK for me until the Lazarus 1.8.4/FPC 3.0.4 could no longer handle the new TypeInfo changes in the latest version of mORMot (SynFPCTypInfo.pas).

Luckily, I saw on the Lazarus forum a new package Lazarus 1.9/FPC 3.2.0 Beta.

http://forum.lazarus-ide.org/index.php/ … ajilg0#new

https://sourceforge.net/projects/lazaru … ndow%2032/
https://sourceforge.net/projects/lazaru … ndow%2064/

I installed this and it compiled the latest mORMot releases flawlessly; I guess because the FPC compiler is more recent and so has the RTTI changes that NewPascal was created to handle. It also compiled the old code I was keeping Lazarus 1.8.4/FPC 3.0.4 around for.

So it looks like I may move ALL my projects to Lazarus 1.9/FPC 3.2.0 Beta and get rid of my existing NewPascal & Lazarus 1.8.4/FPC 3.0.4 combo.

I encourage you to try it. It may be the solution to your problem.

I can confirm that the line

Line 56267:             ParamName := @VMP^.Name;  

is compiled properly

Cheers,

JD

Last edited by JD (2018-09-18 11:56:26)

Offline

#7 2018-09-20 08:44:57

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 211

Re: Latest mORMot.pas does not compile under latest FPC.

Do you guys use fpcupdeluxe? I have never been able to install anything with that, I always do it manually.

Offline

#8 2018-09-20 08:57:00

JD
Member
Registered: 2015-08-20
Posts: 118

Re: Latest mORMot.pas does not compile under latest FPC.

pvn0 wrote:

Do you guys use fpcupdeluxe? I have never been able to install anything with that, I always do it manually.

I use fpcupdeluxe to test trunk builds and sometimes to install NewPascal. I did not use it in my most recent install because FPC trunk is now 3.3.1 and some have said in this thread that it does not compile the latest mORMot.

That is why I chose to install Lazarus 1.9/FPC 3.2.0 Beta instead which is more recent than NewPascal and does not seem to have the problem associated with FPC trunk.

JD

Last edited by JD (2018-09-20 09:04:18)

Offline

#9 2018-09-20 15:51:33

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Latest mORMot.pas does not compile under latest FPC.

Update: With Lazarus/FPC trunk installed by fpcupdeluxe just now (Lazarus 2.1.0 r59094, FPC 3.3.1), the latest mORMot can be compiled successfully, even cross-compile for linux64!


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#10 2018-09-21 15:01:45

damiand
Member
From: Greece
Registered: 2018-09-21
Posts: 94

Re: Latest mORMot.pas does not compile under latest FPC.

Not in my case, unfortunately. Using fpcupdeluxe with latest Lazarus/FPC trunk (2.1.0/3.3.1 SVN 59094) on Linux Lite 3.8 (based on Ubuntu), the compilation stops in line 56267 of mormot.pas:

ParamName := @VMP^.Name;

with error message:

mORMot.pas(56267,31) Error: Variable identifier expected

I presume that the solution proposed by Leslie7 in post #5 above, as well as in this topic also:

https://synopse.info/forum/viewtopic.php?id=4694

is recommended, isn't it?

Thanks.

Last edited by damiand (2018-09-21 15:12:00)

Offline

#11 2018-09-22 09:27:02

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Latest mORMot.pas does not compile under latest FPC.

Every new commit to the FPC trunk can broke our code (this is developer trunk). Unfortunately there is no stable FPC version what support all features required by mORMot (or I don't know it).

So, in my project a freeze FPC & Lazarus revision - currently to FPC 39623 & Lazarus 58733. I can confirm this combination work for both Win64 & Lin64 with cross-compiling back and forward.

Online

#12 2018-09-22 14:56:43

miab3
Member
From: Poland
Registered: 2014-10-01
Posts: 188

Re: Latest mORMot.pas does not compile under latest FPC.

In fpc 3.3.1 does not work:

ParamName := @VMP^.Name;

neither this:

ParamName := VMP^.Name;

Michal

Last edited by miab3 (2018-09-22 14:57:26)

Offline

#13 2018-09-22 21:19:52

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Latest mORMot.pas does not compile under latest FPC.

miab3,

Until FPC is fixed or there is an official mORMot workaround this solves the problem:

ParamName := VMP^.NamePtr;

Offline

#14 2018-09-25 17:04:18

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Latest mORMot.pas does not compile under latest FPC.

pvn0 wrote:

Do you guys use fpcupdeluxe? I have never been able to install anything with that, I always do it manually.

You can check out the source and run it from the IDE to see where it goes wrong for you:

https://github.com/newpascal/fpcupdeluxe

Offline

#15 2018-09-29 08:14:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Latest mORMot.pas does not compile under latest FPC.

Offline

#16 2018-09-30 06:03:08

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Latest mORMot.pas does not compile under latest FPC.

I confirm the compilation issue's fixed.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#17 2018-09-30 08:52:14

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Latest mORMot.pas does not compile under latest FPC.

AB,

I am curious: since NamePtr is public anyway it would seem obvious to use it directly. What is the point for going through the string property and it's getter to get to a pointer at the end which is already available? FPC ShortString is not reference counted so the getter  returns a new string with a different pointer. Where will the new string be freed? It seems like a potential memory leak. Or if this is intentional and the new string is  freed somewhere properly then  when  VER3_1 is not defined it will free  VMP^.NamePtr^  which is likely to cause problems.

Last edited by Leslie7 (2018-10-01 11:52:22)

Offline

#18 2018-10-11 07:17:23

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Latest mORMot.pas does not compile under latest FPC.

AB,

I think this is worth attention.

Offline

#19 2018-10-11 10:11:31

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Latest mORMot.pas does not compile under latest FPC.

"memory leak" / "free NamePtr^"?
IIRC, this is a shortstring, directly pointing to the executable binary RTTI.

Offline

#20 2018-10-11 16:32:07

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Latest mORMot.pas does not compile under latest FPC.

ab wrote:

"memory leak" / "free NamePtr^"?

That is the gist of it. Either way the the fix is inconsistent, returns  different pointers depending on the compiler directive.

Last edited by Leslie7 (2018-10-11 16:33:20)

Offline

#21 2018-10-11 21:14:42

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Latest mORMot.pas does not compile under latest FPC.

A pointer to a shortstring stored in the code segment of the executable making a memory leak?

Offline

#22 2018-10-12 07:39:52

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Latest mORMot.pas does not compile under latest FPC.

When VER3_1 is defined  the getter for the Name property creates a NEW string and the pointer to this string is used from there, not the original pointer. The question is what happens to this new string, will it ever be freed?

Offline

#23 2018-10-12 10:30:04

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Latest mORMot.pas does not compile under latest FPC.

When VER3_1 is defined, the Name property is not a getter but a field:

      TVmtMethodParam =
...
        Name: ShortString;

For newest versions (3.2 branch), including new trunk, it uses NamePtr safely.
https://github.com/graemeg/freepascal/b … fo.pp#L337

This was the whole point of Michalis patch.
Or perhaps the VER3_1 is not what we expect?

Offline

#24 2018-10-15 19:54:46

michalis
Member
Registered: 2018-05-08
Posts: 2

Re: Latest mORMot.pas does not compile under latest FPC.

See the description of my pull request on https://github.com/synopse/mORMot/pull/133 .

FPC revision 39684 (during FPC 3.3.1 development) changed the way you have to access this information. In FPC revision < 39684, you must use "@VMP^.Name". In FPC revision >= 39684 you must use "VMP^.NamePtr".

The FPC revision 39684 happened during the FPC 3.3.1 development.

The patch from https://github.com/synopse/mORMot/pull/133 assumes that:

- You either use FPC 3.1.1.
- Or you use FPC 3.3.1 with revision >= 39684.

The original poster uses FPC 3.3.1, revision 39711. This should be supported. The VER3_1 should not be defined, and the correct approach ("VMP^.NamePtr") should be used.

(Note: I removed my earlier answer, I made a mistake there smile This answer is correct.)

Offline

#25 2018-10-16 07:04:07

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Latest mORMot.pas does not compile under latest FPC.

Great!

Compiling and running:

begin
  {$ifdef VER3_1} Writeln('This is FPC 3.1.x'); {$endif}
  {$ifdef VER3_3} Writeln('This is FPC 3.3.x'); {$endif}
end.

with FPC 3.3.1:

$ fpc a.pas 
Free Pascal Compiler version 3.3.1-r39838 [2018/09/28] for x86_64
Copyright (c) 1993-2018 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling a.pas
Linking a
4 lines compiled, 0.7 sec
$ ./a
This is FPC 3.3.x

So the patch sounds just fine, and I don't understand what Leslie7 complained about.

Offline

Board footer

Powered by FluxBB