Skip to content

Construct DefaultInfo directly for cc_binary - #877

Open
dzbarsky wants to merge 3 commits into
bazelbuild:mainfrom
dzbarsky:codex/direct-build-info-default-info
Open

dzbarsky wants to merge 3 commits into
bazelbuild:mainfrom
dzbarsky:codex/direct-build-info-default-info

Conversation

@dzbarsky

@dzbarsky dzbarsky commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Return DefaultInfo from cc_binary_impl for cc_binary and non-legacy cc_test. Keep the existing struct for legacy cc_tes and new cc_test where non-custom runner needs its executable and runfiles.

In nine paired analysis-only runs over 4,000 cc_binary targets on Bazel 9.2, median analysis time was 2.45 s before and 2.35 s after. The change removes one temporary struct per cc_binary.

Return DefaultInfo from cc_binary_impl for cc_binary and append it directly. Keep the existing struct for cc_test, whose runner callback needs its executable and runfiles.

In nine paired analysis-only runs over 4,000 cc_binary targets on Bazel 9.2, median analysis time was 2.45 s before and 2.35 s after; the runs varied and phase-end heap did not improve. The change removes one temporary struct per cc_binary.

Validated with buildifier and 70 cc_binary/linkstamp analysis tests.
Have the bundled cc_test runner opt in to receiving DefaultInfo from cc_binary_impl and return that provider directly. Preserve the struct argument for legacy cc_test and custom runners that do not opt in. Name the cc_binary provider default_info at the append site.

The runfiles and configured-target suites passed (63 tests); an unmarked custom runner also received the struct and passed. Buildifier passed.

In two paired JFR analysis runs over 2,000 cc_test targets, Java allocation was 2018/2004 MiB and 2071/2121 MiB (baseline/changed). Phase-end heap was 73.64/73.58 and 74.17/74.19 MiB. These runs do not establish a measurable memory reduction.
Bazel 7 and 8 load their own cc_binary_impl from virtual builtins and pass a struct to the bundled default test runner. Convert that struct to DefaultInfo for those versions; reuse DefaultInfo directly when cc_binary_impl supplies one.

Reproduced the Buildkite executable/DefaultInfo analysis failure on Bazel 7.7.1. The failing target now analyzes on Bazel 7.7.1 and Bazel 8.2.1; 63 affected tests pass on Bazel 9.2.0. Buildifier and git diff --check pass.
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