You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "MukundaKatta (via GitHub)" <gi...@apache.org> on 2026/04/25 23:45:12 UTC

[PR] tools/espressif: add esp_libc platform_include shim for C23 ATOMIC_VAR_INIT [nuttx]

MukundaKatta opened a new pull request, #18808:
URL: https://github.com/apache/nuttx/pull/18808

   Fixes #18805.
   
   ## Summary
   
   The Make-based Espressif chip configs add `${ESP_HAL_3RDPARTY_REPO}/nuttx/src/components/esp_libc/platform_include` to the preprocessor search path, but at the pinned esp-hal-3rdparty commit (`d41c921a`) that directory only contains `esp_newlib.h`. The ESP-IDF C23-compatibility `stdatomic.h` shim that re-defines `ATOMIC_VAR_INIT` when `__STDC_VERSION__ > 201710L` actually lives at `${ESP_HAL_3RDPARTY_REPO}/components/esp_libc/platform_include/stdatomic.h` (without the `nuttx/src/` prefix).
   
   Without that path on `-I`, building any esp-hal-3rdparty source that calls `ATOMIC_VAR_INIT` (currently `components/esp_hw_support/esp_gpio_reserve.c`) fails on toolchains that default to a C standard newer than C17 (e.g. `riscv-none-elf-gcc 15.x`):
   
   ```
   chip/esp-hal-3rdparty/components/esp_hw_support/esp_gpio_reserve.c:13:47: error: implicit declaration of function 'ATOMIC_VAR_INIT'; did you mean 'ATOMIC_FLAG_INIT'? [-Wimplicit-function-declaration]
      13 | static _Atomic uint64_t s_reserved_pin_mask = ATOMIC_VAR_INIT(~(SOC_GPIO_VALID_GPIO_MASK));
         |                                               ^~~~~~~~~~~~~~~
   ```
   
   This adds the missing include directory (`components/esp_libc/platform_include`, alongside the existing legacy entry) to every `hal*.mk` for the seven affected chips so the shim is visible to the preprocessor.
   
   ## Impact
   
   - Build-system wiring only. One additional `-I` flag per esp32* chip Make build.
   - No runtime/code/hardware/documentation/security impact.
   - Affected configs: `arch/xtensa/src/esp32/hal.mk`, `arch/xtensa/src/esp32s2/hal.mk`, `arch/xtensa/src/esp32s3/hal.mk`, `arch/risc-v/src/esp32c3/hal_esp32c3.mk`, `arch/risc-v/src/esp32c6/hal_esp32c6.mk`, `arch/risc-v/src/esp32h2/hal_esp32h2.mk`, `arch/risc-v/src/esp32p4/hal_esp32p4.mk`.
   - The equivalent `arch/risc-v/src/esp32*/hal_esp32*.cmake` files contain the same legacy include path; they likely need the same one-line fix if anyone hits this on the CMake build path. Kept out of scope of this PR to match the reproduction in #18805.
   
   ## Testing
   
   - Reproduction (from #18805): `./tools/configure.sh esp32c3-xiao:nimble && make -j` on Linux with `riscv-none-elf-gcc 15.2.0` fails on `esp_gpio_reserve.c` with the diagnostic above.
   - After this patch the new `-I` adds the shim header, so `__STDC_VERSION__ > 201710L` is allowed to redefine `ATOMIC_VAR_INIT(val) (val)` and the file compiles.
   - Pure build-system change with the same wiring on all esp32* chips, so the existing CI build matrix exercises every modified file.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] tools/espressif: add esp_libc platform_include shim for C23 ATOMIC_VAR_INIT [nuttx]

Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 commented on PR #18808:
URL: https://github.com/apache/nuttx/pull/18808#issuecomment-4338649001

   Actually closing due to slop; this account has had almost no activity for the last two years, but has had upwards of 500 PRs per day to many different repos in the last several weeks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] tools/espressif: add esp_libc platform_include shim for C23 ATOMIC_VAR_INIT [nuttx]

Posted by "eren-terzioglu (via GitHub)" <gi...@apache.org>.
eren-terzioglu commented on PR #18808:
URL: https://github.com/apache/nuttx/pull/18808#issuecomment-4324996426

   Hi,
   
   Thanks for contributing. Please add same changes to `hal_CHIP-NAME.cmake` files too (e.g. [hal_esp32c3.cmake](https://github.com/apache/nuttx/blob/master/arch/risc-v/src/esp32c3/hal_esp32c3.cmake))


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] tools/espressif: add esp_libc platform_include shim for C23 ATOMIC_VAR_INIT [nuttx]

Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 closed pull request #18808: tools/espressif: add esp_libc platform_include shim for C23 ATOMIC_VAR_INIT
URL: https://github.com/apache/nuttx/pull/18808


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org