#1 2020-05-16 12:42:43

array81
Member
From: Italy
Registered: 2010-07-23
Posts: 411

Cannot compile last timeline version

After a long time I have try to upgrade my Synopse with last timeline version (2020-05-14 16:06:21).

On Delphi 10.3 I get these errors:

[dcc32 Error] SyNodeRemoteDebugger.pas(224): E2003 Undeclared identifier: 'SafePush'
[dcc32 Error] SyNodeRemoteDebugger.pas(525): E2003 Undeclared identifier: 'SafePush'
[dcc32 Error] SyNodeRemoteDebugger.pas(602): E2003 Undeclared identifier: 'SafeClear'
[dcc32 Error] SyNodeRemoteDebugger.pas(603): E2003 Undeclared identifier: 'SafeClear'
[dcc32 Error] SyNodeRemoteDebugger.pas(620): E2010 Incompatible types: 'TRawUTF8ListLocked' and 'TRawUTF8List'
[dcc32 Error] SyNodeRemoteDebugger.pas(621): E2010 Incompatible types: 'TRawUTF8ListLocked' and 'TRawUTF8List'
[dcc32 Error] SyNodeRemoteDebugger.pas(683): E2003 Undeclared identifier: 'SafeClear'
[dcc32 Error] SyNodeRemoteDebugger.pas(684): E2003 Undeclared identifier: 'SafeClear'
[dcc32 Error] SyNodeRemoteDebugger.pas(777): E2003 Undeclared identifier: 'SafePop'
[dcc32 Error] SyNodeRemoteDebugger.pas(777): E2015 Operator not applicable to this operand type
[dcc32 Error] SyNodeRemoteDebugger.pas(777): E2015 Operator not applicable to this operand type
[dcc32 Fatal Error] SyNode.pas(1319): F2063 Could not compile used unit 'SyNodeRemoteDebugger.pas'

Offline

#2 2020-05-17 17:42:36

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

Re: Cannot compile last timeline version

@array81 - wokring SyNode version is currently in feature/synodeCleanup brunch. I try to keep it in sync with master..

Offline

#3 2020-05-19 21:21:59

array81
Member
From: Italy
Registered: 2010-07-23
Posts: 411

Re: Cannot compile last timeline version

mpv wrote:

@array81 - wokring SyNode version is currently in feature/synodeCleanup brunch. I try to keep it in sync with master..

I have try to use https://github.com/synopse/mORMot/tree/ … odeCleanup but this is the result:

[dcc32 Error] SpiderMonkey.pas(600): E2398 Class methods in record types must be static
[dcc32 Error] SpiderMonkey.pas(601): E2398 Class methods in record types must be static
[dcc32 Error] SpiderMonkey.pas(602): E2398 Class methods in record types must be static
[dcc32 Error] SpiderMonkey.pas(603): E2398 Class methods in record types must be static
[dcc32 Error] SpiderMonkey.pas(604): E2398 Class methods in record types must be static
[dcc32 Error] SpiderMonkey.pas(605): E2398 Class methods in record types must be static
[dcc32 Error] SpiderMonkey.pas(606): E2398 Class methods in record types must be static
[dcc32 Error] SpiderMonkey.pas(607): E2398 Class methods in record types must be static
[dcc32 Error] SpiderMonkey.pas(609): E2398 Class methods in record types must be static
[dcc32 Error] SpiderMonkey.pas(2026): E1030 Invalid compiler directive: 'external'
[dcc32 Error] SpiderMonkey.pas(2026): E2029 ',' or ':' expected but identifier 'name' found
[dcc32 Error] SpiderMonkey.pas(2028): E2070 Unknown directive: 'JS_DisableExtraThreads'
[dcc32 Error] SpiderMonkey.pas(2029): E2004 Identifier redeclared: 'external'
[dcc32 Error] SpiderMonkey.pas(2029): E2029 ',' or ':' expected but identifier 'name' found
[dcc32 Error] SpiderMonkey.pas(2043): E2029 Type expected but 'TYPE' found
[dcc32 Error] SpiderMonkey.pas(2044): E1030 Invalid compiler directive: 'external'
[dcc32 Error] SpiderMonkey.pas(2044): E2029 ',' or ':' expected but identifier 'name' found
[dcc32 Error] SpiderMonkey.pas(2047): E2029 Type expected but 'TYPE' found
[dcc32 Error] SpiderMonkey.pas(2048): E1030 Invalid compiler directive: 'external'
[dcc32 Error] SpiderMonkey.pas(2048): E2029 ',' or ':' expected but identifier 'name' found
[dcc32 Error] SpiderMonkey.pas(2051): E2029 Type expected but 'TYPE' found
[dcc32 Error] SpiderMonkey.pas(2052): E1030 Invalid compiler directive: 'external'
[dcc32 Error] SpiderMonkey.pas(2052): E2029 ',' or ':' expected but identifier 'name' found
[dcc32 Error] SpiderMonkey.pas(2055): E2029 Type expected but 'TYPE' found
[dcc32 Error] SpiderMonkey.pas(2056): E1030 Invalid compiler directive: 'external'
[dcc32 Error] SpiderMonkey.pas(2056): E2029 ',' or ':' expected but identifier 'name' found
[dcc32 Error] SpiderMonkey.pas(2060): E2029 Type expected but 'TYPE' found
[dcc32 Error] SpiderMonkey.pas(2061): E1030 Invalid compiler directive: 'external'
[dcc32 Error] SpiderMonkey.pas(2061): E2029 ',' or ':' expected but identifier 'name' found
[dcc32 Error] SpiderMonkey.pas(2065): E2029 Type expected but 'TYPE' found
[dcc32 Error] SpiderMonkey.pas(2066): E1030 Invalid compiler directive: 'external'
[dcc32 Error] SpiderMonkey.pas(2066): E2029 ',' or ':' expected but identifier 'name' found
[dcc32 Error] SpiderMonkey.pas(2069): E2029 Type expected but 'TYPE' found
[dcc32 Error] SpiderMonkey.pas(2072): E1030 Invalid compiler directive: 'external'
[dcc32 Error] SpiderMonkey.pas(2072): E2029 ',' or ':' expected but identifier 'name' found
[dcc32 Error] SpiderMonkey.pas(2074): E2029 Type expected but 'TYPE' found
[dcc32 Error] SpiderMonkey.pas(2075): E1030 Invalid compiler directive: 'external'
[dcc32 Error] SpiderMonkey.pas(2075): E2029 ',' or ':' expected but identifier 'name' found
[dcc32 Fatal Error] SpiderMonkey.pas(2075): E2226 Compilation terminated; too many errors

Offline

#4 2020-06-02 18:02:28

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

Re: Cannot compile last timeline version

The only supported targets for this brunch is FPC 3.2.0 x64 Linux (cross compile to Windows). Sorry, I don’t have the resources to support anything else

Offline

#5 2020-08-16 14:10:37

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

Re: Cannot compile last timeline version

Is there any news on this ? As @array81 reported, latest mORMot and SyNode are incompatible with each other when Delphi is used.

Offline

#6 2020-08-16 17:22:42

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

Re: Cannot compile last timeline version

The following regex could be helpful to alleviate the burden to support Delphi compatibility of SpiderMonkey.pas

(?gs)type\s([_A-Za-z]+)\s*=\s*(function|procedure)(.*?cdecl;)\s*var(\s[_A-Za-z]+):\s*([_A-Za-z]+)\s(external.*?;)

See also the online tester

Offline

#7 2020-08-17 06:03:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,072
Website

Re: Cannot compile last timeline version

Nice rexex!

cool

Offline

#8 2020-08-17 10:27:42

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

Re: Cannot compile last timeline version

I can resolve an error "Class methods in record types must be static" - it's not a problem.

Problem is about E1030 Invalid compiler directive: 'external'

SpiderMonkey itself is a C++, so we need to export a C++ function as a cdecl.
To avoid unnecessary function call we export a variable what contains pointer to a C++ function from our wrapper - see synsm.h line 10 for example as such:

