Skip to content

TypeScript Go WASM #4894

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

Open
sxzz opened this issue May 15, 2025 · 4 comments
Open

TypeScript Go WASM #4894

sxzz opened this issue May 15, 2025 · 4 comments

Comments

@sxzz
Copy link

sxzz commented May 15, 2025

I tested the latest development commit (2da9d26) of TinyGo to compile TypeScript Go.

The previous issue (#4804) has been resolved; however, some issues remain:

WASI

With wasip1, tsgo cannot be compiled at this time:

❯ GOOS=wasip1 GOARCH=wasm tinygo build ./cmd/tsgo
wasm-ld: error: lto.tmp: undefined symbol: os/signal.signalWaitUntilIdle
@aykevl
Copy link
Member

aykevl commented May 21, 2025

os.Getwd() always returns an empty string, which causes a panic in tsgo.

I don't think wasip1 has a concept of current working directory, but we can of course return a fake directory like ".".

The PR at #4565 is very useful; we need this functionality for CLI arguments.

It doesn't change anything for wasip1. For wasip1, command line arguments are already supported.

@sxzz
Copy link
Author

sxzz commented May 21, 2025

In the WASM (non-WASI) build of Golang, os.Getwd() internally calls process.cwd(). Currently, only the WASM version is compatible with tsgo; using the WASI version will result in a RangeError: Maximum call stack size exceeded.

@aykevl
Copy link
Member

aykevl commented May 21, 2025

os.Getwd() always returns an empty string, which causes a panic in tsgo.

I checked, and it returns "/" and not an empty string.

@aykevl
Copy link
Member

aykevl commented May 21, 2025

#4901 refactors signal handling, and adds os/signal.signalWaitUntilIdle. tsgo now compiles to wasip1 in TinyGo!

...however, it doesn't really work yet. It does show help output, but it crashes when actually compiling anything. There seems to be a memory corruption somewhere (checker inside CheckSourceFiles of program.go becomes nil when it shouldn't).

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

No branches or pull requests

2 participants