From 705e5d6c26ba587b3cd127446264e498f66d087b Mon Sep 17 00:00:00 2001 From: Aron Heinecke Date: Fri, 13 Aug 2021 15:40:10 +0200 Subject: [PATCH] optimize release binary --- .cargo/config.toml | 2 ++ Cargo.toml | 3 +++ README.md | 4 ++++ 3 files changed, 9 insertions(+) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..d5135e9 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +rustflags = ["-C", "target-cpu=native"] \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 7808752..a9eb76e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,9 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[profile.release] +lto = true + [dependencies] toml = "0.5" serde = { version = "1.0", features = ["derive"] } diff --git a/README.md b/README.md index 659711c..ecefb0f 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,10 @@ Then run `cargo build --release` .exe/elf is inside target/release/ You can also run `cargo run --release` instead to directly build & execute the resulting binary. +### Build optimization + +The default release build is heavily optimized, using native target-cpu instructions and LTO. You can disable LTO in the Cargo.toml under `[profile.release]`, which can reduce the build time by a lot. And you can disable the target-cpu flags in `.cargo/config.toml`. + ## Starting Setup your credentials inside .credentials.toml by copying credentials.example.toml