From 04b73368e51c5c48992b0ee6c0205abc161b1934 Mon Sep 17 00:00:00 2001 From: Alexey Lapshin Date: Fri, 23 Feb 2024 20:25:08 +0400 Subject: [PATCH] fix(tools): do not use builtin memcpy/memset/strcpy on xtensa chips Closes https://github.com/espressif/esp-idf/issues/13228 --- tools/cmake/toolchain-esp32.cmake | 11 ++++++++--- tools/cmake/toolchain-esp32s2.cmake | 10 ++++++++-- tools/cmake/toolchain-esp32s3.cmake | 10 ++++++++-- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/tools/cmake/toolchain-esp32.cmake b/tools/cmake/toolchain-esp32.cmake index fcc19cd54b..31bb748dc9 100644 --- a/tools/cmake/toolchain-esp32.cmake +++ b/tools/cmake/toolchain-esp32.cmake @@ -7,10 +7,15 @@ set(CMAKE_CXX_COMPILER xtensa-esp32-elf-g++) set(CMAKE_ASM_COMPILER xtensa-esp32-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX xtensa-esp32-elf-) - -remove_duplicated_flags("-mlongcalls -Wno-frame-address ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) +remove_duplicated_flags("-mlongcalls -Wno-frame-address \ + -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero \ + -fno-builtin-stpcpy -fno-builtin-strncpy \ + ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("-mlongcalls -Wno-frame-address ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) +remove_duplicated_flags("-mlongcalls -Wno-frame-address \ + -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero \ + -fno-builtin-stpcpy -fno-builtin-strncpy \ + ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) remove_duplicated_flags("-mlongcalls ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" CACHE STRING "ASM Compiler Base Flags" FORCE) diff --git a/tools/cmake/toolchain-esp32s2.cmake b/tools/cmake/toolchain-esp32s2.cmake index 8b5ebf7883..358b2e4100 100644 --- a/tools/cmake/toolchain-esp32s2.cmake +++ b/tools/cmake/toolchain-esp32s2.cmake @@ -7,9 +7,15 @@ set(CMAKE_CXX_COMPILER xtensa-esp32s2-elf-g++) set(CMAKE_ASM_COMPILER xtensa-esp32s2-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX xtensa-esp32s2-elf-) -remove_duplicated_flags("-mlongcalls ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) +remove_duplicated_flags("-mlongcalls \ + -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero \ + -fno-builtin-stpcpy -fno-builtin-strncpy \ + ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("-mlongcalls ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) +remove_duplicated_flags("-mlongcalls \ + -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero \ + -fno-builtin-stpcpy -fno-builtin-strncpy \ + ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) remove_duplicated_flags("-mlongcalls ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" CACHE STRING "ASM Compiler Base Flags" FORCE) diff --git a/tools/cmake/toolchain-esp32s3.cmake b/tools/cmake/toolchain-esp32s3.cmake index a830c624ec..e504150e5d 100644 --- a/tools/cmake/toolchain-esp32s3.cmake +++ b/tools/cmake/toolchain-esp32s3.cmake @@ -7,9 +7,15 @@ set(CMAKE_CXX_COMPILER xtensa-esp32s3-elf-g++) set(CMAKE_ASM_COMPILER xtensa-esp32s3-elf-gcc) set(_CMAKE_TOOLCHAIN_PREFIX xtensa-esp32s3-elf-) -remove_duplicated_flags("-mlongcalls ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) +remove_duplicated_flags("-mlongcalls \ + -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero \ + -fno-builtin-stpcpy -fno-builtin-strncpy \ + ${CMAKE_C_FLAGS}" UNIQ_CMAKE_C_FLAGS) set(CMAKE_C_FLAGS "${UNIQ_CMAKE_C_FLAGS}" CACHE STRING "C Compiler Base Flags" FORCE) -remove_duplicated_flags("-mlongcalls ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) +remove_duplicated_flags("-mlongcalls \ + -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero \ + -fno-builtin-stpcpy -fno-builtin-strncpy \ + ${CMAKE_CXX_FLAGS}" UNIQ_CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "${UNIQ_CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler Base Flags" FORCE) remove_duplicated_flags("-mlongcalls ${CMAKE_ASM_FLAGS}" UNIQ_CMAKE_ASM_FLAGS) set(CMAKE_ASM_FLAGS "${UNIQ_CMAKE_ASM_FLAGS}" CACHE STRING "ASM Compiler Base Flags" FORCE)