newlib: xstormy16: fix mallopt definition & mstats handling

The mallopt symbol is defined in tiny-malloc.c, not mallocr.c, but
the Makefile in here tries to compile it out of the latter.  This
leads to mallopt never being defined.

The build also creates mallinfo.o & mallopt.o & mallstats.o objects
to override common ones, but the common dir doesn't use these names.
Instead, it places these all in mstats.o.

So move the build define logic to a dedicated file and compile it
directly to make things a bit simpler while fixing the missing func
and aligning objects with the cmomon code.
This commit is contained in:
Mike Frysinger 2022-03-01 00:58:55 -05:00
parent b1743c94e2
commit 5cd957ff66
3 changed files with 29 additions and 28 deletions

View File

@ -6,7 +6,8 @@ AM_CCASFLAGS = $(AM_CPPFLAGS)
noinst_LIBRARIES = lib.a
lib_a_SOURCES = setjmp.S
lib_a_SOURCES = setjmp.S \
mstats.c
lib_a_CFLAGS = $(AM_CFLAGS)
lib_a_LIBADD = $(lpfx)malloc.o \
@ -17,10 +18,7 @@ lib_a_LIBADD = $(lpfx)malloc.o \
$(lpfx)malign.o \
$(lpfx)valloc.o \
$(lpfx)pvalloc.o \
$(lpfx)mallinfo.o \
$(lpfx)mallstats.o \
$(lpfx)msize.o \
$(lpfx)mallopt.o \
$(lpfx)mallocr.o \
$(lpfx)freer.o \
$(lpfx)reallocr.o \
@ -54,18 +52,9 @@ $(lpfx)valloc.o: tiny-malloc.c
$(lpfx)pvalloc.o: tiny-malloc.c
$(MALLOC_COMPILE) -DDEFINE_PVALLOC -c $(srcdir)/tiny-malloc.c -o $@
$(lpfx)mallinfo.o: tiny-malloc.c
$(MALLOC_COMPILE) -DDEFINE_MALLINFO -c $(srcdir)/tiny-malloc.c -o $@
$(lpfx)mallstats.o: tiny-malloc.c
$(MALLOC_COMPILE) -DDEFINE_MALLOC_STATS -c $(srcdir)/tiny-malloc.c -o $@
$(lpfx)msize.o: tiny-malloc.c
$(MALLOC_COMPILE) -DDEFINE_MALLOC_USABLE_SIZE -c $(srcdir)/tiny-malloc.c -o $@
$(lpfx)mallopt.o: mallocr.c
$(MALLOC_COMPILE) -DDEFINE_MALLOPT -c $(srcdir)/mallocr.c -o $@
$(lpfx)mallocr.o: mallocr.c
$(MALLOC_COMPILE) -DDEFINE_MALLOC -c $(srcdir)/mallocr.c -o $@

View File

@ -117,7 +117,7 @@ am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@)
am__v_AR_0 = @echo " AR " $@;
am__v_AR_1 =
lib_a_AR = $(AR) $(ARFLAGS)
am_lib_a_OBJECTS = setjmp.$(OBJEXT)
am_lib_a_OBJECTS = setjmp.$(OBJEXT) lib_a-mstats.$(OBJEXT)
lib_a_OBJECTS = $(am_lib_a_OBJECTS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@ -140,6 +140,10 @@ AM_V_CPPAS = $(am__v_CPPAS_@AM_V@)
am__v_CPPAS_ = $(am__v_CPPAS_@AM_DEFAULT_V@)
am__v_CPPAS_0 = @echo " CPPAS " $@;
am__v_CPPAS_1 =
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
@ -309,7 +313,9 @@ top_srcdir = @top_srcdir@
AM_CPPFLAGS = $(NEWLIB_CFLAGS) $(TARGET_CFLAGS)
AM_CCASFLAGS = $(AM_CPPFLAGS)
noinst_LIBRARIES = lib.a
lib_a_SOURCES = setjmp.S
lib_a_SOURCES = setjmp.S \
mstats.c
lib_a_CFLAGS = $(AM_CFLAGS)
lib_a_LIBADD = $(lpfx)malloc.o \
$(lpfx)free.o \
@ -319,10 +325,7 @@ lib_a_LIBADD = $(lpfx)malloc.o \
$(lpfx)malign.o \
$(lpfx)valloc.o \
$(lpfx)pvalloc.o \
$(lpfx)mallinfo.o \
$(lpfx)mallstats.o \
$(lpfx)msize.o \
$(lpfx)mallopt.o \
$(lpfx)mallocr.o \
$(lpfx)freer.o \
$(lpfx)reallocr.o \
@ -333,7 +336,7 @@ MALLOC_COMPILE = $(COMPILE)
all: all-am
.SUFFIXES:
.SUFFIXES: .S .o .obj
.SUFFIXES: .S .c .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
@ -384,6 +387,18 @@ distclean-compile:
.S.obj:
$(AM_V_CPPAS)$(CPPASCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.o:
$(AM_V_CC)$(COMPILE) -c -o $@ $<
.c.obj:
$(AM_V_CC)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
lib_a-mstats.o: mstats.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mstats.o `test -f 'mstats.c' || echo '$(srcdir)/'`mstats.c
lib_a-mstats.obj: mstats.c
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mstats.obj `if test -f 'mstats.c'; then $(CYGPATH_W) 'mstats.c'; else $(CYGPATH_W) '$(srcdir)/mstats.c'; fi`
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
@ -578,18 +593,9 @@ $(lpfx)valloc.o: tiny-malloc.c
$(lpfx)pvalloc.o: tiny-malloc.c
$(MALLOC_COMPILE) -DDEFINE_PVALLOC -c $(srcdir)/tiny-malloc.c -o $@
$(lpfx)mallinfo.o: tiny-malloc.c
$(MALLOC_COMPILE) -DDEFINE_MALLINFO -c $(srcdir)/tiny-malloc.c -o $@
$(lpfx)mallstats.o: tiny-malloc.c
$(MALLOC_COMPILE) -DDEFINE_MALLOC_STATS -c $(srcdir)/tiny-malloc.c -o $@
$(lpfx)msize.o: tiny-malloc.c
$(MALLOC_COMPILE) -DDEFINE_MALLOC_USABLE_SIZE -c $(srcdir)/tiny-malloc.c -o $@
$(lpfx)mallopt.o: mallocr.c
$(MALLOC_COMPILE) -DDEFINE_MALLOPT -c $(srcdir)/mallocr.c -o $@
$(lpfx)mallocr.o: mallocr.c
$(MALLOC_COMPILE) -DDEFINE_MALLOC -c $(srcdir)/mallocr.c -o $@

View File

@ -0,0 +1,6 @@
/* stdlib/mstats.c defines all these symbols in this file.
TODO: Missing mstats function. */
#define DEFINE_MALLINFO
#define DEFINE_MALLOC_STATS
#define DEFINE_MALLOPT
#include "tiny-malloc.c"