From 2b92e8d7c6bcfaec7d9b8457d9a7e88aa85ee268 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 7 Feb 2024 19:41:23 +0100 Subject: [PATCH] [lto-nix] enable LTO for release builds using Nix --- Cargo.nix | 2 +- Cargo.toml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.nix b/Cargo.nix index 86a20104..c4d4c0ea 100644 --- a/Cargo.nix +++ b/Cargo.nix @@ -45,7 +45,7 @@ else let inherit (rustLib) fetchCratesIo fetchCrateLocal fetchCrateGit fetchCrateAlternativeRegistry expandFeatures decideProfile genDrvsByProfile; profilesByName = { dev = builtins.fromTOML "lto = \"off\"\n"; - release = builtins.fromTOML "debug = true\n"; + release = builtins.fromTOML "codegen-units = 1\nlto = true\nopt-level = \"s\"\nstrip = true\n"; }; rootFeatures' = expandFeatures rootFeatures; overridableMkRustCrate = f: diff --git a/Cargo.toml b/Cargo.toml index baaf5c26..2c39179d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -131,7 +131,8 @@ aws-sdk-config = "1.13" aws-sdk-s3 = "1.14" [profile.dev] -lto = "thin" +#lto = "thin" # disabled for now, adds 2-4 min to each CI build +lto = "off" [profile.release] lto = true