#1 2021-03-03 23:34:30

L_VV
Member
Registered: 2020-10-29
Posts: 38

FPC: cannot compile mORMot2 and ZeosLib when using each other

Good Morning!

I can't compile both mormot2 and zeoslib package at the same time, in the case when in the mormot2.lpk 'NOSYNDBZEOS' is _undefined_, and in the zeoslib/src/Zeos.inc 'MORMOT2' is _defined_.
Those mORMot2 wants to use ZeosLib, and vice versa, ZeosLib wants to use mORMot2.
zcomponent package added into the mormot2 package.

When compiling the zdbc package, the ZDbcIntfs unit requires the mormot.core.base unit.
I add into the zdbc package the mormot.core.base.pas file and the mormot2/src/core directory.

Next, the same happens with the unit mormot.db.core.
I add into the zdbc package the mormot.db.core.pas file and the mormot2/src/db directory.

zdbc package is compiled successfully.


Next I compile the mormot2 package.
mormot.db.sql.zeos unit requires the Zeos.inc file.
I add into the package mormot2 (Options / Compiler Options / Paths / Include Files) the zeoslib/src directory.
After that, the mormot2 package is compiled successfully.


It seems that everything is fine, but when I trying to do in Lazarus "Run / Clean Up and Build ...", I get the error:

"mormot.core.datetime.pas(120,34) Fatal: Can't find unit mormot.core.datetime used by mormot.core.text"

Verbose: Compiling zcomponent.pas
Verbose: Compiling /home/data/projects/TestApp/dependencies/fpc_components/3rd_party/zeoslib/src/component/ZAbstractConnection.pas
Verbose: PPU Loading ./lib/zdbc/x86_64-linux/mormot.core.datetime.ppu
Verbose: PPU Source: mormot.core.datetime.pas not found
Verbose: PPU Source: ../mormot.defines.inc not available
Warning: Recompiling mormot.core.datetime, checksum changed for ./lib/zdbc/x86_64-linux/mormot.core.text.ppu
mormot.core.datetime.pas(120,34) Fatal: Can't find unit mormot.core.datetime used by mormot.core.text
Verbose: Compilation aborted
Verbose: /opt/fpcupdeluxe/lazarus_trunk/fpc/bin/x86_64-linux/ppcx64 returned an error exitcode

I can not understand how to fix this situation.
Perhaps the problem in circular references between Mormot2 and Zeoslib packages.
I have surpassed many ways, but I haven't succeeded yet.
This error appears constantly when run "Clean up and Build".

And since the Lazarus IDE rebuild occurs when installing any new component, it is critical...

Offline

#2 2021-03-04 06:51:48

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

Re: FPC: cannot compile mORMot2 and ZeosLib when using each other

There is a circular reference between mormot.core.datatime and mormot.core.text IIRC.
It is from interface/implementation sections, so usually it compiles with no trouble.

Perhaps packages compilation are a bit more tricky about this, and fails to do so when two packages are involved.

One solution may be to not include mormot.core.datetime in ZAbstractConnection.pas.
Try to remove this from the uses clause: it may complain about non inlining, but it may compile.

Offline

#3 2021-03-04 08:17:16

L_VV
Member
Registered: 2020-10-29
Posts: 38

Re: FPC: cannot compile mORMot2 and ZeosLib when using each other

Arnaud, I tried more variants.

It turned out that if you close the current project, and create a new project, then "Clean Up and Build" is performed correctly.


If the current project is re-open, and run "Clean up and Build", then when compiling an error from my previous message occurs.

In dependencies, the project has the mormot2 package.
In addition, there are uses mormot.xxx.yy in the project files.

Apparently, because of this, an error appears.
In fact, triple circular references appears - mormot2 uses zeoslib; zeosLib uses mormot2; the Lazarus project uses mormot2.

But we can't get rid of uses mormot.xxx.yyy in the project, because for this mormot2 was included in the project.


Arnaud, maybe it could be in mORMot2 to do for ZeosLib a certain wrapper unit that will include both mormot.core.datetime and mormot.core.text?

Then ZeosLib in it uses can specify this unit instead of mormot.core.datetime and mormot.core.text, and possibly cyclic dependency will disappear, because in addition to ZeosLib, no one will use this module, and error "mormot.core.datetime.pas(120,34) Fatal: Can't find unit mormot.core.datetime used by mormot.core.text" will disappear too?

Or maybe there is some other solution.

Offline

#4 2021-03-04 09:54:53

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

Re: FPC: cannot compile mORMot2 and ZeosLib when using each other

Perhaps the dependency between datetime and text in mormot.core.* should be removed.
I would try to make some kind of late-binding of functions.

Offline

#5 2021-03-06 23:00:51

L_VV
Member
Registered: 2020-10-29
Posts: 38

Re: FPC: cannot compile mORMot2 and ZeosLib when using each other

Good Morning!

I just wanted to update Lazarus / FPC through FPCUPDeluxe, but got the same error, as I showed early.
Repeated attempt was also completed with the same error:
/lib/zdbc/x86_64-linux/mormot.core.datetime.ppu:mormot.core.datetime.pas(13,101) Fatal: (10022) Can't find unit mormot.core.datetime used by mormot.core.text

