Skip to content

Commit

Permalink
fixup! build(core): allow exporting Rust functions' stack sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
romanz committed Jan 30, 2025
1 parent de75780 commit b508b8a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 0 additions & 2 deletions core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ QUIET_MODE ?= 0
TREZOR_DISABLE_ANIMATION ?= $(if $(filter 0,$(PYOPT)),1,0)
STORAGE_INSECURE_TESTING_MODE ?= 0
RUST_PRINT_TYPES_SIZES ?= 0
RUST_EMIT_STACK_SIZES ?= 0

# OpenOCD interface default. Alternative: ftdi/olimex-arm-usb-tiny-h
OPENOCD_INTERFACE ?= stlink
Expand Down Expand Up @@ -125,7 +124,6 @@ SCONS_VARS = \
PYOPT="$(PYOPT)" \
QUIET_MODE="$(QUIET_MODE)" \
RUST_PRINT_TYPES_SIZES="$(RUST_PRINT_TYPES_SIZES)" \
RUST_EMIT_STACK_SIZES="$(RUST_EMIT_STACK_SIZES)" \
SCM_REVISION="$(SCM_REVISION)" \
STORAGE_INSECURE_TESTING_MODE="$(STORAGE_INSECURE_TESTING_MODE)" \
THP="$(THP)" \
Expand Down
10 changes: 5 additions & 5 deletions core/SConscript.firmware
Original file line number Diff line number Diff line change
Expand Up @@ -794,11 +794,11 @@ def cargo_build():
# see https://nnethercote.github.io/perf-book/type-sizes.html#measuring-type-sizes for more details
env.Append(ENV={'RUSTFLAGS': '-Z print-type-sizes'})

if ARGUMENTS.get('RUST_EMIT_STACK_SIZES', '0') == '1':
# see the following links for more details:
# - https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/emit-stack-sizes.html
# - https://blog.japaric.io/stack-analysis/
env.Append(ENV={'RUSTFLAGS': '-Z emit-stack-sizes'})
# Adds an ELF section with Rust functions' stack sizes. See the following links for more details:
# - https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/emit-stack-sizes.html
# - https://blog.japaric.io/stack-analysis/
# - https://github.com/japaric/stack-sizes/
env.Append(ENV={'RUSTFLAGS': '-Z emit-stack-sizes'})

bindgen_macros = tools.get_bindgen_defines(env.get("CPPDEFINES"), ALLPATHS)
build_dir = str(Dir('.').abspath)
Expand Down

0 comments on commit b508b8a

Please sign in to comment.