8

I have an x86_64 library on my Mac compiled by GCC, and I want to link it with Pascal code compiled with Free Pascal 2.4. What options do I give to fpc to make it generate 64-bit code? Without any options, I only get 32-bit .o files.

I'm using the fpc-2.4.0.intel-macosx.dmg download from SourceForge, but when I run fpc -i, the only target Macintosh platform it lists is "Darwin for i386," although the 2.4 release notes say it can target "64-bit Mac OS X (x86_64/ppc64)."

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467

2 Answers2

10

According to Jonas Maebe on the fpc-pascal mailing list, there are two options:

  • Run fpc with the -Px86_64 option. (The -P option does not appear to be documented yet.)
  • Run ppcx64 directly instead of fpc. (Without any options, fpc runs ppc386 instead.)

Both worked for me.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
  • A bit late, but: -P is documented in the buildfaq http://www.stack.nl/~marcov/buildfaq.pdf note that it is a "fpc" parameter, not a "ppc" parameter – Marco van de Voort Nov 12 '10 at 22:09
  • There are several things going against that document, @Marco. One, according to Google, only two pages in the world link to it; your comment makes 3. Two, it's hosted on your personal site rather than freepascal.org. Three, it's a PDF instead of Web-friendly HTML. Four, despite its name, it's not really in FAQ format. Five, anyone who's not compiling FPC itself (like me) would have no reason to read it at all. And six, it *mentions* `-P`, but does not *document* it. To really be documented, `fpc -h` and §5.1 of the user manual (especially §5.1.4) need to say that `-P` exists and what it does. – Rob Kennedy Nov 12 '10 at 22:44
  • 1
    1. it is linked on the "more information" page on the FPC site. 2. True, but that is mostly also because it is out-of-bounds with releases 3. http://www.stack.nl/~marcov/buildfaq/ 4. Read the intro, it grew out of a faq document. 5. It is the only document somewhat completely documenting crosscompiling, which is considered an advanced topic (read faq intro again). I'm telling you like it is, not how it should be 6a. fpc -h shows the actual compiler help, and it has no own help. 6b. wouldn't be bad, but again that is how you would want it, not wat is. – Marco van de Voort Nov 13 '10 at 17:07
0

Use -m64.

Actually, the GNU Pascal documentation does not even state that it is supported on Mac OS X. FreePascal, on the other hand, works on all Mac OS X variants (Intel and PPC, 32 and 64 bits).

F'x
  • 12,105
  • 7
  • 71
  • 123
  • 1
    Although `fpc` doesn't say it doesn't recognize that option (even though it's undocumented), it also has no effect on the output. The .o files it generates are still 32-bit files. Did I somehow give you the impression that I was looking for an option to give to GCC? I'm not. I already have 64-bit object code from GCC. I'm trying to link it with code compiled by Free Pascal, but to do that, I need Free Pascal to generate 64-bit object files. GNU Pascal doesn't even enter the picture, so whether it's supported on Macintosh is irrelevant. – Rob Kennedy Mar 10 '10 at 15:59