Recent

Author Topic: Building FPC 3.3.1 on maOS 12.3 on a Mac Mini M1  (Read 1138 times)

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 298
Building FPC 3.3.1 on maOS 12.3 on a Mac Mini M1
« on: March 17, 2022, 09:36:54 pm »
I'm using the page at https://wiki.freepascal.org/Installing_Lazarus_on_macOS#Installing_from_source, in particular the section headed `FPC development version` to install FPC 3.3.1.

The thing that concerns me is that the instructions to actually perform the make, `make distclean all FPC=/usr/local/lib/fpc/3.2.2/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64 OPT="-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/"` seems to refer to the old Intel architecture.

Is there a change I can make to CPU_TARGET to make it target the ARM chip?
"It builds... ship it!"

macOS 12.3 Monterey
Lazarus 2.3.0 (from src)
FPC 3.3.1 (from src)

Josh

  • Hero Member
  • *****
  • Posts: 996
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 298
Re: Building FPC 3.3.1 on maOS 12.3 on a Mac Mini M1
« Reply #2 on: March 17, 2022, 09:50:37 pm »
Sorted, I think. I ran `fpcmake` which automatically generated the appropriate make file.

I then issued the command `make distclean all FPC=/usr/local/lib/fpc/3.2.2/ppcx64 OS_TARGET=darwin CPU_TARGET=aarch64 OPT="-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/"

Note the `CPU_TARGET=aarch64`. Seems to have done the trick. I've still to build and install Lazarus, but what can possibly go wrong now? 😉
"It builds... ship it!"

macOS 12.3 Monterey
Lazarus 2.3.0 (from src)
FPC 3.3.1 (from src)

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 298
Re: Building FPC 3.3.1 on maOS 12.3 on a Mac Mini M1
« Reply #3 on: March 17, 2022, 09:53:47 pm »
have you read this? it may help.

https://wiki.freepascal.org/macOS_Big_Sur_changes_for_developers#ARM64.2FAArch64.2FApple_Silicon_Support

Thanks for that josh. It looks like my solution was partly right but maybe missed off some details. I'll retrace my steps and follow your link to the letter. Thanks, again!
"It builds... ship it!"

macOS 12.3 Monterey
Lazarus 2.3.0 (from src)
FPC 3.3.1 (from src)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1988
  • Former Delphi 1-7, 10.2 user
Re: Building FPC 3.3.1 on maOS 12.3 on a Mac Mini M1
« Reply #4 on: March 17, 2022, 11:18:07 pm »
I'm using the page at https://wiki.freepascal.org/Installing_Lazarus_on_macOS#Installing_from_source, in particular the section headed `FPC development version` to install FPC 3.3.1.

The thing that concerns me is that the instructions to actually perform the make, `make distclean all FPC=/usr/local/lib/fpc/3.2.2/ppcx64 OS_TARGET=darwin CPU_TARGET=x86_64 OPT="-XR/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/"` seems to refer to the old Intel architecture.

Is there a change I can make to CPU_TARGET to make it target the ARM chip?

You missed the Note at the start of that section:

Quote
Note: When building a native aarch64 Free Pascal Compiler (ppca64) for an Apple Silicon M1 processor Mac, change the CPU_TARGET in the instructions below from x86_64 (Intel 64 bit) to aarch64 (ARM 64 bit - Apple Silicon M1) and change any reference to ppcx64 to ppca64
Lazarus 2.3, FPC 3.3.1 macOS 12.3.1 x86_64 Xcode 13.4
Lazarus 2.3, FPC 3.3.1 macOS 12.3.1 aarch64 Xcode 13.4

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 298
Re: Building FPC 3.3.1 on maOS 12.3 on a Mac Mini M1
« Reply #5 on: March 17, 2022, 11:22:14 pm »
You missed the Note at the start of that section:
Quote
Note: When building a native aarch64 Free Pascal Compiler (ppca64) for an Apple Silicon M1 processor Mac, change the CPU_TARGET in the instructions below from x86_64 (Intel 64 bit) to aarch64 (ARM 64 bit - Apple Silicon M1) and change any reference to ppcx64 to ppca64

Doh! In any case progress has ground to a halt because of ongoing problems at SourceForge 🙁
"It builds... ship it!"

macOS 12.3 Monterey
Lazarus 2.3.0 (from src)
FPC 3.3.1 (from src)

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 298
Re: Building FPC 3.3.1 on maOS 12.3 on a Mac Mini M1
« Reply #6 on: March 18, 2022, 12:25:58 am »
Doh! In any case progress has ground to a halt because of ongoing problems at SourceForge 🙁

The SourceForge problem seems to have passed for now. The one remaining problem I have is that although I have the FPC 3.3.1 source downloaded in `~/fpc_main`, I still need to generate an RTL that is suitable for debugging Lazarus apps.

I'm guessing that I need to find a way to combine the `.inc` files in `./rtl/aarch64` and the `.pp` files in`./rtl/macos`. I could try and do this manually, but I would much rather find an automatic process or some instructions for this, at least.

Any clues?
"It builds... ship it!"

macOS 12.3 Monterey
Lazarus 2.3.0 (from src)
FPC 3.3.1 (from src)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1988
  • Former Delphi 1-7, 10.2 user
Re: Building FPC 3.3.1 on maOS 12.3 on a Mac Mini M1
« Reply #7 on: March 18, 2022, 01:55:42 am »
I believe that if you add OPT="-dDEBUG -glh -gw -godwarfsets -O-" to your FPC build command you will achieve your goal. You may be able to just rebuild the RTL but I've never tried.

Let us know what happens :-)
« Last Edit: March 18, 2022, 02:01:36 am by trev »
Lazarus 2.3, FPC 3.3.1 macOS 12.3.1 x86_64 Xcode 13.4
Lazarus 2.3, FPC 3.3.1 macOS 12.3.1 aarch64 Xcode 13.4

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 298
Re: Building FPC 3.3.1 on maOS 12.3 on a Mac Mini M1
« Reply #8 on: March 18, 2022, 02:36:57 pm »
Trying to follow your instructions, I changed the FPC build command from:
Code: [Select]
sudo make FPC=$PWD/ppca64 OPT="-ap -FD/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin -XR/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" install`
to:
Code: [Select]
`sudo make FPC=$PWD/ppca64 OPT="-dDEBUG -glh -gw -godwarfsets -O-"

Given that the command finished almost instantly and returned this...
Code: [Select]
Targets
all Build a new compiler and all packages
install Install newly build files
zipinstall Create zip/tar of installed files
singlezipinstall Alias for zipinstall

...I'm not convinced it worked!

This really is the most frustrating thing, where you have to pick snippets of instructions from various places and just hope against hope that you have pieced it all together in the right order... 😡
« Last Edit: March 18, 2022, 02:41:52 pm by carl_caulkett »
"It builds... ship it!"

macOS 12.3 Monterey
Lazarus 2.3.0 (from src)
FPC 3.3.1 (from src)

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 298
Re: Building FPC 3.3.1 on maOS 12.3 on a Mac Mini M1
« Reply #9 on: March 18, 2022, 03:19:59 pm »
I tweaked things again and tried to combine the original instruction:
Code: [Select]
sudo make FPC=$PWD/ppca64 OPT="-ap -FD/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin -XR/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" install`
with your modification of
Code: [Select]
OPT="-dDEBUG -glh -gw -godwarfsets -O-"
resulting in...
Code: [Select]
make FPC=ppcx64 OPT="-ap -FD/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin -XR/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -dDEBUG -glh -gw -godwarfsets -O-" CPU_TARGET=aarch64 -j 4 FPMAKEOPT="-T 4" all

