Skip to content

Conversation

@theduke
Copy link
Contributor

@theduke theduke commented Sep 29, 2025

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.

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.
@Arshia001
Copy link
Member

LGTM, but can we turn the overly verbose cfgs into a macro please?

@theduke theduke changed the title fix(build): Meaningful backend compilation errors in api fix(build): Meaningful compilation errors when no backend feature enabled Sep 29, 2025
Copilot AI review requested due to automatic review settings November 25, 2025 16:09
@marxin
Copy link
Contributor

marxin commented Nov 25, 2025

LGTM, but can we turn the overly verbose cfgs into a macro please?

Done that.

@theduke please check my change hasn't changed the expected build behavior?

Copy link
Contributor

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

@marxin marxin enabled auto-merge (squash) December 18, 2025 13:25
@marxin marxin merged commit a5f4b5d into main Dec 18, 2025
236 of 258 checks passed
@marxin marxin deleted the run-745-proper-compilation-error-when-no-backend-enabled branch December 18, 2025 13:29
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.

5 participants