mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
feat(libc): pass __PICOLIBC_ERRNO_FUNCTION to picolibc builds
This commit is contained in:
4
components/esp_libc/hints.yml
Normal file
4
components/esp_libc/hints.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
-
|
||||
re: "errno: TLS reference in ([^ ]+\\.a)\\([^)]*\\) mismatches non-TLS definition"
|
||||
hint: "The library '{}' accessed errno as a TLS symbol, which is incompatible with CONFIG_LIBC_NEWLIB=y (errno via __errno()). Contact the library maintainer to rebuild it with the latest ESP-IDF, or pass -D__PICOLIBC_ERRNO_FUNCTION=__errno if the library is built outside ESP-IDF. Alternatively keep CONFIG_LIBC_PICOLIBC=y, which still provides the TLS errno symbol for older prebuilts."
|
||||
match_to_output: True
|
||||
@@ -58,6 +58,10 @@ if(CONFIG_IDF_TOOLCHAIN_GCC)
|
||||
idf_toolchain_remove_flags(COMPILE_OPTIONS "-mdisable-hardware-atomics")
|
||||
endif()
|
||||
|
||||
idf_toolchain_remove_flags(COMPILE_OPTIONS "-specs=.*picolibc.*")
|
||||
idf_toolchain_remove_flags(COMPILE_OPTIONS "-D__STDC_WANT_LIB_EXT1__=0")
|
||||
# TODO GCC-495:remove
|
||||
idf_toolchain_remove_flags(COMPILE_OPTIONS "-D__PICOLIBC_ERRNO_FUNCTION=__errno")
|
||||
if(CONFIG_LIBC_PICOLIBC)
|
||||
# TODO GCC-464:
|
||||
# The original picolibc.specs file cannot be used directly in the build
|
||||
@@ -69,11 +73,11 @@ if(CONFIG_IDF_TOOLCHAIN_GCC)
|
||||
# --gc-sections option.
|
||||
get_picolibc_specs_path(picolibc_specs_path)
|
||||
idf_toolchain_add_flags(COMPILE_OPTIONS "\"-specs=${picolibc_specs_path}\"")
|
||||
# TODO GCC-495:remove
|
||||
idf_toolchain_add_flags(COMPILE_OPTIONS "-D__PICOLIBC_ERRNO_FUNCTION=__errno")
|
||||
if(LIBC_PICOLIBC_NEWLIB_COMPATIBILITY)
|
||||
idf_toolchain_add_flags(COMPILE_OPTIONS "-D__STDC_WANT_LIB_EXT1__=0")
|
||||
endif()
|
||||
else()
|
||||
idf_toolchain_remove_flags(COMPILE_OPTIONS "-specs=.*picolibc.*")
|
||||
endif()
|
||||
|
||||
if(CONFIG_LIBC_NEWLIB_NANO_FORMAT)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -12,11 +12,10 @@
|
||||
* 'errno' is defined in the TDATA section. The linker script ensures that
|
||||
* it is positioned at the beginning of the TDATA segment.
|
||||
*/
|
||||
#undef errno
|
||||
__thread int errno __attribute__((section(".tdata.errno"))) = 0;
|
||||
|
||||
#if CONFIG_LIBC_PICOLIBC_NEWLIB_COMPATIBILITY
|
||||
int *__errno(void)
|
||||
{
|
||||
return &errno;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -113,6 +113,7 @@ void IRAM_ATTR syscall_exit_tee(void)
|
||||
* 'errno' is defined in the TDATA section. The linker script ensures that
|
||||
* it is positioned at the beginning of the TDATA segment.
|
||||
*/
|
||||
#undef errno
|
||||
__thread int errno __attribute__((section(".tdata.errno"))) = 0;
|
||||
|
||||
int *__errno(void)
|
||||
|
||||
Reference in New Issue
Block a user