The net result of all of this, along with a couple of other, entirely non-intuitive tweaks, appears to have resulted in a fully working setup.

Thanks for your help, Josh and Trev!
« Last Edit: March 18, 2022, 04:45:07 pm by carl_caulkett »
"It builds... ship it!"

macOS 12.3 Monterey
Lazarus 2.3.0 (from src)
FPC 3.3.1 (from src)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1988
  • Former Delphi 1-7, 10.2 user
Re: Building FPC 3.3.1 on maOS 12.3 on a Mac Mini M1
« Reply #10 on: March 18, 2022, 11:03:46 pm »
The net result of all of this, along with a couple of other, entirely non-intuitive tweaks, appears to have resulted in a fully working setup.

What were the other "non-intuitive tweaks"? It may help someone in future to know this.
Lazarus 2.3, FPC 3.3.1 macOS 12.3.1 x86_64 Xcode 13.4
Lazarus 2.3, FPC 3.3.1 macOS 12.3.1 aarch64 Xcode 13.4

carl_caulkett

  • Sr. Member
  • ****
  • Posts: 298
Re: Building FPC 3.3.1 on maOS 12.3 on a Mac Mini M1
« Reply #11 on: March 19, 2022, 01:30:06 am »
When Lazarus started, it had these two errors highlighted.

The FPC Sources one was fixed by my browsing to `~/fpc_main` where I had initially cloned the 3.3.1 source, while the one about the `fppkg.cfg` was fixed by my browsing to where the file had newly been created, in my case at `/Users/carlcaulkett/fpc_main/utils/fpcmkcfg/fppkg.cfg`
"It builds... ship it!"

macOS 12.3 Monterey
Lazarus 2.3.0 (from src)
FPC 3.3.1 (from src)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1988
  • Former Delphi 1-7, 10.2 user
Re: Building FPC 3.3.1 on maOS 12.3 on a Mac Mini M1
« Reply #12 on: March 19, 2022, 06:15:15 am »
Oh, those tweaks.

Or, you can simply change the compiler and source code directories in the Lazarus Preferences> Environment - Files dialog. It's a bit easier when using multiple versions, but don't forget which version you've setup (says the voice of experience) !
Lazarus 2.3, FPC 3.3.1 macOS 12.3.1 x86_64 Xcode 13.4
Lazarus 2.3, FPC 3.3.1 macOS 12.3.1 aarch64 Xcode 13.4

 

TinyPortal © 2005-2018