@@ -132,6 +132,19 @@ build:san-all --//bazel:sanitizer_mode=all
132132build:san-all --copt=-fsanitize=address,undefined,vptr,function,alignment
133133build:san-all --linkopt=-fsanitize=address,undefined,vptr,function,alignment
134134
135+ # LTO mixin: enable LTO for C++ and Rust. Usually mixed in with
136+ # PGO + release, but should work with any.
137+ build:lto --copt -flto=thin
138+ build:lto --linkopt -flto=thin
139+ build:lto --@rules_rust//rust/settings:lto=fat
140+ build:lto --@rules_rust//rust/settings:extra_rustc_flag=-Ccodegen-units=1
141+ # I've seen others claim these flags help with LTO and the final binary, but these also
142+ # require a specific version of clang and I don't really want to tie rustc version with
143+ # clang version.
144+ # build:lto --@rules_rust//rust/settings:extra_rustc_flag=-Clinker-plugin-lto
145+ # build:lto --@rules_rust//rust/settings:extra_rustc_flag=-Cembed-bitcode=yes
146+ # build:lto --@rules_rust//rust/settings:extra_rustc_flag=-Clink-arg=-fuse-ld=lld
147+
135148################################################
136149# PRIMARY BUILD MODES
137150#
@@ -251,23 +264,10 @@ build:release --host_cxxopt=-U_LIBCPP_HARDENING_MODE
251264build:release --cxxopt=-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE
252265build:release --host_cxxopt=-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE
253266
254- # Separate PGO configs to be combined with release
255-
256- # Enable LTO only in PGO build to save time in other builds
257- build:pgo-base --//src/v/redpanda:lto=True
258- build:pgo-base --copt -flto=thin
259- build:pgo-base --@rules_rust//rust/settings:lto=fat
260- build:pgo-base --@rules_rust//rust/settings:extra_rustc_flag=-Ccodegen-units=1
261- # I've seen others claim these flags help with LTO and the final binary, but these also
262- # require a specific version of clang and I don't really want to tie rustc version with
263- # clang version.
264- # build:pgo-base --@rules_rust//rust/settings:extra_rustc_flag=-Clinker-plugin-lto
265- # build:pgo-base --@rules_rust//rust/settings:extra_rustc_flag=-Cembed-bitcode=yes
266- # build:pgo-base --@rules_rust//rust/settings:extra_rustc_flag=-Clink-arg=-fuse-ld=lld
267267
268268# Instrumentation/training step
269269# Empty arg is intentional, we provide the path via env var at run time
270- build:pgo-instrument --config=pgo-base --fdo_instrument=
270+ build:pgo-instrument --config=lto --fdo_instrument=
271271
272272# Final/Optimization build step
273273
@@ -278,7 +278,7 @@ build:pgo-instrument --config=pgo-base --fdo_instrument=
278278
279279# bazel seems to pass -fprofile-correction unconditionally but that only exists
280280# in gcc so need to make clang ignore it
281- build:pgo-optimize --config=pgo-base --copt -Wno-ignored-optimization-argument
281+ build:pgo-optimize --config=lto --copt -Wno-ignored-optimization-argument
282282
283283
284284build:stamp --stamp --workspace_status_command=./bazel/stamp_vars.sh
0 commit comments