Skip to content
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

Update Apple M1/2 K build instructions #3726

Closed
Baltoli opened this issue Oct 18, 2023 · 2 comments · Fixed by #3761
Closed

Update Apple M1/2 K build instructions #3726

Baltoli opened this issue Oct 18, 2023 · 2 comments · Fixed by #3761
Assignees
Labels
apple-silicon Issues related to prototype Apple Silicon support documentation

Comments

@Baltoli
Copy link
Contributor

Baltoli commented Oct 18, 2023

For a while, the canonical line was that the K source build doesn't work on these machines because of an issue with Stack - I have retried the process and was able to build K successfully from a clean source build. We should update the documentation to better reflect this, and remove the old sections explaining the workarounds needed to build K on these platforms.

@Baltoli Baltoli added documentation apple-silicon Issues related to prototype Apple Silicon support labels Oct 18, 2023
@Baltoli Baltoli self-assigned this Oct 18, 2023
@radumereuta
Copy link
Contributor

Please let me know when this is done so I can add it to the changelog for #3706

@Baltoli
Copy link
Contributor Author

Baltoli commented Oct 25, 2023

First Attempt

Re-running my process to make sure that everything works as expected. My starting point is not a totally clean machine, but I have wiped the entire Homebrew installation and removed the Stack cache at ~/.stack on a machine running this OS:

$ sw_vers
ProductName:		macOS
ProductVersion:		13.4.1
BuildVersion:		22F82

Installed Homebrew with the official installer:

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
...
$ brew doctor
Your system is ready to brew.

I then installed the dependencies listed in the documentation:

$ brew install bison boost cmake flex fmt gcc gmp openjdk jemalloc libyaml llvm@15 make maven mpfr pkg-config python stack zlib z3
...

And the relevant developer tooling (separate to build dependencies):

$ brew install git direnv
...

Next, I got a clean checkout of K:

$ git clone [email protected]:runtimeverification/k.git --recursive --branch develop
...
$ cd k

Set up the Homebrew paths using direnv as suggested:

$ cp macos-envrc .envrc
...
$ direnv allow
...

Then tried a build, which got me the Stack error that we work around already in the Homebrew build:

$ mvn package -DskipTests
...
     [exec] ld64.lld: error: unknown argument '--gc-sections'
     [exec] clang: error: linker command failed with exit code 1 (use -v to see invocation)
     [exec] `gcc' failed in phase `Linker'. (Exit code: 1)
     [exec]
     [exec] Error: [S-6374]
     [exec]        While building simple Setup.hs (scroll up to its section to see the error) using:
...

The fix is to ensure that stack setup gets run before setting up the .envrc, as we do in the Homebrew build already. This is not quite zero caveat, but it's much better than the previous problems we've had. It might even be possible (with a future change to the Maven scripts) to get the build to run without custom LLVM on $PATH, but that change is out of scope for here:

$ cd haskell-backend/src/main/native/haskell-backend && stack setup && cd -
...

This hack will need a bit of explanation and debugging help added to help people identify the error when things go wrong.

Then, we get another error:

...
     [exec]        While executing the build plan, Stack encountered the error:
     [exec]
     [exec]        [S-7011]
     [exec]        While building package secp256k1-haskell-0.6.1 (scroll up to its section to see the error)
     [exec]        using:
...

which I believe to just be a missing dependency installable with Homebrew:

$ brew install secp256k1
...

This produces a successful build of K. Finally, I ran the integration tests:

$ cd k-distribution/tests/regression-new
$ time gmake -kO -j8 2>&1 | tee ../test.out
...

which pass, suggesting that this build of K works properly.

Second Attempt

Abbreviated console logs:

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
$ brew doctor
$ brew install bison boost cmake flex fmt gcc gmp openjdk jemalloc libyaml llvm@15 make maven mpfr pkg-config python stack zlib z3 git direnv secp256k1
$ git clone [email protected]:runtimeverification/k.git --recursive --branch develop
$ cd k
$ cd haskell-backend/src/main/native/haskell-backend && stack setup && cd -
$ cp macos-envrc .envrc
$ direnv allow
$ mvn package -DskipTests
$ cd k-distribution/tests/regression-new
$ time gmake -kO -j8 2>&1 | tee ../test.out

These commands allow the build to go through; I will go ahead and document that accordingly.

@Baltoli Baltoli linked a pull request Oct 26, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apple-silicon Issues related to prototype Apple Silicon support documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants