Skip to content

Add support for -fcoverage-mapping support - #24160

Merged
sbc100 merged 32 commits into
emscripten-core:mainfrom
arsnyder16:arsnyder16-fcoverage
Jun 16, 2025
Merged

sbc100 merged 32 commits into
emscripten-core:mainfrom
arsnyder16:arsnyder16-fcoverage

Conversation

@arsnyder16

@arsnyder16 arsnyder16 commented Apr 21, 2025 •

Copy link
Copy Markdown
Contributor

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
Comment thread tools/system_libs.py Resolved
Comment thread system/lib/update_compiler_rt.py Resolved
@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
Comment thread tools/system_libs.py Resolved
Comment thread tools/system_libs.py Resolved
Comment thread system/lib/update_compiler_rt.py Resolved
Comment thread tools/system_libs.py Resolved
Comment thread tools/shared.py Resolved
@arsnyder16
arsnyder16 force-pushed the arsnyder16-fcoverage branch from 7c189ff to 56a1d3a Compare May 30, 2025 16:50
@arsnyder16

Copy link
Copy Markdown
Contributor Author

@sbc100 I think this is ready, not sure why some of the test failures, seems unrelated.

@sbc100 sbc100 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great! Thanks for working on this.

Comment thread test/test_core.py Resolved
Comment thread test/test_core.py Resolved

@sbc100 sbc100 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you add this to the ChangeLog?

Comment thread test/test_core.py Resolved
@arsnyder16

Copy link
Copy Markdown
Contributor Author

Can you add this to the ChangeLog?

Added. Let me know if there is anything else i should specifically call out

Comment thread ChangeLog.md Resolved
@sbc100

sbc100 commented Jun 16, 2025

Copy link
Copy Markdown
Collaborator

Just to confirm, the new files are taken from the emscripten-libs-20 branch in llvm?

@arsnyder16

Copy link
Copy Markdown
Contributor Author

Just to confirm, the new files are taken from the emscripten-libs-20 branch in llvm?

Correct, i used ./update_compiler_rt.py ~/em-llvm-project with a local clone of that branch

@sbc100
sbc100 merged commit 645f5b1 into emscripten-core:main Jun 16, 2025
aheejin added a commit to aheejin/emscripten that referenced this pull request Jan 23, 2026
`include/profile` and `lib/profile` have been added to compiler-rt in
 emscripten-core#24160, but only `lib/profile` has been added to
`update_compiler_rt.py`, which caused this directory missing from the
subsequent LLVM library updates.
aheejin added a commit that referenced this pull request Jan 23, 2026
`include/profile` and `lib/profile` have been added to compiler-rt since
#24160, but only `lib/profile` was added to `update_compiler_rt.py`,
which caused this directory to be missing from the subsequent LLVM
library updates.
inolen pushed a commit to inolen/emscripten that referenced this pull request Feb 13, 2026
…pten-core#26152)

`include/profile` and `lib/profile` have been added to compiler-rt since
emscripten-core#24160, but only `lib/profile` was added to `update_compiler_rt.py`,
which caused this directory to be missing from the subsequent LLVM
library updates.
@kripken

kripken commented Jun 30, 2026

Copy link
Copy Markdown
Member

This test has broken on latest LLVM. Example roll:

https://logs.chromium.org/logs/emscripten-releases/buildbucket/cr-buildbucket/8677571055433179489/+/u/Emscripten_testsuite__cores_/stdout

The output includes this:

warning: default.profraw: raw profile version mismatch: Profile uses raw profile format version = 10; expected version = 11
PLEASE update this tool to version in the raw profile, or regenerate raw profile with expected version.
error: no profile can be merged

@sbc100

sbc100 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

I looks like a version number for the profile data in the compiler was bumped in llvm/llvm-project#190708.

Our compiler-rt comes from the older/stable version of LLVM so they are not somehow incompatible.

@sbc100

sbc100 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Hmm, its sounds like we are going to need to start updating our compiler-rt to tip-of-tree, like we do for clang itself.

hoodmane added a commit to hoodmane/emscripten that referenced this pull request Nov 13, 2026
Emscripten emscripten-core#24160 (released in 4.0.11) started globbing the
compiler-rt profile runtime (system/lib/compiler-rt/lib/profile/*)
into libcompiler_rt. Because Pyodide links the main module with
-sMAIN_MODULE=1, Emscripten wraps all system libraries in
--whole-archive, so InstrProfilingRuntime.o is force-linked even
though nothing references __llvm_profile_runtime. Its global
constructor registers an atexit handler that writes an (empty)
default.profraw to the cwd on every interpreter exit, and adds
~1MB to pyodide.asm.wasm.

Revert the libcompiler_rt part of emscripten-core#24160 so the profile runtime is
only linked when the user actually opts into instrumentation.

Refs: pyodide/pyodide#6339
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.

3 participants