-
-
Notifications
You must be signed in to change notification settings - Fork 66
Description
Follows up from #221.
I'm currently working on generating profraw data from wasm-pack test
: wasm-bindgen/wasm-bindgen#3782
TLDR: It will be possible to generate a wasm.profraw
with the following command:
RUSTFLAGS="-Cinstrument-coverage -Zno-profiler-runtime --emit=llvm-ir" wasm-pack test --chrome --headless --coverage --profraw-out=wasm.profraw
I would to add support for this operation in cargo-llvm-cov
and would therefore like to discuss what the interface and the implementation for this should look like.
Interface
For the interface, I propose adding a --wasm
flag to llvm-cov test
which then runs wasm-pack test
instead of cargo test
.
Implementation
If the --wasm
flag is present in the llvm-cov test
command, then we execute the command written above and dump the profraw in the usual llvm-cov-target/
.
LLVM currently isn't able to read the debuginfo from the .wasm, which is why we use --emit=llvm-ir
in the RUSTFLAGS
. We now need to generate a native .o
with clang
, so llvm-cov
can map the hits in the profdata back to lines in the source code.
clang target/wasm32-unknown-unknown/debug/deps/{file_name}.ll -Wno-override-module -c -o target/llvm-cov-target/{file_name}.o
Merging the profdata should work just before.
Reporting needs to additionally pass our generated .o
as -object
to llvm-cov
.
Let me know what you think! I'm happy to submit a PR if this looks good to everyone.