AdaCore / gnat-llvm

LLVM based GNAT compiler
179 stars 18 forks source link

Any luck on apple silicon ? #24

Closed ceberly closed 2 years ago

ceberly commented 2 years ago

I imagine i'm not the only one trying this, so, has anyone been able to build for llvm on an apple m1?

I've tried a couple things like using gcc built for the m1 and using the GNAT community edition for mac x86_64 as a bootstrap. None of them seem to work.

The most promising (i think) has been to try this: gnat-llvm % CC=/Users/chris/opt/GNAT/2020/bin/gcc CXX=/Users/chris/opt/GNAT/2020/bin/g++ make -j32

which runs for awhile and then bails on a linking step because it looks like it built x86_64 objects instead of an aarch64

image

Thanks! this project has so much potential, i would love if I could get it working on my laptop...

ArnaudCharlet commented 2 years ago

We are not aware of anyone having tried/succeeded yet in building GNAT LLVM for apple M1. I guess you'll need to first build a x86_64 GNAT LLVM since this is what your base GNAT compiler knows and then use this GNAT LLVM to build a new GNAT LLVM which targets arm by default. Note that GNAT LLVM is able to bootstrap, meaning that it's capable of building itself, so you should be able to replace GNAT/GCC with GNAT LLVM as your base compiler. Good luck and let us (or anyone else) know how this goes!

ceberly commented 2 years ago

thanks, i'll give this a shot!

ceberly commented 2 years ago

I've done enough gymnastics over the last couple days to finally have an x86_64 llvm system on the m1. And i think i'm now hitting an actual ada issue. Is this something that I'm getting because I'm using the 2020 community edition for mac x86_64?

image image
ceberly commented 2 years ago

Actually this might be a GCC issue still, anyway im a bit stumped but maybe somebody has hit this...

ArnaudCharlet commented 2 years ago

That's indeed because your base GNAT compiler is too old for your GNAT sources. Using a more recent GNAT on mac os via a alire (https://alire.ada.dev/) should get you further and give you more work around options. Alternatively you could change all uses of [] by () in g-comlin.ads and possibly other files causing troubles in libgnat/ to get you past this step. Once you have a recent gnat llvm, you can revert this temp change.