Re: [fpc-pascal] Building compiler which stalls
On 04/03/2023 07:24, Hairy Pixels via fpc-pascal wrote: Here’s the build command I used and it builds the compiler up to step #2 but then when it copies the compiler to compiler/ppca64 things fall apart. I noticed the following command "make distclean” stalled out at some point so I tried to run the compiler at compiler/ppca64 and it just stalls out, spinning the CPU at 100% in an infinite loop and never prints the normal FPC header. You can add "-Xs- -gw -Xg" to OPT to prevent symbol stripping and add debug info, and then when it's stuck either attach a debugger or run "sample ppcx64" Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Building compiler which stalls
> On Mar 4, 2023, at 6:28 PM, Jonas Maebe via fpc-pascal > wrote: > > You can add "-Xs- -gw -Xg" to OPT to prevent symbol stripping and add debug > info, and then when it's stuck either attach a debugger or run "sample ppcx64" Thanks, I’ve done that and here’s both the LLDB output and sample. It looks like it’s crashed on an exception but I don’t understand why it’s spinning the CPU. Either way something is clearly wrong and I’ve never seen this before. == Last login: Sat Mar 4 21:04:40 on ttys003 fpc$ lldb (lldb) process attach --name ppca64 Process 40083 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=259, address=0x102e8b71c) frame #0: 0x000102ad4a70 ppca64`FPC_BREAK_ERROR ppca64`FPC_BREAK_ERROR: -> 0x102ad4a70 <+0>: stpx29, x30, [sp, #-0x10]! 0x102ad4a74 <+4>: movx29, sp 0x102ad4a78 <+8>: stpx19, x20, [sp, #-0x10]! 0x102ad4a7c <+12>: stpx21, x21, [sp, #-0x10]! Target 0: (ppca64) stopped. Executable module set to "/Users/ryanjoseph/Developer/fpc/ppca64". Architecture set to: arm64e-apple-macosx-. (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=259, address=0x102e8b71c) * frame #0: 0x000102ad4a70 ppca64`FPC_BREAK_ERROR frame #1: 0x000102b319b4 ppca64`SYSTEMS_$$_SET_TARGET$TSYSTEM$$BOOLEAN + 260 frame #2: 0x000102b319b4 ppca64`SYSTEMS_$$_SET_TARGET$TSYSTEM$$BOOLEAN + 260 frame #3: 0x000102b3238c ppca64`SYSTEMS_$$_DEFAULT_TARGET$TSYSTEM + 12 frame #4: 0x000102b32448 ppca64`SYSTEMS_$$_INITSYSTEMS + 24 frame #5: 0x000102ae4ae8 ppca64`COMPILER_$$_INITCOMPILER$ANSISTRING + 56 frame #6: 0x000102ae4c20 ppca64`COMPILER_$$_COMPILE$ANSISTRING$$LONGINT + 192 frame #7: 0x000102abcfa0 ppca64`PASCALMAIN + 64 frame #8: 0x000102ae1a5c ppca64`FPC_SysEntry + 28 frame #9: 0x000102abccf0 ppca64`FPC_SYSTEMMAIN + 48 frame #10: 0x0001937a3e50 dyld`start + 2544 (lldb) Last login: Sat Mar 4 13:11:52 on ttys000 fpc$ sample ppca64 Sampling process 40083 for 10 seconds with 1 millisecond of run time between samples Sampling completed, processing symbols... Sample analysis of process 40083 written to file /tmp/ppca64_2023-03-04_210515_GYef.sample.txt Analysis of sampling ppca64 (pid 40083) every 1 millisecond Process: ppca64 [40083] Path:/Users/USER/*/ppca64 Load Address:0x102abc000 Identifier: ppca64 Version: 0 Code Type: ARM64 Platform:macOS Parent Process: make [40081] Date/Time: 2023-03-04 21:05:15.383 +0700 Launch Time: 2023-03-04 21:03:59.302 +0700 OS Version: macOS 13.1 (22C65) Report Version: 7 Analysis Tool: /usr/bin/sample Physical footprint: 2081K Physical footprint (peak): 2081K Idle exit: untracked Call graph: 4555 Thread_326874 DispatchQueue_1: com.apple.main-thread (serial) 4555 start (in dyld) + 2544 [0x1937a3e50] 4555 FPC_SYSTEMMAIN (in ppca64) + 48 [0x102abccf0] 4555 FPC_SysEntry (in ppca64) + 28 [0x102ae1a5c] 4555 PASCALMAIN (in ppca64) + 64 [0x102abcfa0] 4555 COMPILER_$$_COMPILE$ANSISTRING$$LONGINT (in ppca64) + 192 [0x102ae4c20] 4555 COMPILER_$$_INITCOMPILER$ANSISTRING (in ppca64) + 56 [0x102ae4ae8] 4555 SYSTEMS_$$_INITSYSTEMS (in ppca64) + 24 [0x102b32448] 4555 SYSTEMS_$$_DEFAULT_TARGET$TSYSTEM (in ppca64) + 12 [0x102b3238c] 4555 SYSTEMS_$$_SET_TARGET$TSYSTEM$$BOOLEAN (in ppca64) + 260 [0x102b319b4] 4555 SYSTEMS_$$_SET_TARGET$TSYSTEM$$BOOLEAN (in ppca64) + 260 [0x102b319b4] 3698 _sigtramp (in libsystem_platform.dylib) + 0 [0x193afb26c] 441 FPC_BREAK_ERROR (in ppca64) + 0 [0x102ad4a70] 408 _sigtramp (in libsystem_platform.dylib) + 56 [0x193afb2a4] + 407 FPC_DEFAULTSIGHANDLER (in ppca64) + 432 [0x102ae1580] + ! 395 SYSTEM_$$_REENABLE_SIGNAL$LONGINT$$BOOLEAN (in ppca64) + 144 [0x102ae13a0] + ! : 394 sigprocmask (in libsystem_kernel.dylib) + 8 [0x193a91430] + ! : 1 DYLD-STUB$$sigprocmask (in ppca64) + 4 [0x102d58b74] + ! 5 SYSTEM_$$_REENABLE_SIGNAL$LONGINT$$BOOLEAN (in ppca64) + 36 [0x102ae1334] + ! : 4 SYSTEM_$$_FILLCHAR$formal$INT64$CHAR (in ppca64) + 32 [0x102abde30] + ! : | 3 _platform_memset (in libsystem_platform.dylib) + 0,12,... [0x193afac00,0x193afac0c,...] + ! : | 1 DYLD-STUB$$memset (in ppca64) + 4 [0x102d58ac0] + ! : 1 SYSTEM_$$_FILLCHAR$formal$INT64$CHAR (in ppca64) + 32 [0x102abde30]
Re: [fpc-pascal] Building compiler which stalls
> On Mar 4, 2023, at 9:10 PM, Hairy Pixels wrote: > > Thanks, I’ve done that and here’s both the LLDB output and sample. > > It looks like it’s crashed on an exception but I don’t understand why it’s > spinning the CPU. Either way something is clearly wrong and I’ve never seen > this before. I just tried to run LLDB on the executable again and got a real stack trace this time. Looks like a legit error. fpc$ lldb /Users/ryanjoseph/Developer/fpc/ppca64 (lldb) target create "/Users/ryanjoseph/Developer/fpc/ppca64" Current executable set to '/Users/ryanjoseph/Developer/fpc/ppca64' (arm64). (lldb) r Process 40609 launched: '/Users/ryanjoseph/Developer/fpc/ppca64' (arm64) Process 40609 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=259, address=0x1003cf71c) frame #0: 0x00012c04 ppca64`fpc_shortstr_concat_multi(DESTS=, highDESTS=24, SARR=PSHORTSTRING[] @ 0x00016fdfecd0, highSARR=2) at generic.inc:914:20 911 end; 912 { Concat all strings, except the string we already 913 copied in DestS } -> 914 Len:=length(pdest^); 915 for i:=lowstart to high(sarr) do 916 begin 917 p:=sarr[i]; Target 0: (ppca64) stopped. warning: This version of LLDB has no plugin for the language "pascal83". Inspection of frame variables will be limited. (lldb) bt * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=259, address=0x1003cf71c) * frame #0: 0x00012c04 ppca64`fpc_shortstr_concat_multi(DESTS=, highDESTS=24, SARR=PSHORTSTRING[] @ 0x00016fdfecd0, highSARR=2) at generic.inc:914:20 frame #1: 0x0001000759b4 ppca64`SET_TARGET(T=) at systems.pas:643:47 frame #2: 0x00010007638c ppca64`DEFAULT_TARGET(T=SYSTEM_NONE) at systems.pas:899:3 frame #3: 0x000100076448 ppca64`INITSYSTEMS at systems.pas:1147:5 frame #4: 0x000100028ae8 ppca64`INITCOMPILER(CMD=) at compiler.pas:208:3 frame #5: 0x000100028c20 ppca64`COMPILE(CMD=0x) at compiler.pas:272:8 frame #6: 0x00010fa0 ppca64`PASCALMAIN at pp.pas:308:28 frame #7: 0x000100025a5c ppca64`SYSENTRY(INFO=TENTRYINFORMATION @ 0x0001003616e0) at system.pp:326:3 frame #8: 0x00010cf0 ppca64`FPC_SYSTEMMAIN(ARGCPARAM=, ARGVPARAM=, ENVPPARAM=) at sysinit.pas:68:3 frame #9: 0x0001937a3e50 dyld`start + 2544 (lldb) Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Building compiler which stalls
On 04/03/2023 07:24, Hairy Pixels via fpc-pascal wrote: # 1. Compile a native AArch64 compiler from the FPC trunk source make distclean make FPC=ppcx64 OPT="-ap -FD${TOOLCHAIN} -XR${MACOS_SDK}" CPU_TARGET=aarch64 -j 4 FPMAKEOPT="-T 4" all There is no need anymore to start with ppcx64 now that there is a native ppca64 in the latest FPC release (3.2.2). So you can start directly with your step 3 (removing the "FPC=$PWD/ppca64" so it uses the globally installed ppca64). If you do that, it works. I can reproduce the issue when following your steps. My best guess is that one of the new x86 optimisations is breaking things when cross-compiling the native AArch64 compiler. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Building compiler which stalls
> On Mar 5, 2023, at 3:56 AM, Jonas Maebe via fpc-pascal > wrote: > > There is no need anymore to start with ppcx64 now that there is a native > ppca64 in the latest FPC release (3.2.2). So you can start directly with your > step 3 (removing the "FPC=$PWD/ppca64" so it uses the globally installed > ppca64). If you do that, it works. > > I can reproduce the issue when following your steps. My best guess is that > one of the new x86 optimisations is breaking things when cross-compiling the > native AArch64 compiler. Great it’s working now thanks Jonas. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal