hyperlight-dev / hyperlight-dev/hyperlight-wasm

"Unsupported ELF header" when running Go-compiled WASM

Open
#200 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

lifecycle/needs info
Dominant language
Rust
Stars
728
Forks
39
Avg merge
2d 6h
Merged PRs (30d)
23

Description

Issue Description

I am trying to run a Go-compiled WASM module (testhyperlight-go.wasm) with hyperlight-wasm, but encounter the following error:

Error: GuestError(GuestError, "Error: failed to parse precompiled artifact as an ELF\n\nCaused by:\n    Unsupported ELF header")

This occurs when attempting to load the WASM file in the modified examples/helloworld/main.rs test case (see Reproduction Steps below).


Reproduction Steps
  1. Compile the Go WASM module:

    bash
    
    GOOS=wasip1 GOARCH=wasm go build -o "testhyperlight-go.wasm"
    
    package main
     
    //go:wasmexport noReturnCal
    func noReturnCal() {
        result := 0
        for i := 0; i < 100; i++ {
            result += i
        }
    }
     
    func main() {}
    
  2. Modify examples/helloworld/main.rs to include the new test case:

    fn main() -> Result<()> {
        let tests = [
            (
                "HelloWorld.aot",
                "HelloWorld",
                "Message from Rust Example to Wasm Function".to_string(),
            ),
            (
                "RunWasm.aot",
                "Echo",
                "Message from Rust Example to Wasm Function".to_string(),
            ),
            // New test case (Go WASM)
            (
                "testhyperlight-go.wasm",
                "noReturnCal",
                "Message from Rust Example to Wasm Function".to_string(),
            ),
        ];
        // ... (rest of the test logic)
    }
    
  3. Run the example and observe the error:

    Result from calling HelloWorld Function in Wasm Module test case 0) is: 0
    Result from calling Echo Function in Wasm Module test case 1) is: Message from Rust Example to Wasm Function
    Error: GuestError(GuestError, "Error: failed to parse precompiled artifact as an ELF\n\nCaused by:\n    Unsupported ELF header")
    
Questions
  1. Does hyperlight-wasm currently support WASM files compiled with another compiler?
    • Hyperlight provide wasm-clang-builder to compile C file , but does hyperlight compatible with Go-compiled WASM (with WASI support, such as GOOS=wasip1 GOARCH=wasm go build).
  2. If not, are there any possible modifications that can make hyperlight-wasm work with Go-compiled WASM?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with examples/helloworld/main.rs and reproduce the failure by building testhyperlight-go.wasm with GOOS=wasip1 GOARCH=wasm, then running the example. Compare the Go-generated module with the existing HelloWorld.aot and RunWasm.aot cases, and inspect the wasm-clang-builder context mentioned in the issue. Done means support or the compatibility limitation is established, with any required changes identified and the example no longer producing the ELF-header error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, rust, wasm
Domain
backend, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.