oxidecomputer / oxidecomputer/usdt
Cross-compilation support
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 145
- Forks
- 15
- Avg merge
- 14m
- Merged PRs (30d)
- 6
Description
Mostly a thought for the future, but does Oxide have any need or interest in cross-compilation support for usdt?
The current attribute macro method uses cfg's to select the correct probe generator to use, but those cfg's are forced to happen during the macro crate's compilation which is always compiled on the host. In a cross-compilation scenario this means that the wrong probe generator is chosen and errors ensue (if one is lucky).
A fundamental requirement for cross-compilation would be that the usdt-impl couldn't be chosen based on cfg's; all platforms would need to be capable of producing the usdt-impls of other platforms. This isn't much of a technical problem, I believe, but definitely a code organisational problem.
Some possible ways to achieve cross-compilation would be:
- Simply always emit all probe variants in target-specific cfg!() blocks. Simple, but possibly not great for build times or for debugging the macro expansion: 10 probes would today already expand to around 5000 lines of code.
- Emit target-specific cfg!() blocks containing the original (or equivalent)
mod provider { ...fns... }blocks with parametrised attribute macros on them,#[usdt::provider(linux, x86_64)]style, and use these parameters to choose the actual implementation. - Possibly some kind of environment variable shenanigans to parametrise the macro build?
- Explicitly disable cross-compilation by detecting it (somehow?) and using the empty impl in those cases.
(As you may guess, it turns out my downstream users were doing cross-compilation and my taking up USDTs has thus caused them some consternation, which is why I'm pondering about this :) )
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the attribute macro method and the usdt-impl cfg selections described in the issue, then examine how macro-crate compilation differs from the cross-compilation target. Compare the proposed target-specific generation and parameterized provider approaches. Done means cross-compilation selects the correct target probe generator without host-based cfg errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100