Migration Guide: Feature Flags to Mode Selection
This guide helps you migrate from the old feature flag system to the new mode selection approach.
What Changed?
Old System (Deprecated)
Feature Flags (Cargo.toml):
[features]
default = []
use-bigvm = [] # Required to enable AutoVMBuild Commands:
# With AutoVM (requires feature flag)
cargo build --features use-bigvm
cargo run --features use-bigvm
# Without AutoVM (default, uses Evaluator)
cargo build
cargo runNew System (Current)
Mode Selection (pac.at):
mode: "autovm" # AutoVM is now the DEFAULTBuild Commands:
# AutoVM is default (no feature flag needed)
cargo build
cargo run
# Override at runtime with environment variable
export AUTO_EXECUTION_ENGINE=evaluator
cargo runMigration Steps
Step 1: Remove Feature Flags
Before:
# Cargo.toml
[features]
default = []
use-bigvm = []After:
# Cargo.toml
[features]
default = []
# The use-bigvm feature is kept for compatibility but is a no-op
# You can remove it entirely or keep it for backward compatibility
use-bigvm = [] # Deprecated: has no effectStep 2: Update Build Scripts
Before:
#!/bin/bash
# build.sh
# Build with AutoVM
cargo build --release --features use-bigvmAfter:
#!/bin/bash
# build.sh
# Build with AutoVM (now default)
cargo build --release
# Or explicitly specify mode in pac.at insteadStep 3: Update CI/CD Pipelines
GitHub Actions - Before:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build with AutoVM
run: cargo build --features use-bigvm --releaseGitHub Actions - After:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build (AutoVM is now default)
run: cargo build --release
# Or specify mode in pac.at:
# name: Build with C transpilation
# run: auto trans_c src/main.atStep 4: Update Documentation
Before:
# Building
To build with AutoVM:
\`\`\`bash
cargo build --features use-bigvm
\`\`\`After:
# Building
AutoVM is now the default execution engine:
\`\`\`bash
cargo build
\`\`\`
To override execution mode, use environment variable:
\`\`\`bash
export AUTO_EXECUTION_ENGINE=evaluator
cargo build
\`\`\`
Or specify mode in `pac.at`:
\`\`\`auto
mode: "c" # Transpile to C
\`\`\`Project-by-Project Migration
Pure AutoVM Projects (Simplest)
Before:
# Always built with feature flag
cargo run --features use-bigvmAfter:
# AutoVM is default
cargo run
# Optional: Add pac.at for clarity
echo 'mode: "autovm"' > pac.atC Transpilation Projects
Before:
# Used separate a2c test framework
cargo test -p auto-lang -- transAfter:
// pac.at
name: "embedded_app"
version: "1.0.0"
mode: "c" # Transpile to C
app("embedded_app") {
// All code transpiled to C
}# Now part of standard build process
auto build # Generates .c/.h files
gcc -o firmware main.cMixed-Mode Projects
Before: Not possible (all code used same mode)
After:
// pac.at
name: "mixed_app"
version: "1.0.0"
mode: "autovm"
app("mixed_app") {
dependencies: [
("hal", mode: "c"), # Hardware in C
("crypto", mode: "rust"), # Crypto in Rust
"std:core", # Stdlib in AutoVM
]
}Breaking Changes
1. Feature Flag Removed
Impact: --features use-bigvm is now a no-op
Migration: Remove the flag from all build scripts
2. Default Execution Mode Changed
Impact: Projects that relied on Evaluator by default now use AutoVM
Migration:
- Option A: Explicitly set mode in pac.at:auto
mode: "evaluator" # Use old Evaluator - Option B: Use environment variable:bash
export AUTO_EXECUTION_ENGINE=evaluator - Option C (Recommended): Migrate to AutoVM
3. Runtime Engine Selection
Before: Compile-time selection via feature flags
After: Runtime selection via environment variable
Migration:
# Old way (compile-time)
cargo build --features use-bigvm
# New way (runtime)
export AUTO_EXECUTION_ENGINE=autovm
cargo buildCompatibility Matrix
| Old Command | New Equivalent | Notes |
|---|---|---|
cargo build | cargo build | Now uses AutoVM by default |
cargo build --features use-bigvm | cargo build | Feature flag is no-op |
cargo test -p auto-lang -- trans | auto trans_c file.at | Now part of main CLI |
| N/A | export AUTO_EXECUTION_ENGINE=evaluator | New runtime override |
Rollback Plan
If you encounter issues after migration:
Temporary Rollback
You can temporarily use the old behavior:
# Force Evaluator mode
export AUTO_EXECUTION_ENGINE=evaluator
cargo runPermanent Rollback
Add to your pac.at:
mode: "evaluator"Note: Evaluator mode is deprecated. Use this only for migration purposes.
Verification
After migration, verify your build works:
# 1. Clean build
cargo clean
# 2. Build without feature flags
cargo build
# 3. Run tests
cargo test
# 4. Run application
cargo run
# 5. Verify execution mode
cargo run -- --versionCommon Issues and Solutions
Issue: Build Fails After Migration
Symptom: Compilation errors after removing --features use-bigvm
Cause: Code relied on AutoVM-specific features
Solution:
- Check that
pac.athas correct mode specified - Verify all dependencies support selected mode
- Check for missing FFI declarations
Issue: Performance Changed
Symptom: Application slower/faster after migration
Cause: Different execution mode being used
Solution:
- Verify which mode is active: Check build output
- Explicitly set desired mode in
pac.at - Use environment variable override for testing
Issue: Tests Failing
Symptom: Tests pass with old system, fail with new
Cause: Tests relied on specific execution mode
Solution:
// In tests, explicitly set mode
#[test]
fn test_my_feature() {
// Force AutoVM mode for this test
std::env::set_var("AUTO_EXECUTION_ENGINE", "autovm");
// Test code here
}Best Practices After Migration
1. Always Specify Mode in pac.at
// Recommended
mode: "autovm" // Explicit is better than implicit2. Use Environment Variables for CI
# .github/workflows/test.yml
env:
AUTO_EXECUTION_ENGINE: autovm # Explicit for CI
steps:
- run: cargo test3. Document Mode Requirements
// pac.at
// This project requires AutoVM for performance
mode: "autovm"4. Test Multiple Modes
# Test with AutoVM
cargo test
# Test with Evaluator (for compatibility)
export AUTO_EXECUTION_ENGINE=evaluator
cargo testTimeline
- ✅ Phase 1 (Complete): AutoVM made default, feature flags deprecated
- ✅ Phase 2-5 (Complete): Mode selection infrastructure implemented
- 🔄 Current: Migration and documentation
- 🔮 Future: Feature flags may be removed entirely (backward compatibility period)
Get Help
If you encounter issues during migration:
Check the guides:
Verify your setup:
bash# Check which engine is being used auto --version # Check pac.at syntax auto validate pac.atReport issues:
- GitHub: https://github.com/your-repo/issues
- Include:
pac.at, error messages, build output
Summary
| Aspect | Old System | New System |
|---|---|---|
| Configuration | Feature flags in Cargo.toml | Mode in pac.at |
| Default | Evaluator | AutoVM |
| Override | Compile-time (feature flags) | Runtime (env var) |
| Mixed Modes | Not supported | Fully supported |
| C Transpilation | Separate test framework | Integrated in pac.at |
Next Steps
- ✅ Read this guide
- ✅ Update your
pac.atwith desired mode - ✅ Remove
--features use-bigvmfrom build scripts - ✅ Test your application
- ✅ Update documentation
Welcome to the new AutoVM-first world! 🚀
See Also: