Skip to content

Linking on Apple M1 Max #1356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SynfoniqGene opened this issue Nov 9, 2021 · 7 comments
Open

Linking on Apple M1 Max #1356

SynfoniqGene opened this issue Nov 9, 2021 · 7 comments
Labels

Comments

@SynfoniqGene
Copy link

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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.

@eriksvedang
Copy link
Collaborator

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)

@TimDeve
Copy link
Contributor

TimDeve commented Jan 3, 2022

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...

commercialhaskell/stack#2103

@roman01la
Copy link

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

@eriksvedang
Copy link
Collaborator

@roman01la Great information, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants