* * *

Author Topic: Compiling existing 32bit FPC Programm for 64Bit  (Read 285 times)

TKoecher

  • Newbie
  • Posts: 2
Compiling existing 32bit FPC Programm for 64Bit
« on: May 18, 2017, 10:13:15 am »
Hey guys,

I got a short (and probably very stupid) question.

We have a couple of FPC programs, made quite simple in FPC (not using Lazerus yet) - ending up in having 32Bit Programs.

Now, we would need the advantage of 64bit of being able to address more Memory (read: extend the clip of ~2Gb to >12GB).
It makes me feel kinda stupid, but I totally fail at this (I'm not the one who made the code either, nor I'm really into programming FPC).

Is there an easy Way to do so, or is this more complicated than I think?
Can you please give me a quick explanation how to archive this?

Thanks!

Bart

  • Hero Member
  • *****
  • Posts: 2655
    • Bart en Mariska's Webstek
Re: Compiling existing 32bit FPC Programm for 64Bit
« Reply #1 on: May 18, 2017, 10:51:51 am »
In compiler optiosn set th eappropriate target and architecture.
This may require you hvae cross-compilers on your system (32->64 bit)

On Windows it as easy as installing the win32->win64 cross compiler, then setting target to Win64, architecture to x86_64 and build.

You need to be aware that in the 32-bit era people used to abuse integers for pointer arithmetic etc.
However on 64-bit Integer is still 32-bit (use Int64/UInt64 for 64-bit), but pointers are 64-bit. You need to use PtrInt or PtrUInt if you want to cast a pointer to an integer-type (not only on 64-bit, but you should do that on all platforms to keep it cross-platform).

So, unfortunately you must study the source code to see if there are possible bugs.

Bart

TKoecher

  • Newbie
  • Posts: 2
Re: Compiling existing 32bit FPC Programm for 64Bit
« Reply #2 on: May 18, 2017, 11:02:19 am »
Thank you!
Sounds good.

The Problem is just one (or a few) really big arrays.
Ar=Array[0..100000,0..100000] of byte;
for example.

Of course 32bit FPC fails on this, as it just overflows its usable ~2GB RAM (32GB Ram Available on the PC, Win7 64bit). Should consume ~10GB.

I'll give it a shoot and see if I get it running.

Btw, you speak about using Lazerus for this, right?

Bart

  • Hero Member
  • *****
  • Posts: 2655
    • Bart en Mariska's Webstek
Re: Compiling existing 32bit FPC Programm for 64Bit
« Reply #3 on: May 18, 2017, 06:19:09 pm »
Btw, you speak about using Lazerus for this, right?

Yes, i did, when referring to how easy it was to set it up.
Using plain fpc, you will have to set target and architecture using commandline parameters (which is what Lazarus does when it calls the compiler).

Bart

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus