mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
fix(esp_libc/cmake): add vfs as requirement if CONFIG_VFS_SUPPORT_IO is enabled
The esp_libc relies on the stdio implementation of the vfs component if CONFIG_VFS_SUPPORT_IO is enabled. This is not an issue in cmakev1 because if the vfs component is not included in the project build, its configuration is not available, and CONFIG_VFS_SUPPORT_IO is not set. However, in cmakev2, the configuration for all components is available, and the presence of some component configuration options does not necessarily mean that the component is included in the project build. When esp_libc is compiled without the vfs dependency but with CONFIG_VFS_SUPPORT_IO enabled, the libc initialization will encounter a panic due to a NULL pointer dereference (fp->_flags) in __swsetup_r, as fopen in esp_libc_init_global_stdio will return NULL.
This commit is contained in:
@@ -77,10 +77,18 @@ else()
|
||||
list(APPEND ldfragments src/picolibc/libc.lf)
|
||||
endif()
|
||||
|
||||
set(priv_reqs soc spi_flash)
|
||||
|
||||
if(IDF_BUILD_V2)
|
||||
if(CONFIG_VFS_SUPPORT_IO)
|
||||
list(APPEND priv_reqs vfs)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS platform_include
|
||||
PRIV_INCLUDE_DIRS priv_include
|
||||
PRIV_REQUIRES soc spi_flash
|
||||
PRIV_REQUIRES "${priv_reqs}"
|
||||
LDFRAGMENTS "${ldfragments}")
|
||||
|
||||
# Toolchain libraries require code defined in this component
|
||||
|
||||
Reference in New Issue
Block a user