Commit Graph

84 Commits

Author SHA1 Message Date
Frantisek Hrbata a034ef8713 feat(build): add initial configuration for fast reflashing
Introduce ESPTOOLPY_FAST_REFLASHING configuration option. It instructs
ldgen to group entity mappings for libraries deemed mutable (prone to
change) separately from those considered immutable (unlikely to change).

Organizing mutable and immutable libraries separately in the linker
script allows the linker to form larger contiguous blocks of data for
immutable libraries in the application's output sections. These blocks
are likely to stay mostly unchanged between application recompilations,
enabling them to be skipped during reflashing.

Separating mutable and immutable libraries in the linker script to
minimize changes in the output sections is insufficient. Padding is
added after the input sections of mutable libraries in the default data
and text output sections. This creates a buffer for the mutable
libraries, allowing additional changes to be made without altering the
layout of the binary image.

Additionally two optimizations currently in use can still mix data from
these libraries, leading to significant changes even within the grouped
immutable libraries.

1. constant merging

    Linker will try to merge input sections that have the MERGE and
    STRING flags from different libraries (object files) to perform
    optimizations like tail merging. For example, adding a string
    literal in a mutable library will also change the addresses of
    string literals from immutable libraries in such a merged section,
    causing changes in the generated code when those literals are
    referenced.

    Disabled with COMPILER_DISABLE_MERGE_CONSTANTS(-fno-merge-constants)

2. literal pools on Xtensa

    As optimization, the linker may merge literal pools from different
    libraries (object files) to improve the generated code size. This
    has the same effect as constant merging, and changes in mutable
    libraries may cause changes in the generated code for immutable
    libraries. To get larger unchanged continuous blocks in the text
    output sections for immutable libraries, we need to ensure that the
    Xtensa literal pools remain close to their references and are not
    merged.

    Disabled with CONFIG_COMPILER_ENABLE_TEXT_SECTION_LITERALS(-mtext-section-literals)

When ESPTOOLPY_FAST_REFLASHING is enabled, these two optimizations are
disabled to achieve larger unchaged continuous blocks for the grouped
immutable libraries, even though disabling these optimizations results
in slightly larger code.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-11-13 15:30:42 +01:00
Jakub Kocka 21c2ad8c23 fix: Added check to prevent IDF root directory build failed attempts in Win
Closes https://github.com/espressif/esp-idf/issues/17516
2025-10-17 09:37:04 +02:00
Alexey Gerenkov f3dba4f778 Merge branch 'feature/add-constexpr-noinline-for-libstdcxx' into 'master'
feat(build): add CONFIG_COMPILER_CXX_GLIBCXX_CONSTEXPR choise option

See merge request espressif/esp-idf!42079
2025-09-25 09:26:23 +08:00
Roland Dobai adb2d5deee feat(cmake): Produce warnings when component dependencies are not defined
There are idf.py hints for helping the user to set component
dependencies properly instead of building sources out-of-component or
including headers from outside the component directory. These are
produced with
tools/idf_py_actions/hint_modules/component_requirements.py.

However, idf.py hints are printed only when the build fails. If the user
starts with a buildable solution then the suggestions to add component
dependencies are not printed.

This commit introduces cmake-level warnings for building source files
from outside the component and including header files without setting up
proper component dependencies.
2025-09-24 13:43:23 +02:00
Alexey Lapshin 6d1d5ccb1c feat(build): add CONFIG_COMPILER_CXX_GLIBCXX_CONSTEXPR choise option
Allow to disable implicit inlining of constexpr functions from libstdc++.
This is a known GCC issue https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93008
that may affect C++ application size depending on its structure.
2025-09-23 15:13:28 +07:00
Deomid rojer Ryabkov e2e51c08f6 change(xtensa): Add -mno-target-align to size-optimized builds
Saves space, about 6K in our application

Merges https://github.com/espressif/esp-idf/pull/15677
2025-08-25 12:24:18 +08:00
Marek Fiala 9d35d63651 feat(cmake): Update minimum cmake version to 3.22 (whole repository) 2025-08-19 14:44:32 +02:00
Marius Vikhammer dea84337f5 Merge branch 'change/bootloader_o0_deprecate' into 'master'
change(bootloader): removed support for CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE

Closes IDF-9025

See merge request espressif/esp-idf!40331
2025-07-09 08:58:54 +08:00
Marius Vikhammer 3751479217 change(bootloader): removed support for CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE 2025-07-04 12:16:57 +08:00
Chen Jichang 5909a4d685 remove(essl): remove essl related files 2025-07-03 11:36:45 +08:00
Alexey Lapshin 243c587b70 fix(heap): avoid malloc calls optimization
GCC defines that malloc(0) returns a non-null pointer (glibc behavior).
This can break logic for some cases, because our implementation of
malloc(0) returns null pointer.
POSIX and the ISO C standard allow both behaviors.
2025-06-25 18:01:50 +07:00
Alexey Lapshin b6cfb7ecf6 fix(build): ensure zero-init of padding bits with GCC 15+
GCC 15 introduces a regression in guaranteed zero-initialization of
padding bits. The suggested solution is to add the
-fzero-init-padding-bits=unions compile option.

To prevent similar issues in the future, this change adds the
-fzero-init-padding-bits=all build option. It ensures that padding bits
in unions and structs are properly zeroed, avoiding regressions.
2025-06-25 18:01:50 +07:00
Alexey Lapshin 0be466755b feat(build): add CONFIG_COMPILER_DISABLE_GCC15_WARNINGS and toolchain migration-guide 2025-06-25 18:01:47 +07:00
Omar Chebib 980cf269c7 feat(riscv): implement frame pointer option for backtracing 2025-01-09 11:57:02 +08:00
Laukik Hase 420810ee77 feat(esp_tee): Support for ESP-TEE - tools directory 2024-12-02 12:20:05 +05:30
Alexey Lapshin 2a02d45bde fix(cxx): fix TLS classes destructor call
Closes https://github.com/espressif/esp-idf/issues/14360
2024-09-20 17:17:31 +07:00
Alexey Lapshin 664c2e6b77 feat(build): add CONFIG_COMPILER_DISABLE_GCC14_WARNINGS option 2024-09-08 13:53:52 +07:00
Alexey Storozhev 2d463ad18b Use correct clang flag for size optimization
See https://clang.llvm.org/docs/CommandGuide/clang.html:
>> Code Generation Options
>>   -Oz Like -Os (and thus -O2), but reduces code size further.

Without -Oz enabled clang produced binaries that were too large.
2024-08-27 13:41:34 +08:00
Marius Vikhammer fab065848d Merge branch 'fix/clang_linker_fix_for_linux_target' into 'master'
fix(cmake): Fixed linker not supporting -warn_commons for linux target on MacOS

Closes IDFGH-12129

See merge request espressif/esp-idf!32870
2024-08-22 11:18:58 +08:00
Sudeep Mohanty 78a42a82d5 fix(cmake): Fixed linker not supporting -warn_commons for linux target on MacOS
This commit updates the ld linker flags to conditionally include the
-warn_commons flag when the linux target is built on MacOS. This is
because, not all versions of ld support the -warn_commons option.

Closes https://github.com/espressif/esp-idf/issues/13185
2024-08-14 15:06:08 +02:00
Ivan Grokhotkov 1c343d8923 change(build_system): refactor reproducible build handling
- remove generate_debug_prefix_map.py, move its logic into CMake
- move all reproducible builds logic into a new file, prefix_map.cmake
2024-08-12 13:26:33 +02:00
Mahavir Jain 3dc80527ab feat: add compiler config for not merging const sections
Probably GCC-13.x and on-wards uses "-fmerge-constants" to merge
the const section (string/floating-point) across compilation units.
This makes it difficult to properly analyze the size output of rodata
section across libraries, the merged section (big in size) is showed
across a single library.

The config option added here can help to disable this compiler behavior
and help to provide better size analysis. It can be used during
development phase only as it increases rodata section size.
2024-07-15 10:04:55 +05:30
Konstantin Kondrashov e596cb5527 feat(tool): Adds idf_build_remove_options_from_property func 2024-06-20 14:43:26 +08:00
Marc Finet 9456c157ff feat(build): Add config to disable warn be considered as errors
The -Werror=all activates error for all warnings in -Wall, however, it
does not activate error for other default warnings, such as:
- int-conversion (pointer from integer w/o a cast)
- incompatible-pointer-types
- discarded-qualifiers

Which are IMO even more important that -Wall.

This commit fixes that by activating error for all warnings (i.e. from
-Wall and default ones) and removing those from -Wextra, as the culprit
commit seemed to address.

Fixes: 60f29236f6 "Build system: Raise warning level" (2016-11-16)

In order to avoid long analysis during esp-idf upgrade, provide a way to
restore the previous -Werror=all behavior that consider only warnings
from -Wall (and not default ones).

Also add a hint to use the Kconfig option on compilation error, but warn
that fixing the code is the preferred way.

Merges https://github.com/espressif/esp-idf/pull/11239

Suggested-By: Ivan Grokhotkov <ivan@espressif.com>
2024-06-20 14:43:26 +08:00
Alexey Lapshin ed6e497c6f feat(build): add COMPILER_STATIC_ANALYZER option 2024-06-18 14:25:37 +08:00
Marius Vikhammer a51942ae75 Merge branch 'refactor/esp_rom_cmake' into 'master'
refactor(esp_rom): refactor rom LD inclusions to make it easier to add new targets

Closes IDF-8673

See merge request espressif/esp-idf!29455
2024-03-13 14:18:33 +08:00
Marius Vikhammer 83d1c2f054 refactor(esp_rom): refactor rom LD inclusions to make it easier to add new targets 2024-03-12 09:48:46 +08:00
Darian Leung 48a7f053d5 feat(freertos/smp): Update other IDF components to be compatible with FreeRTOS v11.0.1 2024-03-05 15:44:12 +08:00
Ivan Grokhotkov 1bd417ad68 fix(cmake): don't add Clang flags not supported in Apple toolchain 2023-12-19 23:00:48 +01:00
Alexey Lapshin 47a902c813 fix(build_system): disable shrink-wrapping in Og builds to reduce binary size 2023-10-09 12:13:02 +04:00
Alexey Lapshin 98199d50d6 change(tools): update gcc toolchain version to 13.2.0
Add Kconfig option to supress new gcc warnings
Update docs with migration guide
2023-10-09 12:13:00 +04:00
radek.tandler 58d6216956 build: fixed unwanted libgcc when building using clang for linux target 2023-06-15 14:37:00 +02:00
Alexey Gerenkov d4e1935ba8 Merge branch 'feature/compiler_rt_support' into 'master'
build: Adds support for compiler-rt in Clang toolchain

See merge request espressif/esp-idf!21213
2023-06-09 04:41:34 +08:00
Alexey Gerenkov e9345bcced build: Adds support for Clangs's toolchain compiler-rt 2023-06-08 16:49:37 +03:00
Marius Vikhammer bd4c0fca3c core-system: changed CONFIG_COMPILER_OPTIMIZATION_DEFAULT to CONFIG_COMPILER_OPTIMIZATION_DEBUG
DEBUG is more descriptive and is consistent with the name used in the bootloader:
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG

Closes https://github.com/espressif/esp-idf/issues/8404
2023-06-02 15:16:50 +08:00
Alexey Gerenkov 8846674e54 tools: Upgrade Clang toolchain to 'esp-16.0.0-20230516' 2023-05-31 22:07:15 +03:00
Alexey Lapshin 0da15a7a19 build: add option COMPILER_DISABLE_GCC12_WARNINGS 2023-02-22 05:33:03 +00:00
Alexey Gerenkov 47c2c13de5 build: Adds support for universal Clang toolchain 2022-11-23 13:25:16 +03:00
Djordje Nedic facab8c5a7 tools: Increase the minimal supported CMake version to 3.16
This updates the minimal supported version of CMake to 3.16, which in turn enables us to use more CMake features and have a cleaner build system.
This is the version that provides most new features and also the one we use in our latest docker image for CI.
2022-06-01 06:35:02 +00:00
Anton Maklakov b9a549c80b build: remove COMPILER_DISABLE_GCC8_WARNINGS, no longer relevant 2022-05-27 11:40:40 +07:00
Ivan Grokhotkov 34aa82a11a cmake: use -warn_commons instead of --warn-common on macOS 2022-04-11 13:29:02 +02:00
Darian Leung e6d43ab56f freertos: Update SMP idle hooks
This commit updates the usage of idle hooks in SMP FreeRTOS as follows:

- IDF style idle hooks are now called from vApplicationMinimalIdleHook()
- If the user provdies their own vApplicationMinimalIdleHook(), it can be
  wrapped using -Wl,--wrap if CONFIG_FREERTOS_USE_MINIMAL_IDLE_HOOK is
  enabled.
- SMP port no longer uses vApplicationIdleHook() as it's only called from
  the prvIdleTask() and not every prvMinimalIdleTask()
2022-04-01 22:08:45 +08:00
Andrei Safronov ce7d01b52e cmake: add "-Wno-atomic-alignment" flag to clang scripts
Clang outputs performance warnings by default for atomic operations with
access size more then 4 bytes. So add "-Wno-atomic-alignment add" flag to
ESP-IDF cmake script.
2022-03-25 15:36:26 +03:00
Ivan Grokhotkov 9720cb72cb cmake: enable linker warnings on common symbols
GCC since version 10 uses -fno-common by default and will not emit
common symbols. Enable this option to find the occurrences of common
symbols in ESP-IDF.

Closes https://github.com/espressif/esp-idf/issues/5080
2022-01-27 10:34:49 +07:00
Ivan Grokhotkov 9901fc3058 cmake: don't pass --gc-sections to macOS linker, use -dead_strip
When building for "linux" (~POSIX) target on macOS, the system linker
is normally used. MacOS linker doesn't recognise --gc-sections, but
has a -dead_strip flag which is equivalent.
2022-01-24 18:51:40 +01:00
Ivan Grokhotkov d2b894862c newlib: auto-detect sizeof(time_t)
To make the transition from 32-bit time_t to 64-bit time_t smoother,
detect the size of this type in CMake and remove the manual option in
Kconfig.
The information about 64-bit time_t support is moved from Kconfig help
string into the "system time" section of the API reference.
2022-01-11 19:01:21 +01:00
Omar Chebib 0baf2c43cc Build: CMake compiler flags will be set, regardless of the cache status
Defining CMake variables from the command-line or from another CMake project,
such as `-DCMAKE_C_FLAGS= -DCMAKE_CXX_FLAGS=`, caused a link failure as ESP
CMake was unable to set its proper compilation flags.
Additional CMake compiler flags can now be provided by another project.

* Closes https://github.com/espressif/esp-idf/issues/7507
2021-11-29 09:48:13 +00:00
Fu Hanxi 42405604af idf.py gdb: autoload prefix_map_gdbinit when exists in project_description.json 2021-10-26 14:20:40 +08:00
Fu Hanxi ea1005b740 build: create BUILD_DIR/prefix_map_gdbinit when enable reproducible build
add project property BUILD_COMPONENT_DIRS
2021-10-26 10:55:00 +08:00
Fu Hanxi 9919b75ec1 build: add CONFIG_APP_REPRODUCIBLE_BUILD menuconfig option to produce reproducible binaries 2021-10-26 10:43:15 +08:00