Skip to content

Add support for -fcoverage-mapping support #24160

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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

arsnyder16
Copy link
Contributor

@arsnyder16 arsnyder16 commented Apr 21, 2025

Main introduction is porting llvm-project/compiler_rt/lib/profile into system/lib/compiler_rt/lib/profile

Related
#13072
llvm/llvm-project#111332

No modifications were required for what was ported. llvm-cov worked fine for me with simple project.

  • -g is required to produce a properly instrumented binary error: failed to load coverage: 'my.wasm': no coverage data found

sbc100 and others added 12 commits December 26, 2020 13:23
This is enought make it work up until llvm-cov tries to read the
named data sections in the binary and can't find them.  For this
final part to work we probably need to switch the object format to
using multiple code and data sections:
WebAssembly/tool-conventions#138

Not sure if its worth submitting this part in isolation without
a fully working solution?

See emscripten-core#13046
# Conflicts:
#	emcc.py
#	tests/test_core.py
#	tools/shared.py
#	tools/system_libs.py
@@ -23,6 +23,7 @@
('lib', 'lsan'),
('lib', 'ubsan'),
('lib', 'ubsan_minimal'),
('lib', 'profile'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make sure you copy these files from compiler-rt at the same revision as the existing file?

Based on system/lib/compiler-rt/readme.txt it looks like they should be copied from https://github.com/llvm/llvm-project/compare/llvmorg-19.1.6

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbc100 I was under the impression i need to sync with https://github.com/emscripten-core/llvm-project/tree/main/compiler-rt/lib/profile

Version 19 will not work, as this requires llvm/llvm-project#111332 + a few more commits. Basically we need compiler-rt profile 20+

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is required or triggers a creation of emscripten-lib-20 branch? We will need both compiler-rt source based on 20+ along with version 20+ of llvm-profdata and llvm-cov for the tests

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rather complex process that we have to perform each time a new LLVM release is made. I opened #24182 to get it done.

@arsnyder16 arsnyder16 force-pushed the arsnyder16-fcoverage branch from f1a383d to 10bbd61 Compare April 21, 2025 20:46
@arsnyder16 arsnyder16 marked this pull request as ready for review April 23, 2025 18:17
@@ -23,6 +23,7 @@
('lib', 'lsan'),
('lib', 'ubsan'),
('lib', 'ubsan_minimal'),
('lib', 'profile'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbc100 I was under the impression i need to sync with https://github.com/emscripten-core/llvm-project/tree/main/compiler-rt/lib/profile

Version 19 will not work, as this requires llvm/llvm-project#111332 + a few more commits. Basically we need compiler-rt profile 20+

@@ -754,6 +754,8 @@ class OFormat(Enum):
LLVM_OBJCOPY = os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-objcopy')))
LLVM_STRIP = os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-strip')))
WASM_LD = os.path.expanduser(build_llvm_tool_path(exe_suffix('wasm-ld')))
LLVM_PROFDATA = 'llvm-profdata-20'#os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-profdata')))
LLVM_COV = 'llvm-cov-20'#os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-cov')))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do we get these included?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbc100 Can you advise how to do this? Does it require first a change here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants