You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that the gcc-like coverage tool will get worked with #13072.
Adding compile option -fprofile-arcs -ftest-coverage generates vaild *.gcdo into physical file system and *.gcda into virtual file system. llvm-cov gcov is also working completely using these *.gcdo, *gcda files.
Therefore, I think that we have already a good reason to merge #13072.
Hello, is there any update on this effort?
(We're looking into ways to set up coverage analysis for Google Smart Card Connector, and IIUC currently the only workaround is to switch to the regular clang/gcc, but this doesn't let test the code in the WebAssembly environment.)
I implemented the required routines for wasm code coverage, see Tencent/ncnn#5903
I can use node to run the wasm program, collect gcda data, and combine it with the llvm-cov gcov wrapper to get a reliable coverage report.
It does not require compiler-rt library, you could just add my simplegcov.cpp into your project build, and compile with some special flags for coverage working
Activity
sbc100 commentedon Dec 15, 2020
I don't think we have any direct support for that today, but its sounds like it would be fairly easy to add.
Sounds like it would involve a new option and new compiler-rt variant added to
tools/system_libs.py3d4m-volodymyr commentedon Dec 15, 2020
Is this the place to start looking at https://github.com/emscripten-core/emscripten/blob/master/tools/system_libs.py#L642 ?
I never dealt with the internals of emscripten. Probably will have lots of questions.
Add initial support -fcoverage-mapping support
sbc100 commentedon Dec 18, 2020
I took an initial stab at getting this to work: #13072
It works up until llvm-cov fails to parse the data sections in the wasm executable.
Add initial support -fcoverage-mapping support
nokotan commentedon Oct 27, 2021
It seems that the gcc-like coverage tool will get worked with #13072.
Adding compile option
-fprofile-arcs -ftest-coveragegenerates vaild *.gcdo into physical file system and *.gcda into virtual file system.llvm-cov gcovis also working completely using these *.gcdo, *gcda files.Therefore, I think that we have already a good reason to merge #13072.
emaxx-google commentedon May 8, 2022
Hello, is there any update on this effort?
(We're looking into ways to set up coverage analysis for Google Smart Card Connector, and IIUC currently the only workaround is to switch to the regular clang/gcc, but this doesn't let test the code in the WebAssembly environment.)
AnnieXia commentedon Oct 17, 2022
emcc -fprofile-instr-generate -fcoverage-mapping demo.cppwasm-ld: error: /var/folders/61/x35v93n50_5g1dfjrtprr2dw0000gn/T/emscripten_temp_xjrzk63_/demo_0.o: undefined symbol: __llvm_profile_runtime
have emcc supported code coverage? need help :)
sbc100 commentedon Oct 17, 2022
No, emcc does not yet support this method of doing code coverage. #13072 is a start, but that has yet to land.
junyuecao commentedon Mar 2, 2023
It looks like SanitizerCoverage works. I've tried the demo by replacing clang++ to em++
And the result can be printed as expected.

3d4m-volodymyr commentedon Mar 9, 2023
@junyuecao this is not the same.
bbarwik commentedon Oct 19, 2023
Hey. I've created a tutorial how to generate code coverage for webassembly projects. This one is dedicated for blockchains using WASM VM, however I think it may be useful to you too - https://github.com/hknio/code-coverage-for-webassembly
nihui commentedon Feb 13, 2025
Hi
I implemented the required routines for wasm code coverage, see Tencent/ncnn#5903
I can use node to run the wasm program, collect gcda data, and combine it with the llvm-cov gcov wrapper to get a reliable coverage report.
It does not require compiler-rt library, you could just add my simplegcov.cpp into your project build, and compile with some special flags for coverage working
sample usage guide
Tencent/ncnn#5902 (comment)
wasm code coverage
Tencent/ncnn#5903
the llvm-gcov wrapper