Skip to content

Conversation

@yzhang71
Copy link
Contributor

@yzhang71 yzhang71 commented Dec 5, 2025

PURPOSE

This PR introduces initial support for compiling Rust programs into Lind-WASM, allowing Rust source code to be built into WebAssembly modules that run correctly within the Lind runtime environment. The goal is to extend Lind’s existing C toolchain so that Rust developers can write, compile, and execute programs using the same infrastructure and conventions used by other Lind-supported languages.

This work includes:

  • Adding a Rust-to-WASM compilation pipeline (via rustc / Cargo targeting wasm32-wasi)
  • Ensuring compatibility with Lind’s custom glibc-derived sysroot
  • Integrating Rust compilation into the existing WASM optimization and precompilation stages
  • Providing initial examples/tests demonstrating Rust execution within Lind

RELATED ISSUE

Fixes: [lind-wasm #422](#422)
"Compile Rust code into Lind WASM"

This PR implements the functionality, providing a working pipeline to compile and run Rust programs in Lind.

Copy link
Contributor

Choose a reason for hiding this comment

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

remove from commit

# rm -rf "$SYSROOT"

# # Find all .o files recursively in the source directory, ignoring stamp.o
# object_files=$(find "$BUILD" -type f -name '*.o' \
Copy link
Contributor

Choose a reason for hiding this comment

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

i believe this is all math stuff, if so remove this file from commit

Copy link
Contributor

Choose a reason for hiding this comment

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

binary needs to be removed from commit

Copy link
Contributor

Choose a reason for hiding this comment

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

all the math things as well, i think all the glibc changes arent part of this

for import in module.imports() {
if let Some(m) = import.ty().memory() {
if m.is_shared() {
// if m.is_shared() {
Copy link
Contributor

Choose a reason for hiding this comment

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

@qianxichen233 can you chime in here a bit about this fix?

we're going to need to do something besides just comment out the code and we need some context

pid,
minimal_pages << PAGESHIFT, // size of first memory region
// minimal_pages << PAGESHIFT, // size of first memory region
16777216,
Copy link
Contributor

Choose a reason for hiding this comment

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

this part as well

-MD -MP -MF $GLIBC/build/nptl/elision-unlock.o.dt \
-MT $GLIBC/build/nptl/elision-unlock.o

$CC $CFLAGS $WARNINGS $EXTRA_FLAGS \
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we getting rid of these?

@rennergade
Copy link
Contributor

rennergade commented Dec 10, 2025

@stupendoussuperpowers Can you try this out and see if you can reproduce compiling fdtables for wasm?

Copy link
Contributor

Choose a reason for hiding this comment

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

remove file from PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove from PR

#!/usr/bin/env bash
set -euo pipefail

SYSROOT=/home/lind-wasm-rust/lind-wasm/src/glibc/sysroot
Copy link
Contributor

Choose a reason for hiding this comment

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

lind-wasm-rust -> lind-wasm

target = "wasm32-wasip1"

[target.wasm32-wasip1]
linker = "/home/lind-wasm-rust/wasip1-clang.sh"
Copy link
Contributor

Choose a reason for hiding this comment

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

lind-wasm-rust -> lind-wasm


[target.wasm32-wasip1]
linker = "/home/lind-wasm-rust/wasip1-clang.sh"
rustflags = [
Copy link
Contributor

Choose a reason for hiding this comment

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

arguments need to be updated per new script

Copy link
Contributor

Choose a reason for hiding this comment

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

lets move this file to src/scripts/rust/config.toml.template

@rennergade
Copy link
Contributor

Lets add a short explainer doc in docs/contributing/compiling-with-rust.md

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.

3 participants