Skip to content

bazel: simplify lto flags#29600

Merged
travisdowns merged 1 commit intoredpanda-data:devfrom
travisdowns:td-lto
Feb 15, 2026
Merged

bazel: simplify lto flags#29600
travisdowns merged 1 commit intoredpanda-data:devfrom
travisdowns:td-lto

Conversation

@travisdowns
Copy link
Member

Introduce --config=lto mixin which sets -flto=thin for C++ compile and link. Remove src/v/redpanda specific handling of the link flag, we pass this to all links now. This is effectively a no-op as lld will use LTO mode when inputs have only IR anyway.

You can mix --config=lto with other build modes (most usefully, release) even without PGO.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v25.3.x
  • v25.2.x
  • v25.1.x

Release Notes

  • none

# LTO mixin: enable LTO for C++ and Rust. Usually mixed in with
# PGO + release, but should work with any.
build:lto --copt -flto=thin
build:lto --linkopt -flto=thin
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly a move (cut + paste) of the below, plus renaming, but this line is new.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the LTO (Link Time Optimization) configuration in Bazel to be more flexible and consistent. Previously, LTO was only enabled for the redpanda binary via a BUILD-level flag. Now, LTO is available as a reusable config mixin (--config=lto) that can be combined with any build mode.

Changes:

  • Introduced a new --config=lto mixin in .bazelrc that enables thin LTO for C++ and fat LTO for Rust
  • Removed the redpanda-specific lto bool_flag and use_lto config_setting from src/v/redpanda/BUILD
  • Updated PGO configs to use --config=lto instead of the deprecated --config=pgo-base

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
.bazelrc Added new --config=lto mixin with C++ and Rust LTO settings; updated pgo-instrument and pgo-optimize to use the new lto config
src/v/redpanda/BUILD Removed redpanda-specific LTO flag and linkopts selection logic, now handled globally via .bazelrc

Introduce --config=lto mixin which sets -flto=thin for C++ compile and
link. Remove src/v/redpanda specific handling of the link flag, we
pass this to all links now. This is effectively a no-op as lld will
use LTO mode when inputs have only IR anyway.

You can mix --config=lto with other build modes (most usefully, release)
even without PGO.
@vbotbuildovich
Copy link
Collaborator

CI test results

test results on build#80512
test_class test_method test_arguments test_kind job_url test_status passed reason test_history
RedpandaNodeOperationsSmokeTest test_node_ops_smoke_test {"cloud_storage_type": 1, "mixed_versions": false} integration https://buildkite.com/redpanda/redpanda/builds/80512#019c54cb-b083-4f26-90f3-6795de368cf2 FLAKY 9/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.0815, p0=0.5725, reject_threshold=0.0100. adj_baseline=0.2250, p1=0.3050, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=RedpandaNodeOperationsSmokeTest&test_method=test_node_ops_smoke_test
TxAtomicProduceConsumeTest test_basic_tx_consumer_transform_produce {"with_failures": true} integration https://buildkite.com/redpanda/redpanda/builds/80512#019c54cb-b08c-4945-8128-c97a81b48d87 FLAKY 10/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.0051, p0=1.0000, reject_threshold=0.0100. adj_baseline=0.1000, p1=0.3487, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=TxAtomicProduceConsumeTest&test_method=test_basic_tx_consumer_transform_produce

@travisdowns travisdowns merged commit a38876d into redpanda-data:dev Feb 15, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants