Skip to content

Instantly share code, notes, and snippets.

@kylejeske
Forked from ulanda/RustJS.md
Created March 5, 2024 23:31
Show Gist options
  • Save kylejeske/0fe045307860220b5b662812cd598e55 to your computer and use it in GitHub Desktop.
Save kylejeske/0fe045307860220b5b662812cd598e55 to your computer and use it in GitHub Desktop.
Rust Compile with asmjs target

You will need nightly Rust

  • Install Rust, se rustup.sh curl -sSf https://static.rust-lang.org/rustup.sh | sh

  • Update installaion with: rustup self update rustup self update-data

  • Install nightly Rust: rustup toolchain install nightly

  • Default to nightly: rustup default nightly

  • Add the asmjs target: rustup target add asmjs-unknown-emscripten

  • Install NodeJS from https://nodejs.org/en/

  • Install CMake from www.cmake.org

  • Make CMake available on path sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install

  • Download emscriptem from http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html

  • Get the latest version of the sdk and setup de emscriptem sdk ./emsdk install sdk-incoming-64bit ./emsdk activate source ./emsdk_env.sh

  • Create a simple project with cargo: cargo new --bin --name simple simple

  • Compile the project: cargo build --target asmjs-unknown-emscripten

  • Run with node: node target/asmjs-unknown-emscripten/debug/simple.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment