[gambit-list] A Lisp that runs on Wasm?

Winston W winston at nitidbit.com
Sat Mar 18 15:15:21 EDT 2023


Hi Gambit List—

I'm searching for a way to write Lisp and have it run on a web browser as WASM, i.e. avoiding JS. I was hoping Gambit Scheme might be the key, by compiling Lisp —> (Gambit compiler) —> C —> (Clang) —> wasm. But I'm encountering problems. My current issue is the 'gambit.h' file checks for lots of things including `setjmp` which doesn't exist in WASM. Below is my test situation. Does anybody think this endeavor of compiling Gambit -> wasm can work? Or are there any other ways to write Lisp and execute it as Wasm?

---

```
;; fib.scm
(define (square x)
  (expt x 2))
```

```
% gsc -c fib
```

produces a fib.c file. Then:

```
% clang --target=wasm32 -O1 -Wno-deprecated-declarations -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-math-errno -fomit-frame-pointer -fPIC -fno-common -D___SINGLE_HOST -D___DONT_HAVE_MATH_H -D___DONT_HAVE_SETJMP_H -D___DONT_HAVE_SIGNAL_H -D___DONT_HAVE_WCHAR_H -I"/opt/homebrew/Cellar/gambit-scheme/4.9.3_2/v4.9.3/include"  fib.c
```

Gives this error:
```
In file included from fib.c:36:
/opt/homebrew/Cellar/gambit-scheme/4.9.3_2/v4.9.3/include/gambit.h:8012:5: error: unknown type name 'jmp_buf'
    jmp_buf buf;
    ^
1 error generated.
make: *** [fib.o] Error 1
```


More information about the Gambit-list mailing list