The big issue I have encountered is that I can not install the Xcode command line tools. Running "xcode-select --install" from the command line brings up the standard "Finding software" window, but after a few hours it has not finished. I will try updating all system software and restarting. Without the SDKs installed by this tool, I can not compile Lazarus or FPC projects on the DTK.
And did you know that Apple asks for feedback in the annual developer survey (https://developer.apple.com/app-store/tell-us/)? This may be another place to ask for support for Free Pascal.
Hi Chris,
[...] good performance of x86-64 OpenGL/Metal apps in emulation on ARM. [...]
Can someone post info how to install FPC and Lazarus on Apple DTK?See the installation instructions I lined at https://forum.lazarus.freepascal.org/index.php/topic,50187.msg369996.html#msg369996, including the warnings near the bottom.
I have problems with installing all tools.
1. As Chris wrote above, Command Line Tools cannot be installed, it freezes forever on "Finding software" window.
2. I can't install SVN. Because brew is not installed by default. I tried to manually download brew and install it, but it doesn't work correctly.The easiest option is to use the git mirror: https://github.com/graemeg/freepascal
Another option - MacPorts says that my macOS is not Catalina and exits.
2. I can't install SVN. Because brew is not installed by default. I tried to manually download brew and install it, but it doesn't work correctly.you can try to copy over svn binaries (executable and dependency libs) intel build from 10.15 (or any other macOS version)
Another option - MacPorts says that my macOS is not Catalina and exits.
igor@Igors-Mac fpcsrc % make distclean
xcrun: error: unable to load libxcrun (dlopen(/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib, 0x0005): could not use '/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib' because it is not a compatible arch).
igor@Igors-Mac fpcsrc %
open startlazarus.app --args "--pcp=~/.laz_trunk"
LSOpenURLsWithRole() failed with error -10810 for the file /Users/igor/WnSoft/Development/lazarus/startlazarus.app.
igor@Igors-Mac lazarus % open startlazarus.app --args "--pcp=~/.laz_trunk"
LSOpenURLsWithRole() failed with error -10810 for the file /Users/igor/WnSoft/Development/lazarus/startlazarus.app.
LSOpenURLsWithRole() failed with error -10810 for the file /Users/igor/WnSoft/Development/lazarus/startlazarus.app.
To test my hypothesis, see if turning on "Full Disk Access" for your "Lazarus" fixes your issue:
https://benscheirman.com/2019/10/troubleshooting-appkit-file-permissions/
(not sure if this helps if the executable bit of files is switched on, but should help other files).
I still can't install svn. MacPorts is not available for Big Sur. brew installed incorrectly.
I tried to manually from svn executables from /usr/bin/ on my another Mac, but this file copy operation is not permited:
sudo cp svn /usr/bin
igor@Igors-Mac ~ % xcrun svn
xcrun: error: sh -c '/Applications/Xcode-beta.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -find svn 2> /dev/null' failed with exit code 17664: (null) (errno=No such file or directory)
xcrun: error: The subversion command line tools are no longer provided by Xcode.
igor@Igors-Mac ~ %
I solved the problem with Lazarus. I deleted a link in MacOS and copied Lazarus executable to MacOS folder of Lazarus bundle. Now it works fine.
I still can't install svn. MacPorts is not available for Big Sur. brew installed incorrectly.
I tried to manually from svn executables from /usr/bin/ on my another Mac, but this file copy operation is not permited:
sudo cp svn /usr/bin
LSOpenURLsWithRole() failed with error -10810 for the file /Users/igor/WnSoft/Development/lazarus/startlazarus.app.
Is it possible to create Universal Binary with FPC now?Use the command "lipo" to create universal binaries from individually created binaries. The size of the universal binary will be more or less doubled. But if your app bundle has lots of resources like images, the total size will not increase a lot.
Do this technology mean that APP bundle will have doubled file size?
Use the command "lipo" to create universal binaries from individually created binaries. The size of the universal binary will be more or less doubled. But if your app bundle has lots of resources like images, the total size will not increase a lot.
I have a problem with setting Dark mode for a title of NSWindow. It works fine on Intel Mac.Your code is invalid on all platforms, even if it will not crash everywhere. Please use Objective-Pascal to interface with Objective-C frameworks unless you know all of the implementation details of the Objective-C runtime. In the above case case: you must typecast objc_msgSend to the signature of the function you are calling, rather than use it's declared signature (which uses varargs).
And crashes on Apple DTK on this line:
apr := objc_msgSend(cls, ObjCSelector('appearanceNamed:'), NSSTR(@ap[1]));
Your code is invalid on all platforms, even if it will not crash everywhere. Please use Objective-Pascal to interface with Objective-C frameworks unless you know all of the implementation details of the Objective-C runtime. In the above case case: you must typecast objc_msgSend to the signature of the function you are calling, rather than use it's declared signature (which uses varargs).
Igor, I have reported the Dark mode issue
https://bugs.freepascal.org/view.php?id=37402
Presumably the naming has changed, and now the theme is expected to be system wide.
Error: /Users/igor/TestCode/project1/lib/aarch64-darwin/SysPng.s:6347:7: error: invalid operand for instruction
SysPng.pas(5470,0) Error: Error while assembling exitcode 1
page.inc(36,29) Error: Operator is not overloaded: "Class Of TNotebook" and "Boolean"
shape.inc(33,24) Error: Illegal expression
shape.inc(33,44) Error: Illegal expression
shape.inc(34,24) Error: Illegal expression
shape.inc(34,44) Error: Illegal expression
shape.inc(35,24) Error: Illegal expression
shape.inc(35,44) Error: Illegal expression
shape.inc(36,24) Error: Illegal expression
shape.inc(36,44) Error: Illegal expression
shape.inc(37,24) Error: Illegal expression
shape.inc(37,44) Error: Illegal expression
shape.inc(40,24) Error: Illegal expression
shape.inc(40,44) Error: Illegal expression
shape.inc(41,24) Error: Illegal expression
shape.inc(41,44) Error: Illegal expression
shape.inc(42,24) Error: Illegal expression
shape.inc(42,44) Error: Illegal expression
shape.inc(43,24) Error: Illegal expression
shape.inc(43,44) Error: Illegal expression
shape.inc(44,24) Error: Illegal expression
shape.inc(44,44) Error: Illegal expression
shape.inc(47,24) Error: Illegal expression
shape.inc(47,44) Error: Illegal expression
shape.inc(48,24) Error: Illegal expression
shape.inc(48,44) Error: Illegal expression
shape.inc(49,24) Error: Illegal expression
shape.inc(49,44) Error: Illegal expression
shape.inc(50,24) Error: Illegal expression
shape.inc(50,44) Error: Illegal expression
shape.inc(51,24) Error: Illegal expression
shape.inc(51,44) Error: Illegal expression
shape.inc(54,24) Error: Illegal expression
shape.inc(54,44) Error: Illegal expression
shape.inc(55,24) Error: Illegal expression
shape.inc(55,44) Error: Illegal expression
shape.inc(56,24) Error: Illegal expression
shape.inc(56,44) Error: Illegal expression
shape.inc(57,24) Error: Illegal expression
shape.inc(57,44) Error: Illegal expression
shape.inc(58,24) Error: Illegal expression
shape.inc(58,44) Error: Illegal expression
extctrls.pp(1726) Fatal: There were 41 errors compiling module, stopping
Fatal: Compilation aborted
make[1]: *** [alllclunits.ppu] Error 1
make: *** [lazbuild] Error 2
*** Compiler ppcx64 not found. Stop
make FPC=$PWD/../ppca64 OPT="-ap -FD/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin -XR/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" -j 4 FPMAKEOPT="-T 4" OVERRIDEVERSIONCHECK=1 RELEASE=1 info
Every time I start Lazarus I see an error message that Fppcfg is missing (fppcfg.cfg).
Do you mean /etc/fppkg.cfg ?
That file gets created by the official FPC 3.2.0 installer. I just checked by removing it and reinstalling FPC 3.2.0 as downloaded from https://www.freepascal.org under Beta 9, and it got recreated.Do you mean /etc/fppkg.cfg ?
Yes, and I can't create a new fppkg.cfg file. No rights.
Is it possible to compile native ARM64 code for Apple Silicon on Intel Mac (with Big Sur and Xcode 12)?Yes. Execute step 1 of the instructions on an Intel Mac, and you'll have the cross-compiler. Skip steps 2 and 3. Execute step 4, but modified for a cross-installation:
sudo make FPC=$PWD/compiler/ppcrossa64 OPT="-ap -FD/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin -XR/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" CROSSINSTALL=1 install
Similar for step 5:sudo mv /usr/local/lib/fpc/3.3.1/ppcrossa64 /usr/local/lib/fpc/3.3.1/ppca64
sudo ln -sf /usr/local/lib/fpc/3.3.1/ppca64 /usr/local/bin
#include /etc/fpc.cfg
#ifdef cpuaarch64
-FD/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
-XR/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
#endif
System.GetCPUCount() always returns "1" on Apple Silicon CPU. It should be 4 or maybe 8 cores.
System.GetCPUCount() always returns "1" on Apple Silicon CPU. It should be 4 or maybe 8 cores.
The same here on Linux and Intel i5, always only "1" cpu.
On 64-bit Windows it returns "8", which is my 4 physical core + 4 hyperthreading cores.
System.GetCPUCount() always returns "1" on Apple Silicon CPU. It should be 4 or maybe 8 cores.the function doesn't seem to be implemented for Unix systems.
But same code compiled for Linux and run the Linux binary gives "1" as result.how about this code:
But same code compiled for Linux and run the Linux binary gives "1" as result.how about this code:
uses cthreads; function get_nprocs_conf: integer; cdecl; external; function GetCPUCountLinux: Integer; begin Result := get_nprocs_conf; end; begin writeln('proc count: ', GetCPUCountLinux); end.
another Linux/macOS version:
{$mode objfpc}{$H+} uses ctypes; const // the value changes across Unix OS-es _SC_NPROCESSORS_ONLN = {$ifdef darwin}58{$endif} // macOS {$else}84{$endif}; // linux function sysconf(conf: cint): clong; cdecl; external; function GetCPUCountUnix: Integer; begin Result := sysconf(_SC_NPROCESSORS_ONLN); end; begin writeln('proc count: ', GetCPUCountUnix); end.
Compiling testcpu.pas
Linking testcpu
/usr/bin/ld: testcpu.o: in function `P$TESTCPU_$$_GETCPUCOUNTUNIX$$LONGINT':
testcpu.pas:(.text.n_p$testcpu_$$_getcpucountunix$$longint+0x11): undefined reference to `sysconf'
testcpu.pas(22,5) Error: Error while linking
testcpu.pas(22,5) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
please add cthreads to the uses clause. This should link the required library
Another variant doesn't link on Apple DTK for aarch64:it should not link on macOS. get_nprocs_conf() is a Linux specific function.
Apple DTK has 8 cores (4 high-speed and 4 energy saving).
Yes.Apple DTK has 8 cores (4 high-speed and 4 energy saving).
Can they all work in parallel?
"The Geekbench 5 result reports the DTK as having only four cores while it is known that the A12Z has, in fact, eight CPU cores. It is very well possible that Rosetta 2 is seeing only the four high performance cores and not the efficiency ones."https://www.notebookcheck.net/First-A12Z-Bionic-DTK-Geekbench-5-benchmarks-show-Apple-s-transition-holds-immense-promise-only-a-28-in-drop-seen-in-single-core-score-compared-to-the-MacBook-Air-2020.477595.0.html
What about processorCount (https://developer.apple.com/documentation/foundation/nsprocessinfo/1415622-processorcount)?
The code might look like thise
uses CocoaAll; {$modeswitch objectiveC2} begin writeln('proc count: ', NSProcessInfo processInfo.processorCount); end.
Jonas,Not necessarily. Performance wins usually decrease exponentially as cores become more powerful/complex, so it could easily be more than that. It also illustrates the limited use of a singular "processorcount" value. Other cases where it means little is in case of NUMA configurations and hyperthreading.
You're right. It's easy to check.
The only question - performance of last 4 cores. Probably the total performance of these high-efficienty cores would be as 2 high-performance cores.
Not necessarily. Performance wins usually decrease exponentially as cores become more powerful/complex, so it could easily be more than that. It also illustrates the limited use of a singular "processorcount" value. Other cases where it means little is in case of NUMA configurations and hyperthreading.
In the final release of Big Sur Apple compiles own apps in "arm64e".Apple has been doing that since several betas already (maybe even from the first beta, but I didn't have a DTK yet at that point).
It seems that arm64e is a new generation of arm64:No, it's just an extension.
Is it possible that "arm64" will be declared as deprecated in nearest future?Definitely not in the nearest future, since building your own applications for arm64e is not even supported yet by Apple itself: https://developer.apple.com/forums/thread/652340
Can FPC compile to arm64e ?Currently only by using the LLVM backend.
What is better:You can also use FPC fixes_3_2 (I have merged the macOS/AArch64 support there, except for the inline assembly vector instructions support for now). And you can also use the lazarus fixes_2_0 branch.
A. Use a stable Lazarus 2.0.10 with FPC Trunk 3.3.1?
B. Or Lazarus Trunk + FPC Trunk 3.3.1?
Jonas,Yes, because the default compiler binary that gets started by "fpc" is the one for the host platform (technically, for the platform for which the "fpc" binary itself was compiled). On an Intel Mac that will be ppcx64, which is version 3.2.0 on your machine. If you use "fpc -Paarch64", you should see 3.2.1 instead (since that will start the AArch64 version of the compiler).
Yes, I replaced version number to 3.2.1 (fpc 3.2.0 with fixes).
sudo ln -sf /usr/local/lib/fpc/3.2.1/ppca64 /usr/local/bin
I tried 5 times to recompile FPC and re-download sources again.
When I type "fpc" in Terminal, I see version "3.2.0". Does it correct?
But if I now try to compile Lazarus from sources - 2.0.10 or 2.0 branch fixes I get the following error:
make bigide
carbonbars.pp(16,2) Error: User defined: only cpu i386 is supported
Compiler "/usr/local/bin/fpc" does not support target aarch64-macos
Embarcadero promisses (https://blogs.embarcadero.com/rad-studio-roadmap-november-2020/) 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!
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
Service exited with abnormal code: 217
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.
skalogryz,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.
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.
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.