mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-29 19:08:12 +00:00
core: add build target for debug unix build
This commit is contained in:
parent
75ddedb0b0
commit
42f1af3aa4
@ -123,6 +123,9 @@ build_unix: res ## build unix port
|
|||||||
build_unix_frozen: res build_cross ## build unix port with frozen modules
|
build_unix_frozen: res build_cross ## build unix port with frozen modules
|
||||||
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) PYOPT="$(PYOPT)" BITCOIN_ONLY="$(BITCOIN_ONLY)" TREZOR_EMULATOR_FROZEN=1
|
$(SCONS) CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) PYOPT="$(PYOPT)" BITCOIN_ONLY="$(BITCOIN_ONLY)" TREZOR_EMULATOR_FROZEN=1
|
||||||
|
|
||||||
|
build_unix_debug: res ## build unix port
|
||||||
|
$(SCONS) --max-drift=1 CFLAGS="$(CFLAGS)" $(UNIX_BUILD_DIR)/micropython $(UNIX_PORT_OPTS) TREZOR_EMULATOR_ASAN=1 TREZOR_EMULATOR_DEBUGGABLE=1
|
||||||
|
|
||||||
build_cross: ## build mpy-cross port
|
build_cross: ## build mpy-cross port
|
||||||
$(MAKE) -C vendor/micropython/mpy-cross $(CROSS_PORT_OPTS)
|
$(MAKE) -C vendor/micropython/mpy-cross $(CROSS_PORT_OPTS)
|
||||||
|
|
||||||
|
@ -314,21 +314,31 @@ env.Replace(
|
|||||||
LINK='ld',
|
LINK='ld',
|
||||||
SIZE='size',
|
SIZE='size',
|
||||||
STRIP='strip',
|
STRIP='strip',
|
||||||
OBJCOPY='objcopy', )
|
OBJCOPY='objcopy',
|
||||||
|
COPT=os.getenv('OPTIMIZE', '-Os'), )
|
||||||
|
|
||||||
if env.get('ENV').get('DEBUG_BUILD', 0):
|
if ARGUMENTS.get('TREZOR_EMULATOR_ASAN', 0):
|
||||||
import platform
|
asan_flags=(
|
||||||
platsys = platform.system()
|
' -fsanitize=address'+
|
||||||
env.Replace(
|
' -fsanitize-blacklist=asan_blacklist.txt'+
|
||||||
OPTIMIZE='-O0',
|
' -fno-omit-frame-pointer'+
|
||||||
LINKFLAGS='-Wl,-no_pie' if platsys == "Darwin" else '-Wl,-no-pie'
|
' -fno-optimize-sibling-calls'
|
||||||
)
|
)
|
||||||
|
env.Replace(
|
||||||
|
CC=os.getenv('CC') or 'clang',
|
||||||
|
LINK=os.getenv('LINK') or 'clang',
|
||||||
|
CFLAGS=asan_flags,
|
||||||
|
LINKFLAGS=' -Wl,-no_pie' + asan_flags, )
|
||||||
|
|
||||||
|
if ARGUMENTS.get('TREZOR_EMULATOR_DEBUGGABLE', 0):
|
||||||
|
env.Replace(
|
||||||
|
COPT=' -O0 -ggdb',
|
||||||
|
STRIP='true', )
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
|
TREZOR_MODEL=env.get('ENV').get('TREZOR_MODEL', 'T'), )
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(
|
||||||
COPT=env.get('OPTIMIZE', env.get('ENV').get('OPTIMIZE', '-Os')),
|
|
||||||
CCFLAGS='$COPT '
|
CCFLAGS='$COPT '
|
||||||
'-g3 '
|
'-g3 '
|
||||||
'-std=gnu99 -Wall -Werror -Wuninitialized -Wno-missing-braces '
|
'-std=gnu99 -Wall -Werror -Wuninitialized -Wno-missing-braces '
|
||||||
|
@ -73,3 +73,21 @@ You must not use both on the same test.
|
|||||||
|
|
||||||
[pytest-random-order]: https://pypi.org/project/pytest-random-order/
|
[pytest-random-order]: https://pypi.org/project/pytest-random-order/
|
||||||
[REGISTERED_MARKERS]: ../REGISTERED_MARKERS
|
[REGISTERED_MARKERS]: ../REGISTERED_MARKERS
|
||||||
|
|
||||||
|
## Extended testing and debugging
|
||||||
|
|
||||||
|
### Building for debugging (Emulator only)
|
||||||
|
|
||||||
|
Build the debuggable unix binary so you can attach the gdb or lldb.
|
||||||
|
This removes optimizations and reduces address space randomizaiton.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make build_unix_debug
|
||||||
|
```
|
||||||
|
|
||||||
|
The final executable is significantly slower due to ASAN(Address Sanitizer) integration.
|
||||||
|
If you wan't to catch some memory errors use this.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
time ASAN_OPTIONS=verbosity=1:detect_invalid_pointer_pairs=1:strict_init_order=true:strict_string_checks=true TREZOR_PROFILE="" pipenv run make test_emu
|
||||||
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user