Recent

Author Topic: Apple Developer Transition Kit  (Read 15927 times)

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 304
Re: Apple Developer Transition Kit
« Reply #150 on: November 24, 2020, 01:07:14 pm »
Jonas,

I tried again on iMac with Big Sur, but even with target darwin + aarch64 I get this error:

Code: Pascal  [Select][+][-]
  1. Compiler "/usr/local/bin/fpc" does not support target aarch64-darwin

Code: Pascal  [Select][+][-]
  1. bash-3.2$ fpc -Paarch64
  2. Free Pascal Compiler version 3.2.1 [2020/11/20] for aarch64

Can I manually somehow overwrite fpc binaries to get it work?
« Last Edit: November 24, 2020, 05:44:16 pm by Igor Kokarev »

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 304
Re: Apple Developer Transition Kit
« Reply #151 on: November 26, 2020, 11:05:01 am »
Embarcadero promisses ARM64 support for Delphi only at second half of 2021. Whereas FPC 3.2.0 fixes already can compile for ARM64 target in macOS.
Bravo to developers of FPC!

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1206
  • Former Delphi 1-7, 10.2 User
Re: Apple Developer Transition Kit
« Reply #152 on: November 26, 2020, 10:47:18 pm »
Embarcadero promisses ARM64 support for Delphi only at second half of 2021.

Given their previous over-promising and under-delivering for 64 bit macOS and iOS compilers, I wouldn't be holding my breath.

Quote
Whereas FPC 3.2.0 fixes already can compile for ARM64 target in macOS.
Bravo to developers of FPC!

Indeed. Another reason to use FPC + Lazarus rather than EMB's product.
o Lazarus 2.1.0 r64368, FPC 3.3.1 r48100, macOS 10.14.6, Xcode 11.3.1
o Lazarus 2.1.0 r64392, FPC 3.3.1 Jan 13 21:24, macOS 11.1 (aarch64), Xcode 12.3
o Lazarus 2.1.0 r61574, FPC 3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus 2.1.0 r61574, FPC 3.0.4, Ubuntu 20.04 (Parallels VM)

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 304
Re: Apple Developer Transition Kit
« Reply #153 on: December 04, 2020, 07:13:40 pm »
I created first Universal App, signed, notarized DMG. It works fine on my Apple DTK and on Intel Mac.

But on real Mac Mini with M1 we've got an error for native aarch64 version:

Quote
Dec  4 11:35:57 MacMini com.apple.xpc.launchd[1]: Coalition Cache Hit: app<application.TestApp.27827332.27827354(501)> [1370]
Dec  4 11:35:57 MacMini com.apple.xpc.launchd[1] (application.TestApp.27827332.27827354[1787]): Service exited with abnormal code: 217

So I guess that we have to buy real Mac with M1 for testing. DTK can mask problems.
« Last Edit: December 04, 2020, 07:15:18 pm by Igor Kokarev »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2544
    • havefunsoft.com
Re: Apple Developer Transition Kit
« Reply #154 on: December 04, 2020, 07:33:47 pm »
Quote
Service exited with abnormal code: 217

It seems to be FPC run-time error:
Quote
217 Unhandled exception occurred
An exception occurred, and there was no exception handler present. The sysutils unit installs a default exception handler which catches all exceptions and exits gracefully.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

ChrisR

  • Full Member
  • ***
  • Posts: 187
Re: Apple Developer Transition Kit
« Reply #155 on: December 04, 2020, 07:52:27 pm »
Igor,
 I have both a DTK and M1. I have not seen any bugs on the M1 that were not present on the DTK. However, there are several documented FPC bugs for situations where the optimization level is greater than -O1. My current approach is to develop everything with the FPC compiler (which is very quick to compile and nicely integrated into Lazarus) and then to compile the release builds with LLVM.

Optionally, for extra performance, I also add a couple of custom compiler options for LLVM that Jonas suggested. I do this by adding a couple lines to the .lpi file (I can not work out how to make a conditional for LLVM detection in the compiler options):

<CustomOptions Value="-dDisableLCLGIF
-Clflto
-Clfltonosystem"/>


So my build/notarization script cross-compiles and uses lipo to make a universal binary:

lazbuild -B --compiler=~/src/fpcllvm/lib/fpc/3.3.1/ppcx64 --ws=cocoa  --cpu=x86_64 ~/src/MRIcroGL12/MRIcroGL_Metal_llvm.lpi

lazbuild -B --compiler=~/src/fpcllvm/lib/fpc/3.3.1/ppca64 --ws=cocoa  --cpu=aarch64 ~/src/MRIcroGL12/MRIcroGL_Metal_llvm.lpi

Compared to the non-optimized FPC AArch64, this leads to substantially faster performance. Here are the times in milliseconds for a few tasks:

M1-FPC   
init   329
minmax   319
rgba   189
M1-LLVM   
init   126
minmax   81
rgba   104

I do expect FPC will close this gap as the AArch64 optimization matures - I urge everyone to help sponsor Kit's work on this
  https://www.patreon.com/curiouskit/posts

Since LLVM/Clang is what Apple uses for all their tools, it seems very optimized. All my Lazarus projects just work, including those that use OpenGL and Metal. I suspect this will resolve the bugs you are encountering, and should allow you to build perfectly fine M1 code on your DTK.

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 304
Re: Apple Developer Transition Kit
« Reply #156 on: December 04, 2020, 08:21:45 pm »
skalogryz,
Chris,

Many thanks for your quick responses and advices!

I compiled my app with FPC 3.2.1 fixes on two different Macs. With optimizations O2. I'll try O1 or O0 version. Or maybe LLVM.

Probably I incorrectly compiled some dylibs, or incorrectly signed APP (no errors after checking). I'll try to create more simple tests tomorrow.


Chris,

Even now FPC speed for aarch64 is very good for me. But your results of speed are very impressive. It would great to have these optimizations included for FPC in future.

I'll support FPC developers on Patreon. Really good idea. Thanks for reminding.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 818
Re: Apple Developer Transition Kit
« Reply #157 on: December 05, 2020, 02:39:13 pm »
skalogryz,
Chris,

Many thanks for your quick responses and advices!

I compiled my app with FPC 3.2.1 fixes on two different Macs. With optimizations O2. I'll try O1 or O0 version. Or maybe LLVM.
The LLVM backend is only supported on trunk. FPC 3.2.1 does not contain any of the newly added AArch64 peephole optimizations, so it shouldn't contain any bugs introduced by them either.

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 304
Re: Apple Developer Transition Kit
« Reply #158 on: December 05, 2020, 07:52:38 pm »
Jonas,

OK, I've understood. Thanks.

I've sent several test versions to a friend with Apple M1 Mac. The same problem with O1 and O0 optimizations. So our problem is not related with code optimization level.

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 304
Re: Apple Developer Transition Kit
« Reply #159 on: December 16, 2020, 03:39:43 pm »
I can't compile new Lazarus trunk for aarch64 on DTK.

Lazarus trunk and FPC trunk where downloaded today. FPC 3.3.1 compiled correctly.

Code: Pascal  [Select][+][-]
  1. git clone https://github.com/graemeg/lazarus
  2. make bigide

Code: Pascal  [Select][+][-]
  1. lib/aarch64-darwin/cocoa/tatextelements.s:543:9: error: invalid operand for instruction
  2.         add     x0,w0,w0,lsr #63
  3.                    ^
  4. lib/aarch64-darwin/cocoa/tatextelements.s:544:9: error: invalid operand for instruction
  5.         asr     w0,x0,#1
  6.                    ^
  7. lib/aarch64-darwin/cocoa/tatextelements.s:546:9: error: invalid operand for instruction
  8.         add     x1,w1,w1,lsr #63
  9.                    ^
  10. lib/aarch64-darwin/cocoa/tatextelements.s:547:9: error: invalid operand for instruction
  11.         asr     w1,x1,#1
  12.                    ^
  13. lib/aarch64-darwin/cocoa/tatextelements.s:3829:9: error: invalid operand for instruction
  14.         add     x0,w0,w0,lsr #63
  15.                    ^
  16. lib/aarch64-darwin/cocoa/tatextelements.s:3830:9: error: invalid operand for instruction
  17.         asr     w1,x0,#1
  18.                    ^
  19. lib/aarch64-darwin/cocoa/tatextelements.s:3832:9: error: invalid operand for instruction
  20.         add     x0,w0,w0,lsr #63
  21.                    ^
  22. lib/aarch64-darwin/cocoa/tatextelements.s:3833:9: error: invalid operand for instruction
  23.         asr     w0,x0,#1
  24.                    ^
  25. lib/aarch64-darwin/cocoa/tatextelements.s:3931:9: error: invalid operand for instruction
  26.         add     x0,w0,w0,lsr #63
  27.                    ^
  28. lib/aarch64-darwin/cocoa/tatextelements.s:3932:9: error: invalid operand for instruction
  29.         asr     w1,x0,#1
  30.                    ^
  31. lib/aarch64-darwin/cocoa/tatextelements.s:3934:9: error: invalid operand for instruction
  32.         add     x0,w0,w0,lsr #63
  33.                    ^
  34. lib/aarch64-darwin/cocoa/tatextelements.s:3935:9: error: invalid operand for instruction
  35.         asr     w0,x0,#1
  36.                    ^
  37. tatextelements.pas(944) Error: (9007) Error while assembling exitcode 1
  38. tatextelements.pas(944) Fatal: (10026) There were 2 errors compiling module, stopping
  39. Fatal: (1018) Compilation aborted
  40. make[2]: *** [tachartlazaruspkg.ppu] Error 1
  41. make[1]: *** [bigide] Error 2
  42. make: *** [bigidecomponents] Error 2

Code: Pascal  [Select][+][-]
  1. Igors-Mac:lazarus mac$ fpc -Paarch64
  2. Free Pascal Compiler version 3.3.1 [2020/12/16] for aarch64
« Last Edit: December 16, 2020, 03:48:44 pm by Igor Kokarev »

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 818
Re: Apple Developer Transition Kit
« Reply #160 on: December 16, 2020, 04:47:18 pm »
I can't compile new Lazarus trunk for aarch64 on DTK.

Please file a bug report. That's probably a bug for the people working on the peephole optimizer.

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 304
Re: Apple Developer Transition Kit
« Reply #161 on: December 16, 2020, 05:26:40 pm »
Jonas, I created a bug-report:

https://bugs.freepascal.org/view.php?id=38225

Igor Kokarev

  • Sr. Member
  • ****
  • Posts: 304
Re: Apple Developer Transition Kit
« Reply #162 on: December 16, 2020, 06:43:18 pm »
Jonas, thanks for the corrections in the bug report.

 

TinyPortal © 2005-2018