Forum > macOS / Mac OS X

Lazarus Release 2.2.0 and macOS aarch64


macOS 12.1 - aarch64 - attempt to rebuild the IDE from within itself fails with:

--- Quote ---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
--- End quote ---

Directory permissions as installed:

--- Quote ---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
--- End quote ---

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:

--- Quote ---cd /Applications
sudo chown -R your_username Lazarus
--- End quote ---

Then I was met with:

--- Quote ---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
--- End quote ---

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:

--- Quote ---#include /etc/fpc.cfg
--- End quote ---

so that fpcres can be found where it was installed.

The next hurdle:

--- Quote ---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.
--- End quote ---

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:

--- Quote ---Build IDE: Success, Warnings: 25, Hints 792
Warning: svn not in path.
--- End quote ---

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:

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

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.

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.


[0] Message Index

Go to full version