Stream: git-wasmtime

Topic: wasmtime / issue #9029 ERROR:undefined reference to `wasm...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 27 2024 at 10:17):

Boring545 opened issue #9029:

I attempted to compile wasmtime and its C API on a RISC-V 64 platform. The steps are as follows:

  1. Clone the Wasmtime Repository and Compile:
    bash git clone https://github.com/bytecodealliance/wasmtime.git cd wasmtime cargo build --release -p wasmtime-c-api

  2. Copy the Compiled Results:

    • The .a and .so files are located in wasmtime/target/release.
    • The header files are located in wasmtime/crates/c-api/include.
      bash sudo cp libwasmtime.a /usr/local/lib/ sudo cp libwasmtime.so /usr/local/lib/ sudo cp -r /home/zjq/build_factory/wasmtime/wasmtime/crates/c-api/include/* /usr/local/include/
  3. Compile a Package (kpt) Using libwasmtime:
    bash git clone https://github.com/kptdev/kpt.git cd kpt go build -v

    >

# github.com/GoogleContainerTools/kpt
/home/zjq/riscv_istio_test/go_golang/go/pkg/tool/linux_riscv64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-2768106579/000011.o: in function `_cgo_a67a9a099c04_Cfunc_wasmtime_val_copy':
/tmp/go-build/cgo-gcc-prolog:250:(.text+0xcdc): undefined reference to `wasmtime_val_copy'
/usr/bin/ld: /tmp/go-link-2768106579/000021.o: in function `_cgo_a67a9a099c04_Cfunc_wasmtime_context_add_fuel':
/tmp/go-build/cgo-gcc-prolog:74:(.text+0x198): undefined reference to `wasmtime_context_add_fuel'
/usr/bin/ld: /tmp/go-link-2768106579/000021.o: in function `_cgo_a67a9a099c04_Cfunc_wasmtime_context_consume_fuel':
/tmp/go-build/cgo-gcc-prolog:94:(.text+0x2e0): undefined reference to `wasmtime_context_consume_fuel'
/usr/bin/ld: /tmp/go-link-2768106579/000021.o: in function `_cgo_a67a9a099c04_Cfunc_wasmtime_context_fuel_consumed':
/tmp/go-build/cgo-gcc-prolog:114:(.text+0x3de): undefined reference to `wasmtime_context_fuel_consumed'
/usr/bin/ld: /tmp/go-link-2768106579/000025.o: in function `_cgo_a67a9a099c04_Cfunc_wasmtime_val_delete':
/tmp/go-build/cgo-gcc-prolog:210:(.text+0x5ea): undefined reference to `wasmtime_val_delete'
collect2: error: ld returned 1 exit status

view this post on Zulip Wasmtime GitHub notifications bot (Jul 27 2024 at 10:22):

Boring545 edited issue #9029:

I attempted to compile wasmtime and its C API on a RISC-V 64 platform. The steps are as follows:

  1. Clone the Wasmtime Repository and Compile:
    bash git clone https://github.com/bytecodealliance/wasmtime.git cd wasmtime cargo build --release -p wasmtime-c-api

  2. Copy the Compiled Results:

    • The .a and .so files are located in wasmtime/target/release.
    • The header files are located in wasmtime/crates/c-api/include.
      bash sudo cp libwasmtime.a /usr/local/lib/ sudo cp libwasmtime.so /usr/local/lib/ sudo cp -r /home/zjq/build_factory/wasmtime/wasmtime/crates/c-api/include/* /usr/local/include/
  3. Compile a Package (kpt) Using lwasmtime:
    bash git clone https://github.com/kptdev/kpt.git cd kpt go build -v

    >

# github.com/GoogleContainerTools/kpt
/home/zjq/riscv_istio_test/go_golang/go/pkg/tool/linux_riscv64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-2768106579/000011.o: in function `_cgo_a67a9a099c04_Cfunc_wasmtime_val_copy':
/tmp/go-build/cgo-gcc-prolog:250:(.text+0xcdc): undefined reference to `wasmtime_val_copy'
/usr/bin/ld: /tmp/go-link-2768106579/000021.o: in function `_cgo_a67a9a099c04_Cfunc_wasmtime_context_add_fuel':
/tmp/go-build/cgo-gcc-prolog:74:(.text+0x198): undefined reference to `wasmtime_context_add_fuel'
/usr/bin/ld: /tmp/go-link-2768106579/000021.o: in function `_cgo_a67a9a099c04_Cfunc_wasmtime_context_consume_fuel':
/tmp/go-build/cgo-gcc-prolog:94:(.text+0x2e0): undefined reference to `wasmtime_context_consume_fuel'
/usr/bin/ld: /tmp/go-link-2768106579/000021.o: in function `_cgo_a67a9a099c04_Cfunc_wasmtime_context_fuel_consumed':
/tmp/go-build/cgo-gcc-prolog:114:(.text+0x3de): undefined reference to `wasmtime_context_fuel_consumed'
/usr/bin/ld: /tmp/go-link-2768106579/000025.o: in function `_cgo_a67a9a099c04_Cfunc_wasmtime_val_delete':
/tmp/go-build/cgo-gcc-prolog:210:(.text+0x5ea): undefined reference to `wasmtime_val_delete'
collect2: error: ld returned 1 exit status

view this post on Zulip Wasmtime GitHub notifications bot (Jul 27 2024 at 10:25):

Boring545 commented on issue #9029:

I couldn't find functions like wasmtime_val_copy in these header files, but I did find:

WASM_API_EXTERN void wasm_val_delete(own wasm_val_t* v);
WASM_API_EXTERN void wasm_val_copy(own wasm_val_t* out, const wasm_val_t*);

Is it possible that the version of c-api I compiled is too new, causing these APIs to be removed?

view this post on Zulip Wasmtime GitHub notifications bot (Jul 27 2024 at 18:36):

primoly commented on issue #9029:

I don’t know the reason for your issue, but if it helps, here are the PRs that renamed/replaced those functions:

https://github.com/bytecodealliance/wasmtime/pull/7298/files

https://github.com/bytecodealliance/wasmtime/pull/8451/files

view this post on Zulip Wasmtime GitHub notifications bot (Jul 29 2024 at 14:18):

alexcrichton commented on issue #9029:

Are you sure that the Wasmtime C API was built for RISC-V? If you only executed cargo build --release -p wasmtime-c-api then that would build it for the host platform, which is probably not RISC-V (but I could be wrong)


Last updated: Nov 22 2024 at 16:03 UTC