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

The steps in the "Build from Source" documentation always fail if the runtime is not cleaned after building with a non-wasi compatible clang #2537

Closed
paulcadman opened this issue Nov 24, 2023 · 1 comment · Fixed by #2538
Assignees
Labels
bug build documentation Improvements or additions to documentation pending-review
Milestone

Comments

@paulcadman
Copy link
Collaborator

paulcadman commented Nov 24, 2023

To reproduce

Precondition:

  • The version of LLVM on your PATH does not support thewasm32-unknown-wasi triple (this is the default on macOS aarch64 even after running brew install llvm as the non-wasi Apple clang at /usr/bin/clang takes precedence)

Steps:

  1. Run make in the root of the project. The runtime build will fail with error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-wasi"'
  2. Follow the instructions at https://docs.juvix.org/0.5.4/howto/installing/#building-juvix-from-source
  3. Run make CC=$(brew --prefix llvm)/bin/clang LIBTOOL=$(brew --prefix llvm)/bin/llvm-ar build

Expected

The instructions build and installs Juvix from source.

Actual

The build continues to fail at the make runtime stage with the error: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-wasi"'

Workaround

After the error in step 1. of the reproduction steps, run (for macOS):

make clean
make CC=$(brew --prefix llvm)/bin/clang LIBTOOL=$(brew --prefix llvm)/bin/llvm-ar build

Explanation

After the initial failing build, the runtime build stores the resolved Makefile parameters as state in the build directory. This state is reused even if the Makefile parameters are subsequently changed.

@paulcadman paulcadman added documentation Improvements or additions to documentation bug build pending-review labels Nov 24, 2023
@paulcadman paulcadman added this to the 0.5.5 milestone Nov 24, 2023
@paulcadman paulcadman self-assigned this Nov 24, 2023
@paulcadman
Copy link
Collaborator Author

On macOS with recent versions of LLVM (at least 16+) the instructions to install libclang_rt.builtins-wasm32-wasi-*.tar.gz in https://docs.juvix.org/0.5.4/howto/installing/#installing-dependencies are redundant. They may still be necessary on Linux. We should check this and remove this section if possible.

lukaszcz pushed a commit that referenced this issue Nov 27, 2023
…file (#2538)

This is an attempt to fix a confusing situation where a user:

1. Builds the runtime with clang that does not support wasm32-wasi
2. Attempts to rebuild the runtime by passing the CC parameter pointing
to another installation of clang that does support wasm32-wasi.

In step 1. the runtime Makefile generates dependencies files which
contain the resolved value of `$(CC)`. When the user passes the correct
`CC` variable to the Makefile in step 2., the dependencies files are not
regenerated, the old value of `CC` is used in the build and the build
continues to fail.

In this PR we change the dependency file generation so that the
variables like `$(CC)` are written into the dependency file verbatim.
They are resolved when they are run in step 2. using the new value of
the CC parameter.

* Closes #2537
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug build documentation Improvements or additions to documentation pending-review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant