bytecodealliance / wasmtime

A fast and secure runtime for WebAssembly
https://wasmtime.dev/
Apache License 2.0
15.43k stars 1.31k forks source link

Cranelift: The `clif-util run` command seems can not find the entry function #9655

Open abc767234318 opened 7 hours ago

abc767234318 commented 7 hours ago

I constructed a clif file.

multi_func21_fail_to_find_function.zip

I used the following command to run it.

clif-util run -v file_tests/multi_func21.clif

But I got the following error:

file_tests/multi_func21_fail_to_find_function.clif: 1: expected a function name, e.g. %my_fn
1 file
Error: 1 failure

On line 872 I specify the name of the function to run: And the definition of u1:0 is on line 764.

; print: u1:0()
bjorn3 commented 7 hours ago

I think you need to use a function name like %my_func instead of a function name like u1:0.

abc767234318 commented 7 hours ago

I think you need to use a function name like %my_func instead of a function name like u1:0.

The names of these functions are randomly generated, and they are named using numbers to facilitate subsequent analysis. In addition, other clif files I generated were named in a similar way and did not encounter this error.

bjorn3 commented 6 hours ago

At https://github.com/bytecodealliance/wasmtime/blob/5af89308dc0229ca404cd7000eec694201022e2d/cranelift/reader/src/parser.rs#L2731 the code for parsing ; print directives expects a Token::Name for the name of the function. %my_func is tokenized as Token::Name. u1:0 is not tokenized as Token::Name however. Only tokens that start with %.