micro-ROS / micro-ROS/micro_ros_espidf_component

`libmicroros.a` is built with a hand-maintained toolchain file that may drift from IDF's compile flags (ABI mismatch risk)

Ouverte
#373 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
C
Étoiles
419
Forks
124
Merge moyen
21 h 35 min
PR mergées (30 j)
3

Description

From https://github.com/micro-ROS/micro_ros_espidf_component/pull/334#issuecomment-4829889550

> The following content was generated by AI

#### Cause

micro-ROS is not built as regular IDF component sources. Instead, the component's CMake configure step invokes `libmicroros.mk`, which runs a separate colcon build to produce `libmicroros.a`, and the result is linked back into the ELF via `add_prebuilt_library`. This separate build uses its own toolchain file (`esp32_toolchain.cmake.in`) that only passes through a hand-picked subset of compile options (compiler binary, C standard, `sdkconfig.cmake`, IDF includes, a few hardcoded flags), rather than inheriting the full set of flags IDF applies to its own components.

#### Impact

Some ABI-affecting flags used by the main IDF build are not propagated to the micro-ROS sub-build, so `libmicroros.a` can be compiled with settings inconsistent with the rest of the firmware. Known gaps:

- RISC-V `-march`/`-mabi` are not set (relies on compiler defaults) — a mismatch here breaks the calling convention/ABI.
- PSRAM cache workaround flags (e.g. `-mfix-esp32-psram-cache-issue`) are not forwarded.
- The hardcoded flag list in `esp32_toolchain.cmake.in` must be kept in sync manually and can silently drift as IDF changes.

(Note: many flags like optimization level or stack protector are *not* ABI-breaking, so their absence is harmless — the concern is specifically the ABI/codegen-relevant ones.)

Because the same compiler is used and `sdkconfig.cmake` is included, most struct-layout / config-dependent mismatches are already avoided, so this is a latent risk rather than a guaranteed failure — but it can produce hard-to-debug link/runtime issues in specific configurations (e.g. SPIRAM enabled, certain RISC-V targets).

#### Possible fix

Keeping micro-ROS as a separately built static library is unavoidable (it depends on the ROS 2 / colcon / rosidl build system), so the goal is not to remove this mechanism but to make the sub-build inherit IDF's ABI-relevant flags instead of hardcoding a subset:

- Query the flags IDF actually uses for its components (e.g. `CMAKE_C_FLAGS` / `COMPILE_OPTIONS`, especially RISC-V `-march`/`-mabi` and PSRAM-related flags) in the outer `CMakeLists.txt` and pass them through `libmicroros.mk` into the toolchain file.
- As a minimum/interim step, document the list of flags that are known *not* to be synced and must be verified manually.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par esp32_toolchain.cmake.in, libmicroros.mk et le CMakeLists.txt externe afin de suivre comment les flags de compilation d’IDF atteignent le build colcon séparé. Comparez les flags utilisés par les composants d’IDF avec ceux transmis à libmicroros.a, en vous concentrant sur les options d’ABI RISC-V et de PSRAM. Le travail est considéré comme terminé lorsque le sous-build reçoit les flags pertinents sans liste maintenue manuellement susceptible de diverger, ou lorsque les flags non synchronisés sont explicitement documentés.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
c, cmake
Domaine
build-system, embedded-iot
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.