From: Ivan Grokhotkov Date: Thu, 22 Nov 2018 04:19:49 +0000 (+0800) Subject: newlib: disable some optimizations for syscalls.c X-Git-Tag: v3.3-beta1~82^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8deb885ce3a19b3adef5cc706dca48fa77ad8b76;p=esp-idf newlib: disable some optimizations for syscalls.c Don’t allow the compiler to convert malloc + memset into calloc, causing a recursive call in _calloc_r. Fixes crash when building with -O2 optimization level. --- diff --git a/components/newlib/CMakeLists.txt b/components/newlib/CMakeLists.txt index a7b29c6548..d541b87bf2 100644 --- a/components/newlib/CMakeLists.txt +++ b/components/newlib/CMakeLists.txt @@ -30,3 +30,5 @@ register_component() target_link_libraries(newlib "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib") target_link_libraries(newlib ${LIBC} ${LIBM}) + +set_source_files_properties(syscalls.c PROPERTIES COMPILE_FLAGS -fno-builtin) diff --git a/components/newlib/component.mk b/components/newlib/component.mk index 05ef6bee8d..4db4acd00e 100644 --- a/components/newlib/component.mk +++ b/components/newlib/component.mk @@ -20,3 +20,5 @@ COMPONENT_ADD_LDFLAGS := $(LIBC_PATH) $(LIBM_PATH) -lnewlib COMPONENT_ADD_LINKER_DEPS := $(LIBC_PATH) $(LIBM_PATH) COMPONENT_ADD_INCLUDEDIRS := platform_include include + +syscalls.o: CFLAGS += -fno-builtin