This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: can't build for z8k-coff


Hi Jeff,

On Tue, 5 Jun 2007, Jeff Johnston wrote:

>   Let's start with your output.  You'll notice that argz_insert.c is failing
> to compile.  For some reason, ptrdiff_t appears to be undefined by your
> compiler's stddef.h when __need_ptrdiff_t is set.  From libc/argz_insert.c.
> 
> > #include <errno.h>
> > #include <sys/types.h>
> > #include <string.h>
> > #include <stdlib.h>
> > #include <argz.h>
> > #define __need_ptrdiff_t
> > #include <stddef.h>
> > 
> > error_t
> > _DEFUN (argz_insert, (argz, argz_len, before, entry),
> >        char **argz _AND
> >        size_t *argz_len _AND
> >        char *before _AND
> >        const char *entry)
> > {
> >   int len = 0;
> > 
> >   if (before == NULL)
> >     return argz_add(argz, argz_len, entry);
> > 
> >   if (before < *argz || before >= *argz + *argz_len)
> >     return EINVAL;
> > 
> >   while (before != *argz && before[-1])
> >     before--;
> > 
> >   /* delta will always be non-negative, and < *argz_len */
> >   ptrdiff_t delta = before - *argz;
> > 
> 
> z8k-coff-gcc -B/local/newlib-cvs/b-z8k-coff/z8k-coff/z8001/newlib/ -isystem
> /local/newlib-cvs/b-z8k-coff/z8k-coff/z8001/newlib/targ-include -isystem
> /local/newlib-cvs/src/newlib/libc/include  -mz8001 -DPACKAGE_NAME=\"newlib\"
> -DPACKAGE_TARNAME=\"newlib\" -DPACKAGE_VERSION=\"1.15.0\"
> -DPACKAGE_STRING=\"newlib\ 1.15.0\" -DPACKAGE_BUGREPORT=\"\"  -I.
> -I/local/newlib-cvs/src/newlib/libc/argz -O2 -fno-builtin      -O2 -g -O2
> -mz8001 -c -o lib_a-argz_insert.o `test -f 'argz_insert.c' || echo
> '/local/newlib-cvs/src/newlib/libc/argz/'`argz_insert.c
> /local/newlib-cvs/src/newlib/libc/argz/argz_insert.c: In function
> `argz_insert':
> /local/newlib-cvs/src/newlib/libc/argz/argz_insert.c:34: syntax error before
> `delta'
> /local/newlib-cvs/src/newlib/libc/argz/argz_insert.c:41: `delta' undeclared
> (first use this function)
> /local/newlib-cvs/src/newlib/libc/argz/argz_insert.c:41: (Each undeclared
> identifier is reported only once
> /local/newlib-cvs/src/newlib/libc/argz/argz_insert.c:41: for each function it
> appears in.)
> z8k-coff-gcc: file path prefix
> `/local/newlib-cvs/b-z8k-coff/z8k-coff/z8001/newlib/' never used
> make[8]: *** [lib_a-argz_insert.o] Error 1

This is easy. It's not c89, delta is declared in the middle of the 
function. I've appended a patch to fix this.


> I don't know why the error appears only as an error 1 instead of an error 2.
> The build should have stopped there.

Yes. I didn't look at the output of the build process since I assumed it 
would stop immediately when an error happens. How can I debug this?


There is another error in stdlib, in gdtoa-gethex.c. It seems that neither
Pack_32 nor Pack_16 is defined.

z8k-coff-gcc -B/local/newlib-cvs/b-z8k-coff/z8k-coff/z8001/newlib/ -isystem /local/newlib-cvs/b-z8k-coff/z8
k-coff/z8001/newlib/targ-include -isystem /local/newlib-cvs/src/newlib/libc/include  -mz8001 -DPACKAGE_NAME
=\"newlib\" -DPACKAGE_TARNAME=\"newlib\" -DPACKAGE_VERSION=\"1.15.0\" -DPACKAGE_STRING=\"newlib\ 1.15.0\" -
DPACKAGE_BUGREPORT=\"\"  -I. -I../../../../../../src/newlib/libc/stdlib -O2 -fno-builtin      -O2 -g -O2   
-mz8001 -c -o lib_a-gdtoa-gethex.o `test -f 'gdtoa-gethex.c' || echo '../../../../../../src/newlib/libc/std
lib/'`gdtoa-gethex.c
../../../../../../src/newlib/libc/stdlib/gdtoa-gethex.c: In function `increment':
../../../../../../src/newlib/libc/stdlib/gdtoa-gethex.c:119: `y' undeclared (first use this function)
../../../../../../src/newlib/libc/stdlib/gdtoa-gethex.c:119: (Each undeclared identifier is reported only o
nce
../../../../../../src/newlib/libc/stdlib/gdtoa-gethex.c:119: for each function it appears in.)
../../../../../../src/newlib/libc/stdlib/gdtoa-gethex.c:119: `carry' undeclared (first use this function)
z8k-coff-gcc: file path prefix `/local/newlib-cvs/b-z8k-coff/z8k-coff/z8001/newlib/' never used
make[8]: *** [lib_a-gdtoa-gethex.o] Error 1


When I grep for "Pack_" I get this

langhals:/local/newlib-cvs/src$ find . -type f | xargs grep Pack_
./newlib/libc/stdlib/dtoa.c:#ifdef Pack_32
./newlib/libc/stdlib/dtoa.c:#ifdef Pack_32
./newlib/libc/stdlib/dtoa.c:#ifdef Pack_32
./newlib/libc/stdlib/dtoa.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.c:#ifdef Pack_16
./newlib/libc/stdlib/mprec.c:#ifdef Pack_32
./newlib/libc/stdlib/mprec.h:/* When Pack_32 is not defined, we store 16 bits per 32-bit long.
./newlib/libc/stdlib/mprec.h:#ifndef Pack_32
./newlib/libc/stdlib/mprec.h:#define Pack_32
./newlib/libc/stdlib/mprec.h:#ifdef Pack_32
./newlib/libc/stdlib/gdtoa-gethex.c:#ifdef Pack_16
./newlib/libc/stdlib/gdtoa-gethex.c:#ifdef Pack_32
langhals:/local/newlib-cvs/src$ 


Hmm, it's never set except in mprec.h, but only if Just_16 isn't defined.
Just_16 is defined for z8k for some reason, and it seems to be the only
target which defines it. Is z8k the only 16bit target of newlib?


regards,
chris


Here's the patch for libc/argz/argz_insert.c:

diff -u -p -r1.5 argz_insert.c
--- newlib/libc/argz/argz_insert.c      4 Apr 2007 20:49:07 -0000       1.5
+++ newlib/libc/argz/argz_insert.c      5 Jun 2007 20:03:51 -0000
@@ -20,6 +20,7 @@ _DEFUN (argz_insert, (argz, argz_len, be
        const char *entry)
 {
   int len = 0;
+  ptrdiff_t delta;
 
   if (before == NULL)
     return argz_add(argz, argz_len, entry);
@@ -31,7 +32,7 @@ _DEFUN (argz_insert, (argz, argz_len, be
     before--;
 
   /* delta will always be non-negative, and < *argz_len */
-  ptrdiff_t delta = before - *argz;
+  delta = before - *argz;
 
   len = strlen(entry) + 1;
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]