Skip to content

build: hoist RUSTFLAGS=--cfg tokio_unstable into workspace cargo config#716

Open
Richard1048576 wants to merge 1 commit into
mainfrom
fix/tokio-unstable-cargo-config
Open

build: hoist RUSTFLAGS=--cfg tokio_unstable into workspace cargo config#716
Richard1048576 wants to merge 1 commit into
mainfrom
fix/tokio-unstable-cargo-config

Conversation

@Richard1048576
Copy link
Copy Markdown
Contributor

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:

Where How
`.github/workflows/release.yml` `env: RUSTFLAGS:`
`.github/workflows/rust-ci.yml` `env: RUSTFLAGS:`
`.github/workflows/unit-test.yml` `env: RUSTFLAGS:`
`Makefile` two targets ahead of the line, two missing it
`cluster/deploy.sh` inline per-cargo-build call
`.agents/*` docs / `cluster/docs/gcp-secret-manager.md` / `bin/gravity_cli/README.md` manual one-liner reminder

Why this matters now

This sprawl bit two operators in the past week:

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

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

  • CI green on this PR (existing workflows still build)
  • `unset RUSTFLAGS && cargo build -p gravity_node` succeeds on a fresh clone (was failing before)
  • `make bench` succeeds without the operator having to set RUSTFLAGS in their shell (was implicitly broken before)
  • No change in output binary for gravity_node / gravity_cli (only the entry-point env handling differs)

🤖 Generated with Claude Code

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

1 participant