-
Notifications
You must be signed in to change notification settings - Fork 298
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
Cannot run the WASM demos #2924
Comments
Hmm, can you try without using CUE modules? |
To answer your ancillary questions more specifically:
Gc is impossible to use because it can't export functions yet (see golang/go/#65199). Tinygo is not guaranteed to work because it doesn't have a stable, or a standard ABI. Realistically only C and Rust can be expected to work at this point. Additionally, there is no support for strings yet, which I imagine you might need.
Do you need to use the CUE command line tool, or would a Go API to inject additional functions suffice? We could potentially make it easy to add functions via the API, but of course, if you need to use the command line tool rather than the API this would not help you. |
@4ad Thanks for answering so fast. I get the same behavior if I remove the module ( Using the CUE CLI would be best, but using a Go API to inject additional functions might probably be sufficient: the devs in that team mostly use the CLI to debug their configurations, but the actual logic using the validations is in custom Go code, so that should not be a major issue. I noticed you mention C and Rust: AIUI gccgo can work with the C ABI : is that correct and could that be a solution ? |
I might be wrong, but I don't believe gccgo supports Wasm at all. Additionally, the "C ABI" for Wasm is not defined anywhere really, so every compiler does something slightly different. Sometimes even the same compiler can do something different (see |
OK, so it would be either the existing fork-based solution (short term), or a way to add custom functions in Go for custom apps (second best, if you think that is something which is easily doable), or WASM from Rust Is there an existing issue I could look-at/help-with for the second solution ? |
OK, so I found the problem: i was running, as shown: Running simply I found the info by dissecting what |
Ah, yes, that makes perfect sense. |
FWIW, |
Kind of. The Go compiler does not use the C ABI, so we will need to add a Go-specific ABI, it wouldn't Just Work. But yes. |
Hypothetically, any idea of the amount of work it would take should I try to build this to Cue ? |
The problem is that the only way to get the memory layout of Go structs is via the We also need a way for this information to find its way into CUE. Perhaps we could add it to CUE struct fields as an attribute. Of course we don't want users to have to write this by hand, so we would need some sort of converter from the On a technical side of things, making use of this information (once we have it in CUE) is probably quite easy. The more difficult part is making an ergonomic UI/UX around it for users, and plumbing all the pieces together. In other words the difficulty lies in designing the feature rather than implementing it. |
Apologies, I wrote a message but it somehow got erased when I closed the issue. This wasn't really a bug as Wasm was intended to be used with full packages and not with individual files. But we have removed Wasm support from the CUE command itself (API support still present), so this issue doesn't even serve as a feature request for the forseeable future. We're waiting for Component Model support and when (if) that will arrive it will necessarily have a different UX in CUE. |
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest stable release?
Yes, but slightly differently.
What did you do?
Cargo.toml
is this:hello.wasm
both times, and tried the commands after that one with both version, with identical resultscargo build --target wasm32-wasi
cargo build --target wasm32-unknown-unknown
hello.wasm
file to the project directory containing thewasmer.cue
file:cue eval wasmer.cue
, with no flags and various flags combinations, both with thecue
(current stable) andcue08
(master HEAD) binarycue eval wasmer.cue hello.wasm
, with no flags and various flags combinations, both with thecue
(current stable) andcue08
(master HEAD) binaryunknown file extension .wasm
sudo fs_usage -f pathname cue08
in another window to trace file system callsWhat did you expect to see?
fs_usage
output, at least a stat or open to the filehello.wasm
possibly at an incorrect path to explain the errorsWhat did you see instead?
fs_usage
window, after the prologue:Showing there was no attempt to stat or open the
hello.wasm
file.What more did you do ?
I ran
cue
master HEAD under debugger, and found out:@extern("hello.wasm")
imports happen inwasm.findFile
from the list of resolved files in the was minstance’sb.UnknownFiles
, which is empty.b.OrphanFiles
incmd.getDecoders
but that list is empty too.b.OrphanFiles
is populated inload.fp.add
but that function only ever receives thewasmer.cue
file and not thehellow.wasm
file, regardless of whether it was passed on the CLI.hello.wasm
is much larger than those in the test suite, at 170kB vs less that 1kB for the small ones and 15kB for the largest one. Possibly due to the presence of debug info, I'm not very familiar with Rust builds.Anything else ?
pkg/net
, especially regarding the mixed IPv4/IPv6 situations.net2
Go packagepkg/packages.txt
go generate ./pkg
pkg/register.go
until registration becomes automatic autogenerated as in theTODO
ingen.go#24
go build -o cue08 cuelang.org/go/cmd/cue
The text was updated successfully, but these errors were encountered: