From 8deb885ce3a19b3adef5cc706dca48fa77ad8b76 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 22 Nov 2018 12:19:49 +0800 Subject: [PATCH] newlib: disable some optimizations for syscalls.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- components/newlib/CMakeLists.txt | 2 ++ components/newlib/component.mk | 2 ++ 2 files changed, 4 insertions(+) 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