[PATCH] libcsupport: Workaround for GCC 5.1 and later

Joel Sherrill joel.sherrill at oarcorp.com
Mon Jul 13 18:20:21 UTC 2015



On 7/13/2015 1:06 PM, Sebastian Huber wrote:
> Yes, this option sounded like the right way to fix it, but...
>
> https://gcc.gnu.org/ml/gcc-help/2015-03/msg00093.html
> https://gcc.gnu.org/ml/gcc-help/2015-03/msg00094.html

Ouch! That is a big red flashing sign which says stay away!

And to Gedare's point of raising this as a PR, it is just
an optimization side-effect more than bug.

I wonder if this could impact any code in newlib? It should
have the same issue with the default calloc(). And maybe
some other routines like the string and mem* ones?

> ----- Joel Sherrill <joel.sherrill at oarcorp.com> schrieb:
>> This is possible to do inside the file itself using function
>> attributes or pragmas. I am not sure which method is best but
>> wanted to pass along so we could decide as a group.
>>
>>> optimize
>>> The optimize attribute is used to specify that a function is to be compiled with different optimization options than specified on the command line. Arguments can either be numbers or strings. Numbers are assumed to be an optimization level. Strings that begin with O are assumed to be an optimization option, while other options are assumed to be used with a -f prefix. You can also use the ‘#pragma GCC optimize’ pragma to set the optimization options that affect more than one function. See Function Specific Option Pragmas, for details about the ‘#pragma GCC optimize’ pragma.
>>> This can be used for instance to have frequently-executed functions compiled with more aggressive optimization options that produce faster and larger code, while other functions can be compiled with less aggressive options.
>>
>>
>> --joel	
>>
>> On 7/13/2015 3:20 AM, Sebastian Huber wrote:
>>> Disable an optimization which would lead to a recursive calloc() call in
>>> calloc().
>>> ---
>>>    cpukit/libcsupport/Makefile.am | 8 ++++++--
>>>    cpukit/wrapup/Makefile.am      | 1 +
>>>    2 files changed, 7 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am
>>> index 7474079..a5da5f1 100644
>>> --- a/cpukit/libcsupport/Makefile.am
>>> +++ b/cpukit/libcsupport/Makefile.am
>>> @@ -1,8 +1,9 @@
>>>    include $(top_srcdir)/automake/multilib.am
>>>    include $(top_srcdir)/automake/compile.am
>>>
>>> -noinst_LIBRARIES = libcsupport.a
>>> +noinst_LIBRARIES = libcsupport.a libcalloc.a
>>>    libcsupport_a_CPPFLAGS = $(AM_CPPFLAGS)
>>> +libcalloc_a_CPPFLAGS = $(AM_CPPFLAGS)
>>>
>>>    include_rtemsdir = $(includedir)/rtems
>>>    include_rtems_HEADERS = include/console.h
>>> @@ -79,7 +80,7 @@ ID_C_FILES = src/getegid.c src/geteuid.c src/getgid.c src/getgroups.c \
>>>        src/seteuid.c src/setgid.c src/setuid.c src/setegid.c src/setpgid.c \
>>>        src/setsid.c
>>>
>>> -MALLOC_C_FILES = src/malloc_initialize.c src/calloc.c src/malloc.c \
>>> +MALLOC_C_FILES = src/malloc_initialize.c src/malloc.c \
>>>        src/realloc.c src/_calloc_r.c src/_malloc_r.c \
>>>        src/free.c src/_free_r.c \
>>>        src/_realloc_r.c src/mallocfreespace.c \
>>> @@ -138,6 +139,9 @@ libcsupport_a_SOURCES += $(LIBC_GLUE_C_FILES) $(PASSWORD_GROUP_C_FILES) \
>>>
>>>    libcsupport_a_SOURCES += src/flockfile.c src/funlockfile.c src/ftrylockfile.c
>>>
>>> +libcalloc_a_SOURCES = src/calloc.c
>>> +libcalloc_a_CFLAGS = -fno-builtin
>>> +
>>>    EXTRA_DIST = src/TODO src/CASES src/README
>>>
>>>    include $(srcdir)/preinstall.am
>>> diff --git a/cpukit/wrapup/Makefile.am b/cpukit/wrapup/Makefile.am
>>> index 53861df..5fd6e33 100644
>>> --- a/cpukit/wrapup/Makefile.am
>>> +++ b/cpukit/wrapup/Makefile.am
>>> @@ -21,6 +21,7 @@ endif
>>>
>>>    TMP_LIBS += ../libcrypt/libcrypt.a
>>>    TMP_LIBS += ../libcsupport/libcsupport.a
>>> +TMP_LIBS += ../libcsupport/libcalloc.a
>>>    TMP_LIBS += ../libblock/libblock.a
>>>    if LIBDOSFS
>>>    TMP_LIBS += ../libfs/libdosfs.a
>>>
>>
>> --
>> Joel Sherrill, Ph.D.             Director of Research & Development
>> joel.sherrill at OARcorp.com        On-Line Applications Research
>> Ask me about RTEMS: a free RTOS  Huntsville AL 35805
>> Support Available                (256) 722-9985
>

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985


More information about the devel mailing list