part-cw / lambdanative

LambdaNative is a cross-platform development environment written in Scheme, supporting Android, iOS, BlackBerry 10, OS X, Linux, Windows, OpenBSD, NetBSD, FreeBSD and OpenWrt.
http://www.lambdanative.org
Other
1.4k stars 86 forks source link

M1/M2 (apple silicon) macosx support #435

Closed paines closed 2 years ago

paines commented 2 years ago

Little patch to support m1/m2 (apple silicon) Macs.

I testest with DemoSchemeAndC (needs brew install autoconf) and Calculator (need brew install imagemagick)

mgorges commented 2 years ago

@ddunsmuir can you test this as I don't have an Apple silicone Mac. The same change might also be needed in libraries/libgambit/make.sh?

ddunsmuir commented 2 years ago

@mgorges I don't have access to at Apple silicone Mac either, having purchased the last model of Intel ones.

mgorges commented 2 years ago

@paines could you check what change might be needed to libraries/libgambit/make.sh I presume we need an extra if or switch to test for aarch64-apple-darwin or x86_64-apple-darwin and modify libraries/libgambit/make.sh#L14. Note that this newer version of GambitC is only active if you modify modules/config/LIBRARIES to include libgambit instead of libgambc

paines commented 2 years ago

Actually I am confused by this. I tried both options you mentioned, and then arm64 , without EXTRACONF at all or EXTRACONF=empty and they all failed. BUT If I pull https://github.com/gambit/gambit/archive/v4.9.2.tar.gz and configure --enable-single-host and make it, it simply compiles (independent of the 4 patches in the libraries/libgambit directory).

mgorges commented 2 years ago

The line I am pointing to is targeting iOS, not building for macOS, which I believe you did manually. The macOS use case should be in libraries/libgambit/make.sh#L33, which leaves EXTRACONF empty. If you could provide more details of the problem I'd be happy to explore more, but in the absence of an Apple Silicon mac, we currently can't test this.

paines commented 2 years ago

@mgorges Sorry about the delay... I uploaded the error here: https://gist.github.com/paines/b69881894304745d722f421504b9e3a3

Like mentioned previously I tried line 34 EXTRACONF parameter of libgambit/make.sh empty or with --host=arm64 --host=aarch64-apple-darwin all with the same error.

I have the feeling that clang is making the trouble here. I will fiddle around with the options and see if gcc from homebrew can be used as a compiler. EDIT: I altered targets/macosx/host_macosx SYS_HOST_CC="gcc-11 $SYS_DEBUGFLAG -DMACOSX -m$SYS_ABI" and it will use gcc from homebrew instead of clang BUT the error persists...

mgorges commented 2 years ago

That is an unrelated problem - you are changing the compiler version, which makes an inconsistent state with the libraries and header files, i.e. the `/Users/aneslihovac/Library/Caches/lambdanative/macosx/include/gambit-not407009.h:2:2: error: "You are probably compiling C code generated by a Gambit compiler earlier or later than v4.7.9"

error "You are probably compiling C code generated by a Gambit compiler earlier or later than v4.7.9"` thus if you want to switch from libgambc to libgambit you need to flush the entire lambdanative cache.

paines commented 2 years ago

After cleaning the cache, DemoHelloWorld builds and runs fine with libgambit and EXTRACONF=.