291d884
diff --git a/config/makefiles/rust.mk b/config/makefiles/rust.mk
291d884
--- a/config/makefiles/rust.mk
291d884
+++ b/config/makefiles/rust.mk
291d884
@@ -61,7 +61,11 @@
291d884
 # Enable link-time optimization for release builds, but not when linking
291d884
 # gkrust_gtest.
291d884
 ifeq (,$(findstring gkrust_gtest,$(RUST_LIBRARY_FILE)))
291d884
+# Pass -Clto for older versions of rust, and CARGO_PROFILE_RELEASE_LTO=true
291d884
+# for newer ones that support it. Combining the latter with -Clto works, so
291d884
+# set both everywhere.
291d884
 cargo_rustc_flags += -Clto
291d884
+export CARGO_PROFILE_RELEASE_LTO=true
291d884
 endif
291d884
 endif
291d884
 endif
291d884