From 830f0383605510058e4282d01b600d38043f661a Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Wed, 22 Jan 2025 16:14:40 +0200 Subject: [PATCH] build(core): allow printing Rust types' sizes during build https://nnethercote.github.io/perf-book/type-sizes.html#measuring-type-sizes [no changelog] --- core/Makefile | 2 ++ core/SConscript.firmware | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/core/Makefile b/core/Makefile index a712d4524a..7af1fc4895 100644 --- a/core/Makefile +++ b/core/Makefile @@ -44,6 +44,7 @@ TREZOR_EMULATOR_DEBUGGABLE ?= 0 QUIET_MODE ?= 0 TREZOR_DISABLE_ANIMATION ?= $(if $(filter 0,$(PYOPT)),1,0) STORAGE_INSECURE_TESTING_MODE ?= 0 +RUST_PRINT_TYPES_SIZES ?= 0 # OpenOCD interface default. Alternative: ftdi/olimex-arm-usb-tiny-h OPENOCD_INTERFACE ?= stlink @@ -122,6 +123,7 @@ SCONS_VARS = \ PRODUCTION="$(PRODUCTION)" \ PYOPT="$(PYOPT)" \ QUIET_MODE="$(QUIET_MODE)" \ + RUST_PRINT_TYPES_SIZES="$(RUST_PRINT_TYPES_SIZES)" \ SCM_REVISION="$(SCM_REVISION)" \ STORAGE_INSECURE_TESTING_MODE="$(STORAGE_INSECURE_TESTING_MODE)" \ THP="$(THP)" \ diff --git a/core/SConscript.firmware b/core/SConscript.firmware index b4c9564f71..c2d36dea19 100644 --- a/core/SConscript.firmware +++ b/core/SConscript.firmware @@ -790,6 +790,10 @@ def cargo_build(): env.get('ENV')['TREZOR_MODEL'] = TREZOR_MODEL + if ARGUMENTS.get('RUST_PRINT_TYPES_SIZES', '0') == '1': + # see https://nnethercote.github.io/perf-book/type-sizes.html#measuring-type-sizes for more details + env.Append(ENV={'RUSTFLAGS': '-Z print-type-sizes'}) + bindgen_macros = tools.get_bindgen_defines(env.get("CPPDEFINES"), ALLPATHS) build_dir = str(Dir('.').abspath)