dciabrin/homebrew-ngdevkit

Compile error on macOS

Closed this issue · 8 comments

Hi everyone,

I'm trying compiling ngdevkit in a MacBook Pro with M1 Pro and I'm getting this:

==> /opt/homebrew/opt/make/bin/gmake install -- prefix=/opt/homebrew/Cellar/ngdevkit-toolchain/0.1+2
Last 15 lines from /Users/sidnei/Library/Logs/Homebrew/ngdevkit-toolchain/02.0.1+202306242048-1:
checking whether we are using GNU C... (cached) no
checking for m68k-neogeo-elf-as... (cached) /private/tmp/ngdevkit-toolchain-20230830-26780-s0wxr3/ngdevkit-toolchain-nightly-202306242048/build/ngnewlib/../ngbinutils/gas/as-new
checking for m68k-neogeo-elf-ar... (cached) /private/tmp/ngdevkit-toolchain-20230830-26780-s0wxr3/ngdevkit-toolchain-nightly-202306242048/build/ngnewlib/../ngbinutils/binutils/ar
checking for m68k-neogeo-elf-ranlib... (cached) /private/tmp/ngdevkit-toolchain-20230830-26780-s0wxr3/ngdevkit-toolchain-nightly-202306242048/build/ngnewlib/../ngbinutils/binutils/ranlib
checking for m68k-neogeo-elf-readelf... (cached) /private/tmp/ngdevkit-toolchain-20230830-26780-s0wxr3/ngdevkit-toolchain-nightly-202306242048/build/ngnewlib/../ngbinutils/binutils/readelf
checking whether to enable maintainer-specific portions of Makefiles... no
checking for build system executable suffix... no
configure: updating cache .././config.cache
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands
gmake[2]: Leaving directory '/private/tmp/ngdevkit-toolchain-20230830-26780-s0wxr3/ngdevkit-toolchain-nightly-202306242048/build/ngnewlib'
gmake[1]: *** [Makefile:911: all] Error 2
gmake[1]: Leaving directory '/private/tmp/ngdevkit-toolchain-20230830-26780-s0wxr3/ngdevkit-toolchain-nightly-202306242048/build/ngnewlib'
gmake: *** [Makefile:249: build/ngnewlib] Error 2

Some suggestion to solve it?

Hmmm, unfortunately no, these logs don't look particularly suspicious.

I don't have access to a M1 mac so I haven't got a chance yet to add support for it in ngdevkit. I'll report on this issue once I find a way to access a brew env on M1 to troubleshoot this issue.

Also, last time I checked, the current CI provider for homebrew-ngdevkit (azure) didn't provide M1 runner either, maybe this has changed recently. This will be required to provide bottles for ngdevkit.

@dciabrin, is there something I can do to help solve this issue?

Thanks @sidneivl, basically at this stage I need to get a hold of a M1/M2 environment because this package is fairly big (it compiles binutils, gcc, newlib, sdcc and gdb) and any remote debugging would be impractical.
I might get access to a M2 environment soon, I'll keep this issue updated very soon.

OK, I have an environment now, I've hit a couple of issues to build locally, first without brew build.

gcc refused to build because ngdevkit-toolchain makes use of realpath (Apple's binary) instead of grealpath (brew's coreutils binary). After this one, I had various complications with the way homebrew exposes library path under recent macOS versions [1]. Now I'm trying to workaround the fact that gcc-5.5.0 comes with an old libtool that doesn't know macOS's arm64 [2].

This is progressing. I'll update once I have a full build, at least locally.

[1] Homebrew/brew#13481
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97865

I finally managed to build the entire toolchain by swapping the old GCC 5 for a more recent GCC 11.4, which is apparently better suilted to latest macOS.

Homebrew has sufficiently changed between intel and arm that I need to test that the compiled binaries are good enough for building ROMS and running gngeo.

This is a bigger scope that this specific issue, so I'm going to track it in a dedicated issue in ngdevkit.

OK the entire ngdevkit project builds with gcc 11.4 on M1, MSYS2 and linux. I could compile almost all the ROMS from https://github.com/dciabrin/ngdevkit-examples, except for example 14 which uses complex linkscript for bankswitching. I still have to look into what could have changed compared to gcc 5.
Once everything is confirmed to work, I'll proceed to merge the change in ngdevkit-toolchain, and the Formula in homebrew-ngdevkit should get bumped automatically by the CI run.

OK I think this is finally fixed. ngdevkit now relies on gcc 11, I can build then entire devkit manually on a M2 machine, and all the brew packages have been updated to point to the latest sources.

I can't provide bottles for M1/M2 yet as the azure pipelines doesn't provide hosted m1 envs, so installing ngdevkit might take some time. On the M2 env I used, it took roughly 30min to install all the formulas. Then I could compile and run all ROMs from ngdevkit-examples as expected.

Can you try to reinstall the latest brew formulas on your environment to see if the issue is fixed for you?

I'm going to close this issue now as it's been fixed a long time ago