Mark symbols as used, fix warnings#28
Merged
Merged
Conversation
Compiler is optimizing-away some event symbols, breaking registration.
This causes a link error (when there are zero events) and runtime
failures (due to zero events getting registered). Fix by marking these
symbols as `#[used]`.
Also fix a few clippy warnings.
tests.rs:
- For clarity, name the "unregister-on-drop" object based on the PROVn
that it is unregistering.
event_generator.rs:
- Add `#[used]` to the `_EH_TRACEPOINT_PTR` symbol so that it is not
optimized-away so we can use it when registering the provider.
- Clippy is warning about unnecessary use of `unsafe`, so remove
`unsafe{ ... }` from the generated code.
provider_generator.rs:
- Add `#[used]` to the `_eh_define_provider_MY_PROVIDER` symbol so that
it is not optimized-away so we don't get linker errors on a provider
with no events.
- Clippy is warning about static_mut_refs so suppress the warning.
Cargo.toml:
- The other projects work on 1.64+, so use that as the baseline.
perf_abi.rs:
- `const transmute_copy` is not supported until 1.74. Nobody really
benefits from this being const, so remove the const.
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical compiler optimization issue where event symbols were being optimized away, causing link errors and runtime failures. The fix adds #[used] attributes to prevent optimization and addresses several clippy warnings.
Key Changes:
- Added
#[used]attributes to_EH_TRACEPOINT_PTRand_eh_define_provider_MY_PROVIDERsymbols to prevent compiler optimization - Removed unnecessary
unsafeblocks in event_generator.rs based on clippy warnings - Lowered rust-version requirement from 1.74 to 1.64 for consistency with other crates
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tracepoint_decode/src/perf_abi.rs | Removed const from from_bytes function (const transmute_copy requires rustc 1.74+) |
| tracepoint_decode/src/enumerator.rs | Fixed documentation indentation for consistency |
| tracepoint_decode/Cargo.toml | Lowered rust-version from 1.74 to 1.64 to match other crates |
| eventheader_macros/src/provider_generator.rs | Added #[used] attribute to prevent symbol optimization and #[allow(static_mut_refs)] to suppress warnings |
| eventheader_macros/src/event_generator.rs | Added #[used] attribute and removed unnecessary unsafe block |
| eventheader_dynamic/src/builder.rs | Fixed documentation indentation for consistency |
| eventheader/tests/tests.rs | Renamed variable from _u to _u1 for clarity that it relates to PROV1 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Robo210
approved these changes
Nov 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compiler is optimizing-away some event symbols, breaking registration. This causes a link error (when there are zero events) and runtime failures (due to zero events getting registered). Fix by marking these symbols as
#[used].Also fix a few clippy warnings.
tests.rs:
event_generator.rs:
#[used]to the_EH_TRACEPOINT_PTRsymbol so that it is not optimized-away so we can use it when registering the provider.unsafe, so removeunsafe{ ... }from the generated code.provider_generator.rs:
#[used]to the_eh_define_provider_MY_PROVIDERsymbol so that it is not optimized-away so we don't get linker errors on a provider with no events.Cargo.toml:
perf_abi.rs:
const transmute_copyis not supported until 1.74. Nobody really benefits from this being const, so remove the const.