From f4dd37a6a82477e4695bd143013eb3605230a3ad Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Fri, 17 Dec 2021 18:34:02 -0500 Subject: [PATCH 1/2] cargo: disable LTO LTO saves us 1.5 MB (11%) in the release binary with debug symbols disabled. On the other hand it's been an enormous pain. The RHCOS package disables LTO because of problems on s390x. Quay and the Fedora armv7hl builders apparently OOM building 0.12.0 with LTO. And it's not a default option in the first place. Get rid of it. --- Cargo.toml | 1 - Dockerfile | 2 -- 2 files changed, 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 051b319a9..a3a5a77c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,6 @@ path = "src/bin/rdcore/main.rs" required-features = ["rdcore"] [profile.release] -lto = true # We assume we're being delivered via e.g. RPM which supports split debuginfo debug = true diff --git a/Dockerfile b/Dockerfile index b75f66cd6..8e1726a8f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,6 @@ RUN dnf install -y cargo openssl-devel xz-devel WORKDIR /build COPY Cargo.* ./ COPY src src/ -# Disable LTO to avoid OOM in Quay -RUN sed -i 's/^lto = true$/lto = false/' Cargo.toml RUN cargo build --release FROM registry.fedoraproject.org/fedora:35 From edb76060d5649197d7d150a091f916e5193b2e27 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Fri, 17 Dec 2021 18:55:18 -0500 Subject: [PATCH 2/2] Dockerfile: disable debug symbols Debug symbols can make it easier to debug problems in production, but our bug reports don't generally take advantage of that, and the symbols increase the binary size from 13 MB to 125 MB. --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 8e1726a8f..d90ce1c0a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,8 @@ RUN dnf install -y cargo openssl-devel xz-devel WORKDIR /build COPY Cargo.* ./ COPY src src/ +# Debug symbols are nice but they're not 100+ MB of nice +RUN sed -i 's/^debug = true$/debug = false/' Cargo.toml RUN cargo build --release FROM registry.fedoraproject.org/fedora:35