Prevent recursive 'memset()' calls with gcc 10

Fixes #4125
This commit is contained in:
Christian Prochaska 2021-04-03 11:36:30 +02:00 committed by Norman Feske
parent d5e7870532
commit 9b854e1496
3 changed files with 11 additions and 0 deletions

View File

@ -221,7 +221,12 @@ namespace Genode {
* \param dst destination buffer * \param dst destination buffer
* \param i byte value * \param i byte value
* \param size buffer size in bytes * \param size buffer size in bytes
*
* The compiler attribute is needed to prevent the
* generation of a 'memset()' call in the 'while' loop
* with gcc 10.
*/ */
__attribute((optimize("no-tree-loop-distribute-patterns")))
inline void *memset(void *dst, int i, size_t size) inline void *memset(void *dst, int i, size_t size)
{ {
while (size--) ((char *)dst)[size] = i; while (size--) ((char *)dst)[size] = i;

View File

@ -196,6 +196,9 @@ SRC_NOLINK += accessors.c \
vnode_if.c \ vnode_if.c \
xlat_mbr_fstype.c xlat_mbr_fstype.c
# prevent the generation of a 'memset()' call in 'memset()'
CC_OPT_memset = -fno-tree-loop-distribute-patterns
INC_DIR += $(REP_DIR)/src/include \ INC_DIR += $(REP_DIR)/src/include \
$(RUMP_BASE)/include \ $(RUMP_BASE)/include \
$(RUMP_PORT_DIR)/src/lib/libc/include \ $(RUMP_PORT_DIR)/src/lib/libc/include \

View File

@ -13,6 +13,9 @@ LIBC_STRING_DIR = $(LIBC_DIR)/lib/libc/string
SRC_C = $(filter-out $(FILTER_OUT),$(notdir $(wildcard $(LIBC_STRING_DIR)/*.c))) SRC_C = $(filter-out $(FILTER_OUT),$(notdir $(wildcard $(LIBC_STRING_DIR)/*.c)))
# prevent the generation of a 'memset()' call in 'memset()'
CC_OPT_memset += -fno-tree-loop-distribute-patterns
include $(REP_DIR)/lib/mk/libc-common.inc include $(REP_DIR)/lib/mk/libc-common.inc
vpath %.c $(LIBC_STRING_DIR) vpath %.c $(LIBC_STRING_DIR)