-
Notifications
You must be signed in to change notification settings - Fork 924
fix(build): Meaningful compilation errors when no backend feature enabled #5767
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
fix(build): Meaningful compilation errors when no backend feature enabled #5767
Conversation
Currently, when no backend is enabled, we get a horrible mess of errors. This commit: * Makes sure the wasmer-compiler crate can be compiled withou the compiler feature enabled * Makes sure the compiler crate fails to compile with a single meaningful message if neither core nor std features are enabled * Makes sure the api crate fails to compile with a single meaninful error when no backend is enabled Note: our current module structure doesn't make it trivial to do this cleanly. I went for an approach that has more duplication, but is minimally invasive.
|
LGTM, but can we turn the overly verbose |
Done that. @theduke please check my change hasn't changed the expected build behavior? |
There was a problem hiding this 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 improves compilation error messages when required backend features are not enabled. Currently, missing features result in cascading compilation errors that are difficult to debug. The changes introduce meaningful compile_error! messages and feature-gate code appropriately.
- Adds compile_error! macros to catch missing backend/compiler feature combinations early
- Introduces cfg_std_or_core! and cfg_compiler! macros to reduce duplication in conditional compilation
- Adds feature = "compiler" guards to perfmap-related functions that depend on compiler infrastructure
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lib/compiler/src/lib.rs | Introduces cfg_std_or_core! macro and wraps module declarations to ensure they're only compiled when std or core features are enabled |
| lib/compiler/src/engine/inner.rs | Adds feature = "compiler" guard to register_perfmap function which accesses compiler-specific fields |
| lib/compiler/src/engine/artifact.rs | Adds feature = "compiler" guard to register_perfmap call site for consistency |
| lib/api/src/lib.rs | Adds compile_error! checks for missing backend features, introduces cfg_compiler! macro to conditionally compile modules based on enabled backends |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Currently, when no backend is enabled, we get a horrible mess of errors.
This commit:
compiler feature enabled
meaningful message if neither core nor std features are enabled
error when no backend is enabled
Note: our current module structure doesn't make it trivial to do this
cleanly.
I went for an approach that has more duplication, but is minimally
invasive.