Stream: git-wasmtime

Topic: wasmtime / issue #10323 question: c-api how to set --allo...


view this post on Zulip Wasmtime GitHub notifications bot (Mar 04 2025 at 09:23):

liupeidong0620 opened issue #10323:

question

How to set --allow-precompiled in c-api? Then the cwasm program can run normally

wastime c-api version: wasmtime-v30.0.2-aarch64-macos-c-api.tar.xz

runing cwasm error

# build aot
$ wasmtime compile --target aarch64-apple-darwin bazel-bin/example/optimus_test.wasm -o optimus_test.cwasm

$ ./bazel-bin/example/run_wasm ~/liu-code/wasm/tendis_wasm_test/wasm_build_protobuf_3.17.3_lz4_hashmap_test/tendis_wasm_example/optimus_test.cwasm test ./100181088_1.bin
failed to new module:
failed to parse WebAssembly module

Caused by:
    magic header not detected: bad magic number - expected=[
        0x0,
        0x61,
        0x73,
        0x6d,
    ] actual=[
        0x7f,
        0x45,
        0x4c,
        0x46,
    ] (at offset 0x0)
Segmentation fault: 11

# Running wasm program is normal
$ ./bazel-bin/example/run_wasm ~/liu-code/wasm/tendis_wasm_test/wasm_build_protobuf_3.17.3_lz4_hashmap_test/tendis_wasm_example/bazel-bin/example/optimus_test.wasm test ./100181088_1.bin
define wasm host API tendis_get_buffer_bytes
define wasm host API tendis_set_buffer_bytes
loaded wasm plugin
test_dispatche_phase ctx id 0
wasmtime call function tendis_wasm_dispatche_phase
tendis_get_buffer_bytes start ..., ctx_id: 0
tendis_get_buffer_bytes start1 ..., ctx_id: 0
tendis_get_buffer_bytes start2 ..., ctx_id: 0
tendis_get_buffer_bytes start3 ..., ctx_id: 0
wasmtime call function malloc
run wasm malloc: 16 addr:152168
tendis_get_buffer_bytes start10 ..., ctx_id:
tendis_get_buffer_bytes start ..., ctx_id: 0
tendis_get_buffer_bytes start1 ..., ctx_id: 0
tendis_get_buffer_bytes start2 ..., ctx_id: 0
tendis_get_buffer_bytes start3 ..., ctx_id: 0
wasmtime call function malloc
run wasm malloc: 16 addr:152192
tendis_get_buffer_bytes start10 ..., ctx_id:
test_dispatche_phase result:
wg wait ok, run time: 0.105 milliseconds

view this post on Zulip Wasmtime GitHub notifications bot (Mar 04 2025 at 09:24):

liupeidong0620 edited issue #10323:

question

How to set --allow-precompiled in c-api? Then the cwasm program can run normally

wastime c-api version: wasmtime-v30.0.2-aarch64-macos-c-api.tar.xz

runing cwasm error

# build aot
$ wasmtime compile --target aarch64-apple-darwin bazel-bin/example/optimus_test.wasm -o optimus_test.cwasm

# run cwasm error
$ ./bazel-bin/example/run_wasm ~/liu-code/wasm/tendis_wasm_test/wasm_build_protobuf_3.17.3_lz4_hashmap_test/tendis_wasm_example/optimus_test.cwasm test ./100181088_1.bin
failed to new module:
failed to parse WebAssembly module

Caused by:
    magic header not detected: bad magic number - expected=[
        0x0,
        0x61,
        0x73,
        0x6d,
    ] actual=[
        0x7f,
        0x45,
        0x4c,
        0x46,
    ] (at offset 0x0)
Segmentation fault: 11

# Running wasm program is normal
$ ./bazel-bin/example/run_wasm ~/liu-code/wasm/tendis_wasm_test/wasm_build_protobuf_3.17.3_lz4_hashmap_test/tendis_wasm_example/bazel-bin/example/optimus_test.wasm test ./100181088_1.bin
define wasm host API tendis_get_buffer_bytes
define wasm host API tendis_set_buffer_bytes
loaded wasm plugin
test_dispatche_phase ctx id 0
wasmtime call function tendis_wasm_dispatche_phase
tendis_get_buffer_bytes start ..., ctx_id: 0
tendis_get_buffer_bytes start1 ..., ctx_id: 0
tendis_get_buffer_bytes start2 ..., ctx_id: 0
tendis_get_buffer_bytes start3 ..., ctx_id: 0
wasmtime call function malloc
run wasm malloc: 16 addr:152168
tendis_get_buffer_bytes start10 ..., ctx_id:
tendis_get_buffer_bytes start ..., ctx_id: 0
tendis_get_buffer_bytes start1 ..., ctx_id: 0
tendis_get_buffer_bytes start2 ..., ctx_id: 0
tendis_get_buffer_bytes start3 ..., ctx_id: 0
wasmtime call function malloc
run wasm malloc: 16 addr:152192
tendis_get_buffer_bytes start10 ..., ctx_id:
test_dispatche_phase result:
wg wait ok, run time: 0.105 milliseconds

view this post on Zulip Wasmtime GitHub notifications bot (Mar 04 2025 at 09:30):

liupeidong0620 commented on issue #10323:

The Wasmtime library is capable of running AOT programs compiled with wasmedgec.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 04 2025 at 09:31):

liupeidong0620 deleted a comment on issue #10323:

The Wasmtime library is capable of running AOT programs compiled with wasmedgec.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 04 2025 at 09:44):

bjorn3 commented on issue #10323:

Instead of wasmtime_module_new you have to use wasmtime_module_deserialize to load a precompiled module.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 04 2025 at 10:51):

liupeidong0620 commented on issue #10323:

wasmtime_module_deserialize

Thanks

view this post on Zulip Wasmtime GitHub notifications bot (Mar 04 2025 at 10:51):

liupeidong0620 closed issue #10323:

question

How to set --allow-precompiled in c-api? Then the cwasm program can run normally

wastime c-api version: wasmtime-v30.0.2-aarch64-macos-c-api.tar.xz

runing cwasm error

# build aot
$ wasmtime compile --target aarch64-apple-darwin bazel-bin/example/optimus_test.wasm -o optimus_test.cwasm

# run cwasm error
$ ./bazel-bin/example/run_wasm ~/liu-code/wasm/tendis_wasm_test/wasm_build_protobuf_3.17.3_lz4_hashmap_test/tendis_wasm_example/optimus_test.cwasm test ./100181088_1.bin
failed to new module:
failed to parse WebAssembly module

Caused by:
    magic header not detected: bad magic number - expected=[
        0x0,
        0x61,
        0x73,
        0x6d,
    ] actual=[
        0x7f,
        0x45,
        0x4c,
        0x46,
    ] (at offset 0x0)
Segmentation fault: 11

# Running wasm program is normal
$ ./bazel-bin/example/run_wasm ~/liu-code/wasm/tendis_wasm_test/wasm_build_protobuf_3.17.3_lz4_hashmap_test/tendis_wasm_example/bazel-bin/example/optimus_test.wasm test ./100181088_1.bin
define wasm host API tendis_get_buffer_bytes
define wasm host API tendis_set_buffer_bytes
loaded wasm plugin
test_dispatche_phase ctx id 0
wasmtime call function tendis_wasm_dispatche_phase
tendis_get_buffer_bytes start ..., ctx_id: 0
tendis_get_buffer_bytes start1 ..., ctx_id: 0
tendis_get_buffer_bytes start2 ..., ctx_id: 0
tendis_get_buffer_bytes start3 ..., ctx_id: 0
wasmtime call function malloc
run wasm malloc: 16 addr:152168
tendis_get_buffer_bytes start10 ..., ctx_id:
tendis_get_buffer_bytes start ..., ctx_id: 0
tendis_get_buffer_bytes start1 ..., ctx_id: 0
tendis_get_buffer_bytes start2 ..., ctx_id: 0
tendis_get_buffer_bytes start3 ..., ctx_id: 0
wasmtime call function malloc
run wasm malloc: 16 addr:152192
tendis_get_buffer_bytes start10 ..., ctx_id:
test_dispatche_phase result:
wg wait ok, run time: 0.105 milliseconds

view this post on Zulip Wasmtime GitHub notifications bot (Mar 04 2025 at 10:52):

liupeidong0620 edited a comment on issue #10323:

Thanks


Last updated: Apr 17 2025 at 16:03 UTC