#1 2012-12-11 12:46:51

h.hasenack
Member
From: Nijmegen, Netherlands
Registered: 2012-08-01
Posts: 173
Website

x64 compilation

Hi Ab

I have managed to compile my sqlite3.c into 64 bit .o files. Now I'm trying to compile the Mormot sources into 64 bit dcus, but I'm running into trouble with SynCOmmonspas, regarding the SynLog rouytines.

This piece

var
  /// internal list of created TSynLog instance, one per each log file on disk
  // - do not use directly - necessary for inlining TSynLogFamily.SynLog method
  SynLogFile: TObjectList = nil;

is required at many other places, but is inside a {$ifdef NOEXCEPTIONINTERCEPT} block, causing compilation failes at several places where the global SynLogFile is addressed like:

function TSynLogFamily.CreateSynLog: TSynLog;
var i: integer;
begin
  if SynLogFile=nil then begin
    SynLogFile := TObjectList.Create;
    GarbageCollector.Add(SynLogFile);
  end;
  result := fSynLogClass.Create(self);
  i := SynLogFile.Add(result);
  if fPerThreadLog then
    SynLogFileIndex[fIdent] := i+1 else
    fGlobalLog := result;
end;

Is something wrong with the compiler defines or is it just me not understanding what needs to be done wink

(Using Delphi XE3)

Offline

#2 2012-12-11 13:20:12

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

Re: x64 compilation

Support of 64 bit compilation is not finished nor tested yet.
Latest version of SynCommons.pas should be more prepared for 64 bit compilation, since it includes RtlCaptureStackBackTrace() API calls to retrieve the stack trace.

I've committed some code fix with which setting NOEXCEPTIONINTERCEPT is compiling.
Not fully tested, though.
See http://synopse.info/fossil/info/d2bab10f61

If you can share your experiment with 64 bit SQLite3 linking, you are welcome!

Offline

#3 2012-12-11 13:26:09

h.hasenack
Member
From: Nijmegen, Netherlands
Registered: 2012-08-01
Posts: 173
Website

Re: x64 compilation

I Moved the SYnLog definition outside defenitions  and syncommons compiles well now.
Also I added USETYPEINFO define to x64 compilation

  {$ifdef CPUX64}
    {$define CPU64} // Delphi compiler for 64 bit CPU
    {$undef CPU32}
    {$define PUREPASCAL} // no x86 32 bit asm to be used
    {$define USETYPEINFO}  // in x64 we can onpy use official typeinfo structures
  {$else}

Next I run into trouble with the next code. Do you think my code proposal is valid?

function TSQLPropInfoRTTI.GetFieldAddr(Instance: TObject): pointer;
begin
  if Instance=nil then
    result := nil else
    {$ifndef USETYPEINFO}  // inx64 we can onpy use official typeinfo structures
    result := fPropInfo^.GetFieldAddr(Instance);
    {$else}
    begin
      if NativeInt(fPropInfo^.GetProc)<0 then // high bit set: there is no getter method so it's an offset. (should work in x64 as well as x32)
      begin
        result:=Instance;
        inc(PByte(Result),(integer(NativeInt(fPropInfo^.GetProc)) and $7fffffff));  add the offset to the object base pointer
      end
      else Result:=nil; // return nil for no pointer to data because there's a getter method
    end
    {$endif}
end;

Then again, this code could also be defined in the as a "pure pascal" routine...

{$ifndef USETYPEINFO}
function TPropInfo.GetFieldAddr(Instance: TObject): pointer;
asm
  cmp [eax].TPropInfo.GetProc.Byte[3],$FF // is it a field property?
  mov eax,[eax].TPropInfo.GetProc
  jnz @0
  // field - Getter is the field's offset in the instance data
  and eax,$00FFFFFF
  add eax,edx
  ret
@0:xor eax,eax // method -> return nil
end;
{$endif}

I seem to get a little stuck now. Can I ask you to put some focus on the x64 compilation? If you need I can provide you with a RDP session or Teamviewer session. Just send me an email and we'll find out how.

Hans

Offline

#4 2012-12-11 13:30:35

h.hasenack
Member
From: Nijmegen, Netherlands
Registered: 2012-08-01
Posts: 173
Website

Re: x64 compilation

Yes I am definitely willing to share. I'll keep you posted.

Offline

#5 2012-12-11 16:52:01

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

Re: x64 compilation

I've made some code refactoring, and now trunk includes several fixes for proper PUREPASCAL and USETYPEINFO conditional compilation (targetting 64 bit).
See http://synopse.info/fossil/info/9ff890c4a6
and http://synopse.info/fossil/info/db1f196673

This is a good start to work with in order to fulfill 64 bit compilation.

Offline

#6 2012-12-12 08:24:12

h.hasenack
Member
From: Nijmegen, Netherlands
Registered: 2012-08-01
Posts: 173
Website

Re: x64 compilation

WOnderful. I'll keep you posted!

Offline

Board footer

Powered by FluxBB