fpcupdeluxe: info: LazarusNativeInstaller (GetModule: Lazarus): Lazarus was at revision: 64666
fpcupdeluxe: info: LazarusNativeInstaller (GetModule: Lazarus): Lazarus is now at revision: 64760
fpcupdeluxe: info: Lazarus native builder: Detected source version Lazarus: 2.1.0
fpcupdeluxe: info: Lazarus native builder: Using FPC compiler with version: 3.3.1
fpcupdeluxe: Start of compile error summary.
/lib/zdbc/x86_64-linux/mormot.core.datetime.ppu:mormot.core.datetime.pas(13,101) Fatal: (10022) Can't find unit mormot.core.datetime used by mormot.core.text
(10028) Recompiling mormot.core.datetime, checksum changed for ./lib/zdbc/x86_64-linux/mormot.core.text.ppu
fpcupdeluxe: Start of compile error summary.
Fatal: (1018) Compilation aborted
./lib/zdbc/x86_64-linux/mormot.core.datetime.ppu:mormot.core.datetime.pas(13,101) Fatal: (10022) Can't find unit mormot.core.datetime used by mormot.core.text
fpcupdeluxe: Start of compile error summary.
Error: /opt/fpcupdeluxe/lazarus_trunk/fpc/bin/x86_64-linux/ppcx64 returned an error exitcode
fpcupdeluxe: Start of compile error summary.
Error: (lazarus) Compile package zcomponent 8.0: stopped with exit code 1

I used last trunk versions of the mORMot2 and ZeosLib.

The update was completed successfully only after I temporarily disabled the MORMOT2 define in the ZeosLib.



After the update Lazarus/FPC, I enabled the MORMOT2 define again, and tried to compile sequentially ZeosLib and mORMot2.

The zcomponent package compiled successfully, but when compiling the mormot2 package there was a strange error:
mormot.soa.core.pas(1302,40) Error: Compilation raised exception internally
Error: An unhandled exception occurred at $000000000076E5B8:
Error: EAccessViolation: Access violation

...
mormot.rest.core.pas(3352,63) Hint: Variable "ContentType" of a managed type does not seem to be initialized
mormot.rest.core.pas(3363,13) Note: Call to subroutine "function IdemPChar(p:PUtf8Char;up:PChar):Boolean;" marked as inline is not inlined
mormot.rest.core.pas(3376,13) Note: Call to subroutine "function IdemPChar(p:PUtf8Char;up:PChar):Boolean;" marked as inline is not inlined
mormot.rest.core.pas(3988,26) Hint: Local variable "newOffset" of a managed type does not seem to be initialized
mormot.rest.core.pas(47,3) Hint: Unit "mormot.core.search" not used in mormot.rest.core
Verbose: Compiling /home/data/projects/TaskMachine/dependencies/fpc_components/3rd_party/mORMot2/src/soa/mormot.soa.core.pas
mormot.soa.core.pas(1302,40) Error: Compilation raised exception internally
Error: An unhandled exception occurred at $000000000076E5B8:
Error: EAccessViolation: Access violation
Verbose: Compilation aborted
Debug:   $000000000076E5B8
Debug: 
Verbose: /opt/fpcupdeluxe/lazarus_trunk/fpc/bin/x86_64-linux/ppcx64 returned an error exitcode

After the second try to compile the mormot2 package, another error occurred:
mormot.soa.core.pas(1302,39) Error: Incompatible type for arg no. 1: Got "TServiceContainer", expected "Options"

Verbose: Compiling mormot2.pas
Verbose: Compiling /home/data/projects/TaskMachine/dependencies/fpc_components/3rd_party/mORMot2/src/soa/mormot.soa.core.pas
mormot.soa.core.pas(1302,39) Error: Incompatible type for arg no. 1: Got "TServiceContainer", expected "Options"
mormot.rest.core.pas(1994,17) Hint: Found declaration: ServicesRelease(Options);
mormot.soa.core.pas(1394,20) Hint: Variable "bits" does not seem to be initialized
mormot.soa.core.pas(1404,44) Hint: Local variable "method" of a managed type does not seem to be initialized
mormot.soa.core.pas(1510,21) Hint: Variable "Services" of a managed type does not seem to be initialized
mormot.soa.core.pas(1522,18) Hint: Variable "Names" of a managed type does not seem to be initialized
mormot.soa.core.pas(1537,47) Hint: Local variable "temp" does not seem to be initialized
mormot.soa.core.pas(1782,25) Hint: Local variable "nfo" of a managed type does not seem to be initialized
mormot.soa.core.pas(1834,0) Verbose: There were 1 errors compiling module, stopping
Verbose: Compilation aborted
Verbose: /opt/fpcupdeluxe/lazarus_trunk/fpc/bin/x86_64-linux/ppcx64 returned an error exitcode

It looks like this issue is not related to the problem under discussion, but it is occurred when recompiling the mormot2 package.


Full "Clean Up and Build" in the Lazarus with an open project using Mormot2 leads to the same error as before (Can't find unit mormot.core.datetime used by mormot.core.text).
With a new empty project "Clean Up and Build" is successful.

It's all so inconveniencly...

Arnaud, may be you will have time to look at the possibility of removing dependency between mormot.core.datetime and mormot.core.text?

Offline

#6 2021-03-07 12:08:02

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

Re: FPC: cannot compile mORMot2 and ZeosLib when using each other

I have removed the circular dependency.
https://github.com/synopse/mORMot2/comm … 1c0130c4c9

Now the date/time functions are available from TTextWriter from mormot.core.json and not from TBaseWriter.
Just use TTextWriter instead of TBaseWriter for mORMot 2 code.

Offline

#7 2021-03-07 12:58:57

L_VV
Member
Registered: 2020-10-29
Posts: 38

Re: FPC: cannot compile mORMot2 and ZeosLib when using each other

Arnaud, now everything compiles without errors smile

Through FPCupDeluxe, Lazarus is successfully updated to the trunk version.

The full "Clean Up and Build" is also executed without errors, even with an open project using mORMot2.

Thank you very much!

Offline

Board footer

Powered by FluxBB