Skip to content

Conversation

@idigdoug
Copy link
Collaborator

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.

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.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_PTR and _eh_define_provider_MY_PROVIDER symbols to prevent compiler optimization
  • Removed unnecessary unsafe blocks 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.

@idigdoug idigdoug merged commit 4d3a743 into main Nov 26, 2025
11 checks passed
@idigdoug idigdoug deleted the TheOneThatGetsUsed branch November 26, 2025 21:40
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