Recent

Author Topic: Lazarus for Windows on aarch64 (ARM64) - Native Compiler  (Read 35932 times)

PascalDragon

  • Hero Member
  • *****
  • Posts: 6184
  • Compiler Developer
Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Reply #75 on: December 14, 2024, 03:32:02 pm »
Absolutely no doubt, if not overkill!

The point is, building the compiler is intrinsicly part of building the whole FPC distribution, so verifying that it works comes with no additional cost.

msintle

  • Sr. Member
  • ****
  • Posts: 358
Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Reply #76 on: December 20, 2024, 05:12:50 pm »
Absolutely no doubt, if not overkill!

The point is, building the compiler is intrinsicly part of building the whole FPC distribution, so verifying that it works comes with no additional cost.

Sure, and my goal is to keep this effort moving forward; which is why I'd asked for a simpler test case to begin with.

msintle

  • Sr. Member
  • ****
  • Posts: 358
Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Reply #77 on: September 01, 2025, 02:58:53 pm »
Please be advised we are now able to offer a new bounty for this project.

An M3 "Submax" Apple laptop - 4 TB storage, 96 GB RAM, Space Black color, M3 Max CPU (30 GPU cores).

msintle

  • Sr. Member
  • ****
  • Posts: 358
Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Reply #78 on: September 13, 2025, 04:10:59 pm »
Has this effort been abandoned?

msintle

  • Sr. Member
  • ****
  • Posts: 358
Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Reply #79 on: September 13, 2025, 07:39:47 pm »
We've upped the CASH bonus for this bug to $1,000:

https://www.upwork.com/jobs/~021966919458128686252

And posted it as a gig above ^ ^

Edit: Would somebody care to post this at the FPC mailing list, too?

AlexTP

  • Hero Member
  • *****
  • Posts: 2615
    • UVviewsoft
Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Reply #80 on: September 14, 2025, 02:48:15 pm »
@msintle I posted this bounty suggestion to FPC mailing list. Delivered.

msintle

  • Sr. Member
  • ****
  • Posts: 358
Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Reply #81 on: September 14, 2025, 08:16:40 pm »
Many thanks!!!

PascalDragon

  • Hero Member
  • *****
  • Posts: 6184
  • Compiler Developer
Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Reply #82 on: September 14, 2025, 08:33:44 pm »
Has this effort been abandoned?

No, it's just that there are things that have higher priority, they are called "living a life".

msintle

  • Sr. Member
  • ****
  • Posts: 358
Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Reply #83 on: September 15, 2025, 01:11:23 pm »
Has this effort been abandoned?

No, it's just that there are things that have higher priority, they are called "living a life".

Oh, do you suppose the rest of us don't have anything else to worry about, are dependably raking in billions from our dozens of fully automated and diversified enterprises, hosting supermodels on our mega yachts (when we're too bothered with setting foot on any of our mega mansions sprouted on every continent of the planet connected with our 100 million private jets); with Lazarus as a hobby on the side, or an academic/archeological interest perhaps?

I suppose we owe you a "thanks" for having such a high view of us :D

So thank you 8-)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12523
  • FPC developer.
Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Reply #84 on: September 15, 2025, 05:24:52 pm »
Can we all dial down the sarcasm please?

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1840
Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Reply #85 on: September 16, 2025, 11:25:09 am »
It is very nice of you to offer a bounty to fully implement this target.
I hope that somebody capable will be able to do this.

msintle

  • Sr. Member
  • ****
  • Posts: 358
Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Reply #86 on: September 16, 2025, 12:59:59 pm »
It is very nice of you to offer a bounty to fully implement this target.
I hope that somebody capable will be able to do this.

Many thanks for your support! It is greatly appreciated.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1840
Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Reply #87 on: September 16, 2025, 02:15:38 pm »
I have asked a (very smart) AI to look into FPC. It detected all "recent" changes regarding Windows ARM64. And came up with some (seemingly good) advice (and actual code suggestions) about prologues, epilogues and stack unwinding. If time permits, I will dive (a small bit) into.

Wallaby

  • Full Member
  • ***
  • Posts: 113
Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Reply #88 on: September 16, 2025, 02:23:45 pm »
I've been testing this myself and here are my findings so far.

The following code behaves as expected on Win64 x86_64:

Code: Pascal  [Select][+][-]
  1. program test;
  2.      
  3. uses
  4.   Classes, SysUtils;
  5.      
  6. begin
  7.   writeln('begin');
  8.   try
  9.     writeln('try');
  10.     exit;
  11.   finally
  12.     WriteLn('finally');
  13.   end;
  14.   WriteLn('end');
  15. end.
  16.  

On Win64 AArch64, however, it only prints "begin" and "try". The "finally" block is skipped, which suggests that the exit statement isn’t working correctly. Since exit should trigger the finally block, this is clearly an issue.

The root cause seems related to the missing implementation of g_local_unwind in compiler/aarch64/cgcpu.pas, though there are other dependencies:

1) In compiler/options.pas, enabling FPC_USE_WIN64_SEH for system_aarch_win64 activates _FPC_local_unwind. 
2) I added a Win64-specific g_local_unwind override to the AArch64 code generator so that Windows ARM64 builds can hook custom unwinding:

Code: Pascal  [Select][+][-]
  1. procedure tcgaarch64.g_local_unwind(list: TAsmList; l: TAsmLabel);
  2. var
  3.   para1, para2: tcgpara;
  4.   href: treference;
  5.   pd: tprocdef;
  6. begin
  7.   if target_info.system<>system_aarch64_win64 then
  8.     begin
  9.       inherited g_local_unwind(list,l);
  10.       exit;
  11.     end;
  12.   pd:=search_system_proc('_fpc_local_unwind');
  13.   para1.init;
  14.   para2.init;
  15.   paramanager.getcgtempparaloc(list,pd,1,para1);
  16.   paramanager.getcgtempparaloc(list,pd,2,para2);
  17.   reference_reset_symbol(href,l,0,1,[]);
  18.   a_load_reg_cgpara(list,OS_ADDR,NR_STACK_POINTER_REG,para1);
  19.   a_loadaddr_ref_cgpara(list,href,para2);
  20.   paramanager.freecgpara(list,para2);
  21.   paramanager.freecgpara(list,para1);
  22.   g_call(list,'_FPC_local_unwind');
  23.   para2.done;
  24.   para1.done;
  25. end;
  26.  

With this change, the program now correctly prints "finally" — but unfortunately crashes immediately afterwards.


DonAlfredo

  • Hero Member
  • *****
  • Posts: 1840
Re: Lazarus for Windows on aarch64 (ARM64) - Native Compiler
« Reply #89 on: September 16, 2025, 02:27:47 pm »
Nice ! I guess it takes many steps like this to reach our goal.
Good to work together.

 

TinyPortal © 2005-2018