From 14fe7a081a8260bbbfc7929a14ec4187faaa3c25 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Mon, 16 Jan 2023 16:23:08 -0500 Subject: YJIT: Use ThinLTO for Rust parts in release mode This reduces the code size of libyjit.a by a lot. On darwin it went from 23 MiB to 12 MiB for me. I chose ThinLTO over fat LTO for the relatively fast build time; in case we need to debug release-build-only problems it won't be painful. --- common.mk | 1 + yjit/Cargo.toml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/common.mk b/common.mk index ac627181e0..9dd35eebc2 100644 --- a/common.mk +++ b/common.mk @@ -225,6 +225,7 @@ YJIT_RUSTC_ARGS = --crate-name=yjit \ --crate-type=staticlib \ --edition=2021 \ -g \ + -C lto=thin \ -C opt-level=3 \ -C overflow-checks=on \ '--out-dir=$(CARGO_TARGET_DIR)/release/' \ diff --git a/yjit/Cargo.toml b/yjit/Cargo.toml index 18b1d10bd8..d2d54edc78 100644 --- a/yjit/Cargo.toml +++ b/yjit/Cargo.toml @@ -45,3 +45,5 @@ opt-level = 3 overflow-checks = true # Generate debug info debug = true +# Use ThinLTO. Much smaller output for a small amount of build time increase. +lto = "thin" -- cgit v1.2.3