]> granicus.if.org Git - esp-idf/commitdiff
newlib: disable some optimizations for syscalls.c
authorIvan Grokhotkov <ivan@espressif.com>
Thu, 22 Nov 2018 04:19:49 +0000 (12:19 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Thu, 22 Nov 2018 04:19:49 +0000 (12:19 +0800)
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
components/newlib/component.mk

index a7b29c65484c5474d2ac34060b6dba453d292c4c..d541b87bf243243d132ad1f283b2f113a8c5c315 100644 (file)
@@ -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)
index 05ef6bee8d7494ff047464a21e784c09ca01cf9b..4db4acd00eef3170390390407e0fb80dd107d096 100644 (file)
@@ -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