ya0guang opened a new issue #8534:
URL: https://github.com/apache/tvm/issues/8534


   As some people and I mentioned in #6816, the currently TVM cannot support 
`wasm32` target well using Rust APIs. It can run into this error: `wasm trap: 
indirect call type mismatch`.
   
   This error originates in the incorrect extern function definition in 
`rust/tvm-sys/src/lib.rs`:
   ```rs
       pub type BackendPackedCFunc = extern "C" fn(
           args: *const TVMValue,
           type_codes: *const c_int,
           num_args: c_int,
           out_ret_value: *mut TVMValue,
           out_ret_tcode: *mut u32,
       ) -> c_int;
   ```
   
   However, the correct definition in C is from 
`include/tvm/runtime/c_backend_api.h`:
   ```c
   /*!
    * \brief Signature for backend functions exported as DLL.
    *
    * \param args The arguments
    * \param type_codes The type codes of the arguments
    * \param num_args Number of arguments.
    * \param out_ret_value The output value of the the return value.
    * \param out_ret_tcode The output type code of the return value.
    * \param resource_handle Pointer to associated resource.
    *
    * \return 0 if success, -1 if failure happens, set error via 
TVMAPISetLastError.
    */
   typedef int (*TVMBackendPackedCFunc)(TVMValue* args, int* type_codes, int 
num_args,
                                        TVMValue* out_ret_value, int* 
out_ret_tcode,
                                        void* resource_handle);
   ```
   
   Here is an additional parameter, `void* resource_handle`. It seems people 
forgot to update the Rust interface. My previous issue(#8439) is also related 
to this error.
   
   @mssun and @m4sterchain are also interested in this issue.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to