mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 21:24:32 +02:00
fix(newlib): use optimized misalign access functions from libc.a
This commit is contained in:
@@ -38,6 +38,8 @@ if(CONFIG_STDATOMIC_S32C1I_SPIRAM_WORKAROUND)
|
||||
endif()
|
||||
|
||||
if(CONFIG_LIBC_OPTIMIZED_MISALIGNED_ACCESS)
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
# TODO IDF-13089: remove this block and modify src/newlib.lf when clang was upgraded
|
||||
list(APPEND srcs
|
||||
"src/string/memcmp.c"
|
||||
"src/string/memmove.c"
|
||||
@@ -52,6 +54,7 @@ if(CONFIG_LIBC_OPTIMIZED_MISALIGNED_ACCESS)
|
||||
list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_strncpy_impl")
|
||||
list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_strcpy_impl")
|
||||
list(APPEND EXTRA_LINK_FLAGS "-u esp_libc_include_strcmp_impl")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_LIBC_NEWLIB)
|
||||
@@ -69,12 +72,10 @@ endif()
|
||||
set(ldfragments "")
|
||||
list(APPEND ldfragments "src/newlib.lf" "src/system_libs.lf")
|
||||
|
||||
if(CONFIG_SPIRAM_CACHE_WORKAROUND)
|
||||
if(CONFIG_LIBC_NEWLIB)
|
||||
list(APPEND ldfragments src/esp32-spiram-rom-functions-c.lf)
|
||||
else()
|
||||
list(APPEND ldfragments src/picolibc/esp32-spiram-rom-functions-c.lf)
|
||||
endif()
|
||||
if(CONFIG_LIBC_NEWLIB)
|
||||
list(APPEND ldfragments src/libc.lf)
|
||||
else()
|
||||
list(APPEND ldfragments src/picolibc/libc.lf)
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
|
@@ -3,10 +3,6 @@
|
||||
# and/or applications may assume that because these functions normally are in ROM, they are accessible even when flash is
|
||||
# inaccessible. To work around this, this ld fragment places these functions in RAM instead. If the ROM functions are used,
|
||||
# these defines do nothing, so they can still be included in that situation.
|
||||
#
|
||||
#
|
||||
# Note: the only difference between esp32-spiram-rom-functions-c.lf
|
||||
# and esp32-spiram-rom-functions-psram-workaround.lf is the archive name.
|
||||
|
||||
[mapping:libc]
|
||||
archive:
|
||||
@@ -15,6 +11,8 @@ archive:
|
||||
else:
|
||||
libc.a
|
||||
entries:
|
||||
if LIBC_OPTIMIZED_MISALIGNED_ACCESS = y:
|
||||
libc_a-memcpy (noflash)
|
||||
if SPIRAM_CACHE_WORKAROUND = y:
|
||||
# The following libs are either used in a lot of places or in critical
|
||||
# code. (such as panic or abort)
|
@@ -9,3 +9,18 @@ entries:
|
||||
stdatomic (noflash)
|
||||
if STDATOMIC_S32C1I_SPIRAM_WORKAROUND = y:
|
||||
stdatomic_s32c1i (noflash)
|
||||
if STDATOMIC_S32C1I_SPIRAM_WORKAROUND = y:
|
||||
stdatomic_s32c1i (noflash)
|
||||
if CONFIG_LIBC_OPTIMIZED_MISALIGNED_ACCESS = y && IDF_TOOLCHAIN_GCC = y:
|
||||
# memcpy() should be in IRAM due to early system use
|
||||
# Others can stay in flash (performance difference is minimal)
|
||||
#
|
||||
# Performance Comparison:
|
||||
# | func | flash | iram |
|
||||
# |---------|-------|-------|
|
||||
# | memcmp | 15986 | 15170 |
|
||||
# | strcpy | 17499 | 16660 |
|
||||
# | strcmp | 13125 | 11147 |
|
||||
# | strncpy | 17386 | 16668 |
|
||||
# | strncmp | 22161 | 21782 |
|
||||
libc_a-memcpy (noflash)
|
||||
|
@@ -8,6 +8,10 @@
|
||||
archive:
|
||||
libc.a
|
||||
entries:
|
||||
if LIBC_OPTIMIZED_MISALIGNED_ACCESS = y && IDF_TARGET_ARCH_RISCV = y:
|
||||
memcpy-asm (noflash)
|
||||
if LIBC_OPTIMIZED_MISALIGNED_ACCESS = y && IDF_TARGET_ARCH_XTENSA = y:
|
||||
libc_machine_xtensa_memcpy (noflash)
|
||||
if SPIRAM_CACHE_WORKAROUND = y:
|
||||
# The following libs are either used in a lot of places or in critical code. (such as panic or abort)
|
||||
# Thus, they shall always be placed in IRAM.
|
Reference in New Issue
Block a user