This is the mail archive of the
mailing list for the newlib project.
Re: Bug compiling the C version of memset with gcc -O3
- From: Alexander Holler <holler at ahsoftware dot de>
- To: newlib at sourceware dot org
- Date: Mon, 09 Dec 2013 09:18:04 +0100
- Subject: Re: Bug compiling the C version of memset with gcc -O3
- Authentication-results: sourceware.org; auth=none
- References: <52A3DC07 dot 8030803 at ahsoftware dot de>
Am 08.12.2013 03:40, schrieb Alexander Holler:
I've stumbled over bug compiling newlib 2.0 for ARM with gcc and -O3.
I'm quoting from http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59420
The issue is there is a loop inside of memset that gets converted to a
memset; that is if I read the assembly code correctly. if that is the case
then this is a bug in the newlib makefiles as they should be using
-fno-tree-loop-distribute-patterns or like what glibc does:
/* Add the compiler optimization to inhibit loop transformation to library
calls. This is used to avoid recursive calls in memset and memmove
default implementations. */
# define inhibit_loop_to_libcall \
__attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
# define inhibit_loop_to_libcall
So closing as invalid, please report this to newlib.
Note the work around is not to use -O3 or use -O3
The bug was likely not discovered before, because most architectures
except ARM are using optimized (assembler) versions for memset.
The C comment above (likely from glibc) sounds like memmove might be too
a victim of that optimization of gcc, but I haven't tested it up to now.
Btw., using -O3 wasn't my choice but is used by newlib as the default
for ARM. So this bug likely affects a lot more people than just me.