Author Topic: Lazarus Release 2.2.0 and macOS aarch64  (Read 834 times)


  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1998
  • Former Delphi 1-7, 10.2 user
Lazarus Release 2.2.0 and macOS aarch64
« on: January 06, 2022, 08:01:04 am »
macOS 12.1 - aarch64 - attempt to rebuild the IDE from within itself fails with:

Build IDE: Exit code 2, Errors: 2
Error: mkdir: ../units/aarch64-darwin/cocoa: Permission denied
make[1]: *** [../units/aarch64-darwin/cocoa] Error 1
Error: make: *** [idepkg] Error 2

Directory permissions as installed:

drwxr-xr-x  3     503  admin  96       2 Jan 21:20 units
drwxr-xr-x  4     503  admin  128     2 Jan 21:22 x86_64-darwin
drwxr-xr-x  896 503  admin  28672  2 Jan 21:24 cocoa

I checked my stable of Mac minis and my user always has an id of 501.

In comparison, my Firefox installation is owned by trev:admin

The workaround:

cd /Applications
sudo chown -R your_username Lazarus

Then I was met with:

make[2]: *** [lazarus] Error 1
make[1]: *** [idepkg] Error 2
Error: make: *** [idepkg] Error 2
Error: resource compiler "fpcres" not found, switching to external mode

The fix for this is to create a .fpc.cfg (note the initial dot) file in your home directory and add these lines to it:

#include /etc/fpc.cfg

so that fpcres can be found where it was installed.

The next hurdle:

make[2]: *** [lazarus] Error 1
make[1]: *** [idepkg] Error 2
Error: make: *** [idepkg] Error 2
Error: Unsupported target architecture -Paarch64, invoke the "fpc" compiler driver instead.

which is a little weird because it was happy earlier and the Preferences > Compiler executable is set to /usr/local/bin/fpc. The solution is to change that to /usr/local/lib/fpc/3.2.2/ppca64 instead.

The IDE is successfully rebuilt but does not restart automatically:

Build IDE: Success, Warnings: 25, Hints 792
Warning: svn not in path.

possibly due to the warning about svn? Quit the IDE.

Unfortunately trying to then start Lazarus from either the icon or icon in /Applications/Lazarus still results in the original Intel lazarus binary being launched.

The correct aarch64 binary can be found in ~/.lazarus/bin/aarch64-darwin/lazarus. So the final solution is to:

mv /Applications/Lazarus/lazarus /Applications/Lazarus/lazarus.old
mv  ~/.lazarus/bin/aarch64-darwin/lazarus /Applications/Lazarus/

You can then start the IDE with either the StartLazarus or Lazarus icons.

I came across this while trying to re-compile the IDE from within itself to produce a native aarch64 version of the IDE as the delivered release IDE is an X86_64 binary.

If anyone does try this, then be aware you need to go to Tools > Configure "Build Lazarus" and change the Target CPU to aarch64, check the Clean common files option and then Build.
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


  • New Member
  • *
  • Posts: 20
Re: Lazarus Release 2.2.0 and macOS aarch64
« Reply #1 on: February 04, 2022, 02:51:15 pm »
Thank you trev for this information.  My experience was exactly as you described.

Also after installing the aarch64 IDE, set the Preferences > Compiler executable setting, back to /usr/local/bin/fpc so now it will auto select the correct compiler type per the project settings.

Further to the above - Debugging - what works and what does not?  This is what I found.

I changed to the LLDB per step 5 here:

With the original Intel x86_64 IDE build and LLDB, I can compile both aarch64 and x86_64 apps, but I found it will only debug the x86_64 app.

With the aarch64 IDE build and LLDB, I can compile and debug both app types.  this is the preferred setup.

Hope this helps.


TinyPortal © 2005-2018