Carp icon indicating copy to clipboard operation
Carp copied to clipboard

Linking on Apple M1 Max

Open SynfoniqGene opened this issue 4 years ago • 7 comments

When attempting to build the example file reptile.carp, I get the following error: ld: warning: ignoring file /usr/local/lib/libSDL2.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64

This makes sense, as I have built SDL2 for arm64.

Is there a way to tell carp to build and link for macOS-arm64?

SynfoniqGene avatar Nov 09 '21 21:11 SynfoniqGene

I did a stack build and stack install hoping this would build a native ARM binary, but I still am seeing the link error.

SynfoniqGene avatar Nov 09 '21 21:11 SynfoniqGene

Typing (target-arch) in the repl shows this:

鲤 (target-arch)
I did not understand the form `("x86_64")` at REPL:1:2.

Traceback:
  (target-arch) at REPL:1:1.

SynfoniqGene avatar Nov 09 '21 21:11 SynfoniqGene

I was able to install the x86_64 libraries and use Rosetta2 emulation to build. I wasn't able to figure out how to get stack to build a arm version of carp. That may be a much more complex issue.

SynfoniqGene avatar Nov 09 '21 23:11 SynfoniqGene

Do you use pkg-config?

If you do the following in your project you can see the complete shell command that carp uses to compile your code:

(Project.config "echo-compiler-cmd" true)

What does it say? (when you build)

eriksvedang avatar Nov 10 '21 08:11 eriksvedang

I was able to install the x86_64 libraries and use Rosetta2 emulation to build. I wasn't able to figure out how to get stack to build a arm version of carp. That may be a much more complex issue.

Responding to this incredibly late but last time I checked Stack still does not support ARM sadly...

https://github.com/commercialhaskell/stack/issues/2103

TimDeve avatar Jan 03 '22 19:01 TimDeve

Can confirm this works now, GLFW example compiles and runs

MBP M1, macOS 12.6.1

stack --version
Version 2.9.3 aarch64

stack build --extra-include-dirs=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/ffi
stack install --extra-include-dirs=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/ffi

The flag is needed due to this issue https://gitlab.haskell.org/ghc/ghc/-/issues/20592

roman01la avatar Jan 29 '23 20:01 roman01la

@roman01la Great information, thanks!

eriksvedang avatar Jan 30 '23 08:01 eriksvedang