Skip to content

LLVM error with arithemetic on function addresses #64521

@MarkMcCaskey

Description

@MarkMcCaskey

Hello! I was doing some experimenting with Wasm callbacks and ran into 2 issues.

The code for the guest is compiled with Rust 1.37.0 on OSX with --target=wasm32-unknown-unknown and --release.

edit: the first issue is no longer relevant; I misunderstood how function pointers were implemented. By using the table to look up these values, I got it working!

The second issue

While investigating this, I also found that the invalid solution of relying on the guest to offset correctly:

fn main() {
    // offset by 3 because we have 3 imports!
    unsafe { call_guest_fn(test_callback as usize as u32 + 3) };
}

causes an LLVM error:

 cargo build --release --target=wasm32-unknown-unknown
   Compiling guest v0.1.0 (/Users/mark/Documents/temp/guest)
LLVM ERROR: Function addresses with offsets not supported
error: Could not compile `guest`.

To learn more, run the command again with --verbose.

Let me know if I can clarify or help out with this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions