build system: add COMPILER_SAVE_RESTORE_LIBCALLS option

Add new Kconfig option to enable -msave-restore flag for RISC-V
targets. This option can be used to reduce binary size by replacing
inlined register save/restore sequences with library calls.
pull/7751/head
Ivan Grokhotkov 2021-08-18 12:02:20 +05:00
rodzic bb15aa48a0
commit 95ee8104bf
4 zmienionych plików z 19 dodań i 0 usunięć

Wyświetl plik

@ -61,6 +61,10 @@ else()
list(APPEND link_options "-fno-rtti") # used to invoke correct multilib variant (no-rtti) during linking
endif()
if(CONFIG_COMPILER_SAVE_RESTORE_LIBCALLS)
list(APPEND compile_options "-msave-restore")
endif()
if(CONFIG_COMPILER_DISABLE_GCC8_WARNINGS)
list(APPEND compile_options "-Wno-parentheses"
"-Wno-sizeof-pointer-memaccess"

12
Kconfig
Wyświetl plik

@ -394,6 +394,18 @@ mainmenu "Espressif IoT Development Framework Configuration"
For C++, this warns about the deprecated conversion from string
literals to ``char *``.
config COMPILER_SAVE_RESTORE_LIBCALLS
bool "Enable -msave-restore flag to reduce code size"
depends on IDF_TARGET_ARCH_RISCV
help
Adds -msave-restore to C/C++ compilation flags.
When this flag is enabled, compiler will call library functions to
save/restore registers in function prologues/epilogues. This results
in lower overall code size, at the expense of slightly reduced performance.
This option can be enabled for RISC-V targets only.
config COMPILER_DISABLE_GCC8_WARNINGS
bool "Disable new warnings introduced in GCC 6 - 8"
default "n"

Wyświetl plik

@ -4,6 +4,8 @@ entries:
lib2funcs (noflash_text)
if IDF_TARGET_ESP32 = n:
_divsf3 (noflash)
if IDF_TARGET_ARCH_RISCV:
save-restore (noflash)
[mapping:gcov]
archive: libgcov.a

Wyświetl plik

@ -298,6 +298,7 @@ The following configuration options will reduce the final binary size of almost
- Don't enable :ref:`CONFIG_COMPILER_CXX_EXCEPTIONS`, :ref:`CONFIG_COMPILER_CXX_RTTI`, or set the :ref:`CONFIG_COMPILER_STACK_CHECK_MODE` to Overall. All of these options are already disabled by default, but they have a large impact on binary size.
- Disabling :ref:`CONFIG_ESP_ERR_TO_NAME_LOOKUP` will remove the lookup table to translate user-friendly names for error values (see :doc:`/api-guides/error-handling`) in error logs, etc. This saves some binary size, but error values will be printed as integers only.
- Setting :ref:`CONFIG_ESP_SYSTEM_PANIC` to "Silent reboot" will save a small amount of binary size, however this is *only* recommended if no one will use UART output to debug the device.
:CONFIG_IDF_TARGET_ARCH_RISCV: - Set :ref:`CONFIG_COMPILER_SAVE_RESTORE_LIBCALLS` to reduce binary size by replacing inlined prologues/epilogues with library calls.
.. note::