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

Add build file for mlton wasm compilation #4

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

jcreedcmu
Copy link
Collaborator

Since compilation to webassembly with MLTon is demonstrably feasible, I would like to upstream the minor change that was required to get it to work.

Copy link
Member

@robsimmons robsimmons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I'm totally on board here, but is there any chance those huge MLB files can be refactored and shared with other mlb files?

@jcreedcmu
Copy link
Collaborator Author

You're right, that would be better, will do.

[This pull request against
MLton](MLton/mlton#550) enables compiling to
WebAssembly, so that twelf can be run from, e.g. inside a web browser.

A demo can be seen at:
https://jcreedcmu.github.io/twelf-wasm/

Test plan:
- ensure that the make target `twelf-server-mlton` still produces a
twelf-server binary
- ensure that the make target `wasi` produces
`bin/twelf.wasm`, when an appropriate version of `mlton` is installed.
Detailed instructions for building follow. Comments on the above pull
request have more details pertaining to build and install of GMP.

Checked out
https://github.com/agoode/mlton/tree/wasm2
at commit
MLton/mlton@d2b9e5d
put into
`$BUILD/dev-mlton`

and then did the following:

```
MLTON=$BUILD/mlton-wasm2-INSTALL

cd $BUILD/dev-mlton
make clean
make CC=$WASISDK/bin/clang \
     AR=$WASISDK/bin/ar \
     RANLIB=$WASISDK/bin/ranlib \
     TARGET_OS=wasi \
     TARGET_ARCH=wasm32 \
     TARGET=wasm32-unknown-wasi \
     WITH_GMP_DIR=$BUILD/gmp-wasi-INSTALL \
     PREFIX=$MLTON \
     dirs runtime install-runtime

cd $BUILD/dev-mlton
make clean
make all
make PREFIX=$MLTON install

cd $BUILD/twelf
mlton=$BUILD/mlton-wasm2-INSTALL/bin/mlton make wasi
```
Copy link
Member

@robsimmons robsimmons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ 🚢 🧝

@robsimmons robsimmons merged commit d357dbe into standardml:master Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants