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

evmrs: use weak linkage for profiling functions #932

Merged
merged 1 commit into from
Nov 5, 2024
Merged

Conversation

LorenzSchueler
Copy link
Collaborator

This PR uses weak linkage for all coverage functions. This way linking will always success and the dump-cov feature is no longer needed. Furthermore, Go can now set the filename which makes it possible to remove the hard coded value from the Jenkins file. Because weak linkage is only possible in nightly rust, this is done in C functions which get called from Rust.

@LorenzSchueler LorenzSchueler marked this pull request as ready for review November 5, 2024 13:31
@LuisPH3
Copy link
Contributor

LuisPH3 commented Nov 5, 2024

This PR uses weak linkage for all coverage functions. This way linking will always success and the dump-cov feature is no longer needed. Furthermore, Go can now set the filename which makes it possible to remove the hard coded value from the Jenkins file. Because weak linkage is only possible in nightly rust, this is done in C functions which get called from Rust.

I need some more explanation about the weak linkage, and how it does affect the go code. can you link references or develop a little more how does this mechanism executes a dump? describe a trace of events ?

@LorenzSchueler
Copy link
Collaborator Author

The problem is that because evmrs and evmzero are shared libs and not executables, the profiling data is not dumped automatically. Therefore, Go has to call a function which does this. Both evmzero and evmrs expose such a function.
Before this PR evmrs had a feature dump-cov which if enabled exposed this function (which internally calls llvm injected functions). It was assumed that dump-cov gets only enabled if the shared lib was compiled with instrumentation. if this was not the case linking would fail.
With this PR rust always exposes this function. This Rust function then calls a C function which calls a the llvm function, which now is only linked weakly. If the function is available it is called otherwise it is basically a no op.

@LuisPH3 LuisPH3 merged commit d040328 into main Nov 5, 2024
12 checks passed
@LuisPH3 LuisPH3 deleted the lorenz/cov branch November 5, 2024 15:32
LorenzSchueler added a commit that referenced this pull request Nov 5, 2024
@LorenzSchueler LorenzSchueler mentioned this pull request Nov 11, 2024
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