anoma / juvix

A language for intent-centric and declarative decentralised applications
https://docs.juvix.org
GNU General Public License v3.0
452 stars 52 forks source link

On Apple silicon machines, the brew installed llvm's `wasm-ld` linker does not seem to be detected by juvix doctor command. #3082

Open denniswon opened 3 weeks ago

denniswon commented 3 weeks ago

Describe the bug

I am Apple M1 Pro (OS: macos sonoma) and I installed juvix. juvix itself installs fine but juvix doctor command is not being able to detect my wasm-ld installed locally. (I do want to compile to WebAssembly)

On Apple silicon macos machines, the brew installed llvm's wasm-ld linker does not seem to be detected by juvix doctor command. I also tried installing and building wasm-ld directly (https://lld.llvm.org/). But either way, wasm-ld is not detected by juvix doctor.

> juvix --version
Juvix version 0.6.6-e4559bb
Branch: HEAD
Commit: e4559bbc87eb946c1b5c4db76ec8983a94201418
Date: Tue Sep 3 18:10:01 2024 +0100
> juvix doctor
> Checking for clang...
> Checking clang version...
> Checking for wasm-ld...
  ! Could not find the wasm-ld command
  ! https://docs.juvix.org/0.6.6/reference/tooling/doctor/#could-not-find-the-wasm-ld-command
> Checking that clang supports wasm32...
> Checking that clang supports wasm32-wasi...
> Checking that WASI_SYSROOT_PATH is set...
> Checking for wasmer...
> Checking latest Juvix release on Github...
> which wasm-ld
/usr/local/bin/wasm-ld
> brew --prefix llvm
/opt/homebrew/opt/llvm

Can anyone help me here? Not sure if this is the issue with the llvm setup on my local mac or the juvix doctor.

Desktop (please complete the following information):

To Reproduce Steps to reproduce the behavior: https://docs.juvix.org/0.6.3/howto/installing.html

Expected behavior

juvix doctor to detect locally installed wasm-ld

paulcadman commented 3 weeks ago

Hi 👋 - thanks for the report.

To summarise:

What follows is a more detailed description of what we need to fix.

1. wasm-ld is no longer present in the homebrew llvm package

wasm-ld was removed from the llvm package in the latest version (version 19).

$ brew ls -v llvm@18 | grep wasm-ld
/opt/homebrew/Cellar/llvm@18/18.1.8/bin/wasm-ld
$ brew ls -v llvm | grep wasm-ld

wasm-ld is installed by the lld homebrew package.

$ brew ls -v lld | grep wasm-ld
/opt/homebrew/Cellar/lld/19.1.0/bin/wasm-ld

Actions

  1. Update the install documentation for macOS with instructions for installing wasm-ld using the lld homebrew package.

2. The juvix doctor diagnosis is misleading

We require that the doctor checks that:

  1. wasm-ld is available on the user's PATH
  2. wasm-ld is compatible with the version of clang on the user's PATH

We currently do this by checking that wasm-ld exists in the llvm distribution.

https://github.com/anoma/juvix/blob/8c37d9b439acc66455cff963a11821bbd0ac15b4/app/Commands/Doctor.hs#L77-L80

For macOS the implemented check does not cover the two requirements.

Actions

  1. Update the implemented check to meet the requirements.
  2. Update the warning message and documentation to more accurately describe what's being checked.

3. The juvix doctor links are broken

For example:

$ curl -s -o /dev/null -w "%{http_code}\n" https://docs.juvix.org/0.6.6/reference/tooling/doctor/#could-not-find-the-wasm-ld-command
404

Actions

Fix this as part of

4. The WASM dependencies are highlighted in the install docs but are not required for Anoma.

The Juvix WASM backend was developed at a time when Anoma applications were represented as WASM code. This is no longer the case and so it's not important for Juvix users of Anoma to setup WASM tooling. The Juvix documentation and doctor make it seem like WASM setup is important.

Actions

  1. Deemphasise WASM tooling in docs https://github.com/anoma/juvix/issues/3078
  2. Make WASM support optional: https://github.com/anoma/juvix/issues/3077