build system: always build with -fno-jump-tables & -fno-tree-switch-conversion
Jump tables placed in flash would cause issue with code that needed to be ran from IRAM. These optimizations are now always disabled.
This commit is contained in:
@@ -93,15 +93,11 @@ There are some possible issues with placement in IRAM, that may cause problems w
|
||||
|
||||
Note that knowing which data should be marked with ``DRAM_ATTR`` can be hard, the compiler will sometimes recognize that a variable or expression is constant (even if it is not marked ``const``) and optimize it into flash, unless it is marked with ``DRAM_ATTR``.
|
||||
|
||||
* GCC optimizations that automatically generate jump tables or switch/case lookup tables place these tables in flash. There are two possible ways to resolve this issue:
|
||||
|
||||
- Use a :doc:`linker script fragment <linker-script-generation>` to mark the entire source file as ``noflash``
|
||||
- Pass specific flags to the compiler to disable these optimizations in the relevant source files. For CMake, place the following in the component CMakeLists.txt file:
|
||||
* GCC optimizations that automatically generate jump tables or switch/case lookup tables place these tables in flash. IDF by default builds all files with `-fno-jump-tables -fno-tree-switch-conversion` flags to avoid this.
|
||||
|
||||
.. code-block:: cmake
|
||||
Jump table optimizations can be re-enabled for individual source files that don't need to be placed in IRAM. For instructions on how to add the -fjump-tables -ftree-switch-conversion options when compiling individual source files, see :ref:`component_build_control`
|
||||
|
||||
set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/relative/path/to/file" PROPERTIES
|
||||
COMPILE_FLAGS "-fno-jump-tables -fno-tree-switch-conversion")
|
||||
|
||||
.. _irom:
|
||||
|
||||
|
||||
@@ -116,6 +116,8 @@ The following changes will increase the speed of a chosen part of the firmware a
|
||||
|
||||
IRAM is a limited resource, and using more IRAM may reduce available DRAM, so a strategic approach is needed when moving code to IRAM. See :ref:`iram` for more information.
|
||||
|
||||
- Jump table optimizations can be re-enabled for individual source files that don't need to be placed in IRAM. For hot paths in large switch cases this will improve performance. For instructions on how to add the -fjump-tables -ftree-switch-conversion options when compiling individual source files, see :ref:`component_build_control`
|
||||
|
||||
Improving Startup Time
|
||||
----------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user