Hacker News new | ask | show | jobs
by docandrew 1021 days ago
There’s a GNAT release for M1 now. The FSF Ada compiler is based on GCC so it has worked for RISC-V and other ARM CPUs for a little while now as well.

Ada’s dynamic memory principles are definitely unique. For heap allocation its based around memory pools, at least in GNAT. For the most part it’s RTTI but you can do manual new/free style too (though discouraged).

Ada uses a secondary stack as well for variable-length function returns, so in practice you don’t need to do heap allocation very much.

There are also equivalents of some STL containers like vector that can handle heap allocations for you safely.

1 comments

Thanks for this... I'll take a look at how to get started on Mac OS with GNAT.

I went down a bit of a rabbit hole recently looking to see if there was a LLVM way to do this. It looked like it was being worked, but I'm not sure it's the best way to get started with Mac OS and Ada on Apple Silicon.

I'll check out homebrew and macports too... again, just in case!

Thanks again!

Not sure how well it works (I don’t have a Mac), but there is this repository that describes how to compile the whole gcc/gnat ada system in MacOS.

https://github.com/simonjwright/building-gcc-macos-arm-eabi

Bonus point is that you get the compiler for ARM bare metal

Happy to help! I can also recommend alire (alire.ada.dev), the open source package manager for Ada. It can manage your toolchains for you and makes it very easy to get started and create new projects. It works well on M1s.