Skip to content
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

Add feature flags to Noir #6963

Open
michaeljklein opened this issue Jan 6, 2025 · 1 comment
Open

Add feature flags to Noir #6963

michaeljklein opened this issue Jan 6, 2025 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@michaeljklein
Copy link
Contributor

Problem

  • It's ergonomic to include assertions and debugging helpers within the functions/methods to test, but this approach currently either requires duplication or ad-hoc abstractions to enable/disable code.
  • Most dead code isn't eliminated until fairly late in compilation (?)

See description of how features work in Rust.

Happy Case

Minimal useful version:

  • Support declaring features in Nargo.toml
    • [features] section
    • feature_name = ["included_feature1", "included_feature2", ..]
  • Support #[cfg(feature = "feature_name")] on top-level declarations and filter out unused declarations after parsing
  • Support let _: bool = cfg!(feature = "feature_name"); or similar for use inside declarations
  • Support nargo CLI option: --features "feat1 feat2"

Outside original PR:

  • Support all/any/not in cfg
  • default feature
  • Support other CLI options: --all-features, --no-default-features

Workaround

Yes

Workaround Description

Maintain multiple versions of declarations that need different features.

Additional Context

No response

Project Impact

Nice-to-have

Blocker Context

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@jfecher
Copy link
Contributor

jfecher commented Jan 7, 2025

Wonder if this will be compatible with our current use of attributes & macros. Since we collect & typecheck functions before we apply attributes to them, if a function is #[cfg(...)]'d out of the program, we'd still issue errors for it. E.g. "duplicate function with name foo", or feature-specific functions not being available within its body, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 📋 Backlog
Development

No branches or pull requests

2 participants