Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Add support for wasm-pack test #337

Open
aDogCalledSpot opened this issue Jan 15, 2024 · 0 comments · May be fixed by #338
Open

[Proposal] Add support for wasm-pack test #337

aDogCalledSpot opened this issue Jan 15, 2024 · 0 comments · May be fixed by #338
Labels
C-enhancement Category: A new feature or an improvement for an existing one

Comments

@aDogCalledSpot
Copy link

aDogCalledSpot commented Jan 15, 2024

Follows up from #221.

I'm currently working on generating profraw data from wasm-pack test: rustwasm/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.

@aDogCalledSpot aDogCalledSpot linked a pull request Jan 16, 2024 that will close this issue
@taiki-e taiki-e added the C-enhancement Category: A new feature or an improvement for an existing one label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: A new feature or an improvement for an existing one
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants