Commit Graph

9 Commits

Author SHA1 Message Date
Frantisek Hrbata
534a7c0c96 feat(cmakev2): add IDF_CUSTOM_TOOLCHAIN for sub-projects with non-IDF toolchains
Sub-projects like ULP are built as external CMake projects via
externalproject_add() and may use toolchains that are completely
different from the IDF target toolchain. For example, the ULP RISC-V
co-processor on an xtensa target (ESP32-S2/S3) uses
riscv32-esp-elf-gcc while the main project uses xtensa-esp-elf-gcc.

This causes problems in cmakev2:

1. __init_toolchain() in idf.cmake validates that CMAKE_TOOLCHAIN_FILE
   matches IDF_TARGET and then overrides it. For sub-projects with
   custom toolchains (passed via -DCMAKE_TOOLCHAIN_FILE from the
   parent), this validation fails because the toolchain doesn't follow
   the IDF naming convention (toolchain-<target>.cmake).

2. Several component project_include.cmake files use functions from
   the IDF toolchain response file machinery (idf_toolchain_add_flags,
   idf_toolchain_remove_flags, idf_toolchain_rerun_abi_detection) that
   are not available in sub-projects with custom toolchains, or perform
   validation that assumes the IDF target toolchain is in use.

Introduce IDF_CUSTOM_TOOLCHAIN, a CMake variable passed via -D from
the parent build to indicate that the toolchain was provided externally
and should not be resolved or validated by the IDF build system.

When IDF_CUSTOM_TOOLCHAIN is set:
- __init_toolchain() records the pre-set CMAKE_TOOLCHAIN_FILE and
  skips IDF_TARGET-based resolution and validation.
- Component project_include.cmake files that manipulate IDF toolchain
  flags (xtensa, esp_libc, esp_psram, soc) return early, as those
  operations are not applicable to custom toolchains.

This is a generic mechanism usable by any sub-project that provides
its own toolchain (ULP, or any future sub-project with a non-IDF
toolchain).

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-07-14 16:54:57 +09:00
Alexey Lapshin
159bc4b1bc Revert "fix(esp_libc): remove --gc-sections from picolibc.specs for CMake checks"
This reverts commit 4535898de9.
2026-06-17 17:24:25 +07:00
Alexey Lapshin
72682b9f36 Revert "fix(libc): nano: add -lnosys to linking to avoid CMake configuration issues"
This reverts commit f54b5d4747.
2026-06-17 17:24:25 +07:00
Alexey Lapshin
f54b5d4747 fix(libc): nano: add -lnosys to linking to avoid CMake configuration issues 2026-05-20 15:08:41 +07:00
Alexey Lapshin
19c2f0becc fix(libc): picolibc: disable C11 annex K in compatibility mode 2026-05-06 14:23:29 +07:00
Alexey Lapshin
4535898de9 fix(esp_libc): remove --gc-sections from picolibc.specs for CMake checks
The --gc-sections flag in picolibc.specs causes CMake compiler detection
to fail by dropping required data. Work around this by creating a modified
specs file without the flag.
2026-02-04 18:08:51 +07:00
Alexey Lapshin
31810ae993 feat(esp_libc): make picolibc default libc 2025-12-03 13:31:42 +07:00
Alexey Lapshin
0c1d917f78 feat(build): propagate compiler flags from files to toolchain.cmake
This change improves build consistency across external projects integrated
through CMake by ensuring that compiler flags defined in configuration files
are passed correctly to the toolchain. It covers the majority of use cases,
as external projects are typically also CMake-based. For projects that use
a custom build system, users will still need to specify the required flags
manually.
2025-11-14 21:04:54 +07:00
Alexey Lapshin
9281e78381 change(esp_libc): rename newlib component to esp_libc 2025-09-09 22:00:44 +08:00