build: hoist RUSTFLAGS=--cfg tokio_unstable into workspace cargo config#716
Open
Richard1048576 wants to merge 1 commit into
Open
build: hoist RUSTFLAGS=--cfg tokio_unstable into workspace cargo config#716Richard1048576 wants to merge 1 commit into
Richard1048576 wants to merge 1 commit into
Conversation
The aptos-core fork that gravity_node and gravity_cli depend on uses several tokio APIs gated behind `#[cfg(tokio_unstable)]`: RuntimeMetrics, tokio-console integration, named tasks. Dozens of files in the dependency graph reference these. Without the cfg flag, the build fails with `unresolved import: this item is gated behind a cfg(tokio_unstable) flag`. Until now the flag had to be repeated at every build entry point: - .github/workflows/release.yml env: RUSTFLAGS: - .github/workflows/rust-ci.yml env: RUSTFLAGS: - .github/workflows/unit-test.yml env: RUSTFLAGS: - Makefile two targets ahead, two missing - cluster/deploy.sh inline per-cargo-build call - .agents/* docs / cluster docs documented as a manual flag - bin/gravity_cli/README.md manual one-liner reminder This sprawl bit two operators recently. A team member building gravity_cli manually forgot the flag; the build failed but a `| tail` in their wrapper masked cargo's non-zero exit (bash default behavior; needs `set -o pipefail`). The Makefile is also internally inconsistent — the `bench` and `kvstore` targets transitively depend on aptos-* and DO need tokio_unstable, but their lines don't set RUSTFLAGS, so they're broken today for anyone running `make bench` from a clean checkout. Fix: workspace-level `.cargo/config.toml` with `[build] rustflags`. Any `cargo build / test / check / clippy` invocation, in CI or outside, picks the flag up automatically. An explicit `RUSTFLAGS` env var still takes precedence (cargo's documented merge order), so the existing per-workflow RUSTFLAGS values keep working unchanged — they're just now belt-and- suspenders rather than the only line of defense. The existing duplicates in workflows / Makefile / scripts are intentionally NOT removed in this PR — the goal here is to fix the silent-failure surface without touching every entry point. Cleanup of the redundant RUSTFLAGS lines can land in a follow-up once this config has soaked. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The aptos-core fork that gravity_node and gravity_cli depend on uses several tokio APIs gated behind `#[cfg(tokio_unstable)]` — `RuntimeMetrics`, tokio-console integration, named tasks. Dozens of files reference these. Without the cfg flag the build fails with `unresolved import: this item is gated behind a cfg(tokio_unstable) flag`.
Until now the flag has been repeated at every build entry point:
Why this matters now
This sprawl bit two operators in the past week:
A team member building gravity_cli manually forgot the flag. The build failed, but a
| tailin their wrapper masked cargo's non-zero exit (bash default behavior; you'd need `set -o pipefail` to catch it). They saw "looks fine" output and proceeded with a binary that wasn't actually built. Took a while to notice.The Makefile is internally inconsistent. The `bench` and `kvstore` targets transitively depend on `gaptos.workspace` and `aptos-*`, so they DO need `tokio_unstable`. But their Makefile lines don't set `RUSTFLAGS`. Anyone running `make bench` from a clean checkout today gets a compile failure. Existing local Makefile runs probably work only because the operator had `RUSTFLAGS` in their shell already.
Fix
Workspace-level `.cargo/config.toml` with:
```toml
[build]
rustflags = ["--cfg", "tokio_unstable"]
```
Any `cargo build / test / check / clippy` invocation, in CI or on a fresh checkout, picks the flag up automatically.
Compatibility
Cargo's documented merge order: an explicit `RUSTFLAGS` env var takes precedence over the config file. So the existing per-workflow `RUSTFLAGS` declarations keep working unchanged — they're now belt-and-suspenders rather than the only line of defense. No CI behavior changes.
Scope
This PR is intentionally minimal: add the config, don't touch the duplicate `RUSTFLAGS` sites. Cleanup of the redundant lines can land in a follow-up once this config has soaked through a few CI runs and is proven to be the source of truth.
Test plan
🤖 Generated with Claude Code