extern "C" {
  JS_PUBLIC_API(bool) (*SM_Initialize)(void) = &JS_Init;

SM_Initialize is a pointer to a function.

And when import it in the SpiderMonkey.pas using

type TJS_Initialize = function : Boolean; cdecl;
var JS_Init: TJS_Initialize external SpiderMonkeyLib name 'SM_Initialize';

I don't know how to do such in Delphi.

Last edited by mpv (2020-08-17 10:29:30)

Offline

#9 2020-08-17 11:19:56

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

Re: Cannot compile last timeline version

If the following two code blocks are equivalent to each other, the regex posted above could be used to automatically transform the hundreds of declarations in SpiderMonkey.pas big_smile

current

type TJS_Initialize = function : Boolean; cdecl;
var JS_Init: TJS_Initialize external SpiderMonkeyLib name 'SM_Initialize';

Delphi compatible

function SM_Initialize: Boolean; cdecl; external SpiderMonkeyLib name 'SM_Initialize';
type TJS_Initialize = function : Boolean; cdecl;
var JS_Init: TJS_Initialize = SM_Initialize; // external SpiderMonkeyLib name 'SM_Initialize';

Last edited by ComingNine (2020-08-17 11:21:14)

Offline

#10 2020-08-17 12:47:04

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

Re: Cannot compile last timeline version

@ComingNine - `SM_Initialize` exported by SpiderMonkeyLib is a pointer to function, not a function. So

function SM_Initialize: Boolean; cdecl; external SpiderMonkeyLib name 'SM_Initialize';

not works (at last in FPC I got AV).
Did you verify your code in Delphi? It's work?

Offline

#11 2020-08-17 13:13:41

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

Re: Cannot compile last timeline version

Thank you for your efforts ! IIRC, to realize a pointer to external function in Delphi (and FPC as well), one does not use external keyword but SafeLoadLibrary followed by GetProcAddress. I have to try and return.

Last edited by ComingNine (2020-08-17 13:14:27)

Offline

#12 2025-07-02 09:45:12

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

Re: Cannot compile last timeline version

mpv wrote:

...
To avoid unnecessary function call we export a variable what contains pointer to a C++ function from our wrapper - see synsm.h line 10 for example as such:

extern "C" {
  JS_PUBLIC_API(bool) (*SM_Initialize)(void) = &JS_Init;

SM_Initialize is a pointer to a function.
...

Could you help to suggest how to build your wrapper SynSM.sln ?
When I open the solution in Visual Studio 2015, there are many errors that are related to includes. For example, "jspubtd.h" cannot resolve "#include "mozilla/Assertions.h"". In the file system, "Assertions.h" is under "mozilla-esr52\mfbt\Assertions.h" not "mozilla"... This seems to be a rather basic problem, since the instructions to build SpiderMonkey itself works, but I am not familiar with C++ or SpiderMonkey. Could you suggest what one needs to do to proceed ? Many thanks !

Last edited by ComingNine (2025-07-02 09:49:59)

Offline

#13 2025-07-02 12:38:44

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

Re: Cannot compile last timeline version

The last time I compiled this was in 2020. I'll be at my workstation at the end of July, so I can take a look. Unfortunately, I couldn't do it before

Offline

#14 2025-07-02 14:14:22

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

Re: Cannot compile last timeline version

mpv wrote:

The last time I compiled this was in 2020. I'll be at my workstation at the end of July, so I can take a look. Unfortunately, I couldn't do it before

It is so great to hear from you ! smile

That will be more than good enough ! big_smile Many thanks !

Last edited by ComingNine (2025-07-02 14:15:00)

Offline

#15 Yesterday 16:16:14

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

Re: Cannot compile last timeline version

ComingNine wrote:
mpv wrote:

...
To avoid unnecessary function call we export a variable what contains pointer to a C++ function from our wrapper - see synsm.h line 10 for example as such:

extern "C" {
  JS_PUBLIC_API(bool) (*SM_Initialize)(void) = &JS_Init;

SM_Initialize is a pointer to a function.
...

Could you help to suggest how to build your wrapper SynSM.sln ?
When I open the solution in Visual Studio 2015, there are many errors that are related to includes. For example, "jspubtd.h" cannot resolve "#include "mozilla/Assertions.h"". In the file system, "Assertions.h" is under "mozilla-esr52\mfbt\Assertions.h" not "mozilla"... This seems to be a rather basic problem, since the instructions to build SpiderMonkey itself works, but I am not familiar with C++ or SpiderMonkey. Could you suggest what one needs to do to proceed ? Many thanks !

It seems that one can build SynSM.sln under windows following your how-to : D
One just needs to pay attention to some minor issues.
For example, when one follows the build SM52 how-to, put --disable-shared-js to the configure command line.
The js_static.lib is required for SynSM.sln.
Furthermore, during the mozbuild process, the include files required by SynSM.sln will be put under the i686-mingw/dist.

Offline

#16 Yesterday 16:32:28

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

Re: Cannot compile last timeline version

mpv wrote:

I can resolve an error "Class methods in record types must be static" - it's not a problem.

Problem is about E1030 Invalid compiler directive: 'external'

SpiderMonkey itself is a C++, so we need to export a C++ function as a cdecl.
To avoid unnecessary function call we export a variable what contains pointer to a C++ function from our wrapper - see synsm.h line 10 for example as such:

extern "C" {
  JS_PUBLIC_API(bool) (*SM_Initialize)(void) = &JS_Init;

SM_Initialize is a pointer to a function.

And when import it in the SpiderMonkey.pas using

type TJS_Initialize = function : Boolean; cdecl;
var JS_Init: TJS_Initialize external SpiderMonkeyLib name 'SM_Initialize';

I don't know how to do such in Delphi.


It seems that using an explicit SafeLoadLibrary followed by GetProcAddress, one can compile SpiderMonkey.pas in Delphi.

......
    SM52Lib := SafeLoadLibrary(SpiderMonkeyLib);
  Result := SM52Lib <> INVALID_MODULEHANDLE_VALUE;
  if Result then
  begin
    JS_Init := TJS_Initialize(GetProcAddress(SM52Lib, 'SM_Initialize')^);
    JS_ShutDown := TJS_ShutDown(GetProcAddress(SM52Lib, 'SM_ShutDown')^);
.....

The original SpiderMonkey.pas is  https://snips.sh/f/C8cKlLp-nw, the modified SpiderMonkey.pas using an explicit SafeLoadLibrary followed by GetProcAddress is https://snips.sh/f/5MQRzLzUmg.
I made a simple test and it seems to work fine.
Could you help to review and test and consider to incorporate ? : D Many thanks !

Offline

Board footer

Powered by FluxBB