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


Christian Groessler wrote:
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.



Doh, I should have spotted that as obvious. Thanks.



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?



If you didn't specify an option like -i on the build, then check which make you are using and if there are any updates available. You can set up a small test case to reproduce the problem and if still present you should open a bug.



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



It is likely that I gummed this up when I brought the code in originally and modified it to work for newlib. Obviously, this new code has never been compiled on the z8k. I've made up a proposed patch to fix this. Try it out and let me know.


-- Jeff J.





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: mprec.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdlib/mprec.h,v
retrieving revision 1.5
diff -u -p -r1.5 mprec.h
--- mprec.h	5 Jul 2006 16:18:30 -0000	1.5
+++ mprec.h	5 Jun 2007 20:48:30 -0000
@@ -351,10 +351,14 @@ extern double rnd_prod(double, double), 
  * slower.  Hence the default is now to store 32 bits per long.
  */
 
-#ifndef Pack_32
-#define Pack_32
-#endif
-#endif
+ #ifndef Pack_32
+  #define Pack_32
+ #endif
+#else  /* Just_16 */
+ #ifndef Pack_16
+  #define Pack_16
+ #endif
+#endif /* Just_16 */
 
 #ifdef Pack_32
 #define ULbits 32

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