Recent

Author Topic: Compiling for OSX from Windows  (Read 1101 times)

Grahame Grieve

  • Full Member
  • ***
  • Posts: 107
Compiling for OSX from Windows
« on: September 28, 2020, 10:12:46 pm »
I'm trying to figure out how to get my win64 install of lazarus to compile for macos. I'm using FPCUPdeluxe, and I have other windows + linux installed. Versions= 2.1.0/3.3.1 and fpcupdeluxe is 1.8.0e.

from FPCUPdeluxe, I assume that darwin = macos?

I choose x64 + darwin, and I get:

    Be forwarned: this will only work with FPC 3.2 / embedded / trunk.

That tells me very little:
*  What's embedded / trunk?
* does 3.2 only mean, not prior to 3.20? or only 3.2?
* does the dialog mean that this will or won't work? will nothing get installed, or 3.2 instead of 3.3.1? or something else?

So say yes anyway, and it proceeds to do a whole bunch of work and says that it succeeded. But then, if I choose x64/macos in Lazarus, it tells me that there's no config for this option

What should I do to be able to compile for OSX from windows?

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1044
  • Former Delphi 1-7, 10.2 User
Re: Compiling for OSX from Windows
« Reply #1 on: September 29, 2020, 04:48:27 am »
Cross-compiling for macOS on Windows is certainly the road less travelled. The Wiki has no instructions for doing this unfortunately.

I believe Don Alfredo, the author of fpcupdeluxe, compiles his macOS binaries on Windows and may be able to offer some insight.

You will of course run into the issue of not being able to test your macOS binaries if you do not have access to an Apple computer.

[Going the other way, macOS to Win32 or to Win64 is trivial in comparison and is what I do. Win binaries are then tested in Parallels VMs.]
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (Parallels VM)

Grahame Grieve

  • Full Member
  • ***
  • Posts: 107
Re: Compiling for OSX from Windows
« Reply #2 on: September 29, 2020, 05:50:02 am »
Well, I'm also working on setting up Lazarus on MacOS. That doesn't seem like a road very well travelled either. Certainly the instructions are obtuse, and/or out of date.

Of course I will need a mac to actually run anything.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1044
  • Former Delphi 1-7, 10.2 User
Re: Compiling for OSX from Windows
« Reply #3 on: September 29, 2020, 07:01:19 am »
Well, I'm also working on setting up Lazarus on MacOS. That doesn't seem like a road very well travelled either. Certainly the instructions are obtuse, and/or out of date.

The instructions for installing Lazarus on macOS are completely up to date. What is obtuse about them?
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (Parallels VM)

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1358
Re: Compiling for OSX from Windows
« Reply #4 on: September 29, 2020, 10:05:25 am »
All fpcup binaries are (cross-)compiled on a Windows 10 machine. Including binaries for macOS (=Darwin).

Embedded is a repo that is in sync with trunk, but with some extras that allow me to build for SAMC and SAMD micro-controllers. So, embedded=trunk.
And you are right: stating just 3.2 is not very clear. It means at least 3.2, including trunk.

So, you are welcome to use fpcupdeluxe to setup FPC and Lazarus and also use it to setup cross-compiling towards macOS. If you encounter issues, please report them on GitHub. I have to restart my work on fpcupdeluxe (have been a bit busy lately), but your issue will be addressed.

Pease note:
At the moment FPC 3.2.1 and newer will not (cross-)build for Darwin i386 anymore due to some incompatible mnemnonics that are generated by the compiler. Due to this issue, my personal build-system at the moment for fpcupdeluxe binaries is based on FPC stable and Lazarus trunk. Both with some minor changes to be able to cross-compile towards all those different architectures.

Edit:
The patches that are used are out in the open.
https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/tag/patches_v1.0
If enabled (in Setup+), the suitable patches will be automagically applied by fpcupdeluxe.
« Last Edit: September 29, 2020, 10:10:06 am by DonAlfredo »

Grahame Grieve

  • Full Member
  • ***
  • Posts: 107
Re: Compiling for OSX from Windows
« Reply #5 on: September 29, 2020, 12:49:16 pm »
Well, I'm not sure what to report. Here's the results out of FOCUPdeluxe:

---------------------------------------------------------------------------------

Going to install a cross-compiler from available sources.
Fpcupdeluxe: FPC cross-builder: Building compiler for darwin-x86_64.
FPCUP(deluxe) is starting up.

Binutils/make dir:     C:\tools\lazarus\fpcbootstrap
Bootstrap dir:         C:\tools\lazarus\fpcbootstrap
FPCupdeluxe basedir:   C:\tools\lazarus
FPC URL:               https://svn.freepascal.org/svn/fpc/trunk
FPC options:           
FPC source directory:  C:\tools\lazarus\fpcsrc
FPC install directory: C:\tools\lazarus\fpc
Lazarus URL:               https://svn.freepascal.org/svn/lazarus/trunk
Lazarus options:           
Lazarus source directory:  C:\tools\lazarus\lazarus
Lazarus install directory: C:\tools\lazarus\lazarus

Please stand back and enjoy !

29/09/2020 6:09:36: fpcupdeluxe: V304 (20200722) started.
FPCUPdeluxe V1.8.0e for x86_64-win64 running on Win64-10.0.18363

... (lots of build)....

fpcupdeluxe: info: FPCCrossInstaller (BuildModuleCustom: FPC): Adding fpc.cfg config snippet for target x86_64-darwin
fpcupdeluxe: info: FPCCrossInstaller (InsertFPCCFGSnippet: fpc.cfg): Found existing snippet in C:\tools\lazarus\fpc\bin\x86_64-win64\fpc.cfg. Replacing it with new version.
fpcupdeluxe: info: FPCCrossInstaller (InsertFPCCFGSnippet: fpc.cfg): Inserting snippet in C:\tools\lazarus\fpc\bin\x86_64-win64\fpc.cfg done.
fpcupdeluxe: info: FPCCrossInstaller (BuildModuleCustom: FPC): Building native compiler for x86_64-darwin finished.
fpcupdeluxe: info: FPCCrossInstaller (BuildModuleCustom: FPC): Removal of stale build files and directories ready.
fpcupdeluxe: info: FPCCrossInstaller (BuildModuleCustom: FPC): Removal of stale build files and directories ready.


SUCCESS: Fpcupdeluxe ended without errors.

---------------------------------------------------------------------------------

So shouldn't that mean that lazarus should be able to compile for MacOS now? Because it just says that it can't. Is there something I can look for?

Grahame Grieve

  • Full Member
  • ***
  • Posts: 107
Re: Compiling for OSX from Windows
« Reply #6 on: September 29, 2020, 12:52:33 pm »
> The instructions for installing Lazarus on macOS are completely up to date

well, for the command line tools, they should just say 'this doesn't work on catalina'.

The real problem, though, is svn. I installed svn using homebrew but it still doesn't work. Which appears to mean that you can only install 3.2.0/2.0.10 on macos via the .git - and I only found any reference to that on the forum somewhere. (I think I need 3.3.1/2.1.0)

I was going to make another post about that in the right group. I created a brand new vanilia catalina to test the install process. Because even after it succeeds for I can't recompile the IDE. But I'll make another post about that

Grahame Grieve

  • Full Member
  • ***
  • Posts: 107
Re: Compiling for OSX from Windows
« Reply #7 on: September 29, 2020, 12:57:39 pm »
> The real problem, though, is svn

That's a problem with FPCUPdeluxe. Not directly with those instructions. Anyway, I'll make another post about MacOS install.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1044
  • Former Delphi 1-7, 10.2 User
Re: Compiling for OSX from Windows
« Reply #8 on: September 29, 2020, 01:00:32 pm »
The real problem, though, is svn. I installed svn using homebrew but it still doesn't work. Which appears to mean that you can only install 3.2.0/2.0.10 on macos via the .git - and I only found any reference to that on the forum somewhere. (I think I need 3.3.1/2.1.0)

The instructions I pointed you to include instructions for using either svn or git. There are also instructions in the same place for installing non-release versions of both Lazarus and Free Pascal.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (Parallels VM)

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1358
Re: Compiling for OSX from Windows
« Reply #9 on: September 29, 2020, 01:40:52 pm »
Quote
So shouldn't that mean that lazarus should be able to compile for MacOS now? Because it just says that it can't. Is there something I can look for?
Yes, it should be able. Please elaborate on this issue.

Grahame Grieve

  • Full Member
  • ***
  • Posts: 107
Re: Compiling for OSX from Windows
« Reply #10 on: September 29, 2020, 09:46:31 pm »
I've attached a screenshot of what happens if I try to choose macos as a compiler target after the fpcupdeluxe run above.

My install directory is C:\tools\lazarus. In C:\tools\lazarus\fpc. I have these folders in there:
x86_64-linux
x86_64-win64
i386-win32
x86_64-darwin

but the C:\tools\lazarus\fpc\bin only has
i386-win32
x86_64-linux
x86_64-win64

Only the x86_64-win64 has an fpc.cfg file. I'm not sure what else to look for
« Last Edit: September 29, 2020, 09:53:15 pm by Grahame Grieve »

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1358
Re: Compiling for OSX from Windows
« Reply #11 on: September 29, 2020, 10:43:27 pm »
Choose Darwin and not macOS !

Grahame Grieve

  • Full Member
  • ***
  • Posts: 107
Re: Compiling for OSX from Windows
« Reply #12 on: September 30, 2020, 12:31:19 am »
oh. What's the difference?

thanks

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1044
  • Former Delphi 1-7, 10.2 User
Re: Compiling for OSX from Windows
« Reply #13 on: September 30, 2020, 01:32:30 am »
oh. What's the difference?

MacOS (more correctly "Mac OS", there never was a "MacOS") = the Classic Mac Operating System developed for the Macintosh family of personal computers by Apple from 1984 to 2001, starting with System 1 and ending with Mac OS 9.

Darwin = the open source BSD UNIX core set of components on which macOS (originally marketed as Mac OS X and then OS X) runs.

o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (Parallels VM)

Grahame Grieve

  • Full Member
  • ***
  • Posts: 107
Re: Compiling for OSX from Windows
« Reply #14 on: September 30, 2020, 02:07:26 am »
well, that's obscure. So now I have another problem, though I don't know whether this is anything to do with FPCUpdeluxe:

32 bit darwin won't install in FPCdeluxe:

C:/tools/lazarus/fpc/bin/x86_64-win64/ppcross386.exe -Ur -dFPC_USE_LIBC -Tdarwin -Pi386 -XPx86_64-apple-darwin15- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../i386 -Fi../unix -Fi../bsd -Fi../bsd/i386 -Fi../darwin/i386 -FDC:\tools\lazarus\cross\bin\x86-darwin -FE. -FUC:/tools/lazarus/fpcsrc/rtl/units/i386-darwin -vw-n-h-l-d-u-t-p-c- -dFPC_SOFT_FPUX80 -di386 -dRELEASE -WM10.8 -XPx86_64-apple-darwin15- -Xd -FlC:\tools\lazarus\cross\lib\x86-darwin\MacOSX10.11.sdk\usr\lib -FlC:\tools\lazarus\cross\lib\x86-darwin\MacOSX10.11.sdk\usr\lib\system  -Us -Sg ../bsd/system.pp
C:\tools\lazarus\fpcsrc\rtl\units\i386-darwin\system.s:10:2: error: instruction requires: Not 64-bit mode
        pushfl
        ^

then many 100s more.

64 bit won't compile in Lazarus:

CarbonBars.pas:

{$IFNDEF cpui386}
{$ERROR only cpu i386 is supported}
{$ENDIF}
             

 

TinyPortal © 2005-2018