Skip to content

"Unsupported ELF header" when running Go-compiled WASM #200

Description

@TKOTKCh

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions