Netboot Mailing List (by thread)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mknbi-mgl compile problem. SOLVED: patch included




Vsevolod Sipakoff <versus@megalink.ru> writes:

> I've got strange errors trying to compile
> both netboot-0.9.0e and netboot-0.8.1
> Maybe it's because bison or flex is broken, I wonder?
> 
> here is result of 'make':
> ======================================================
> making all in mknbi-mgl
> make[1]: Entering directory `/usr/local/src/netboot-0.9.0e/mknbi-mgl'
> gcc -O2 -Wall  -DHAVE_CONFIG_H -I. -I.. -I../include -DPARANOID   -c y.tab.c -o
> y.tab.o
> mglparse.y: In function `yyparse':
> mglparse.y:2388: called object is not a function

I had the same problem and tracked it down today.

The problem is in mknbi-mgl/mglparse.y in the lines

      /* We need this for the code generator */
      static struct sym strlen = {
              funcsym, "", 0, -1, {
                { 0, 0, CMD_STRLEN, 1, &int_type,
                  { &string_type },
                  { ATTR_CONST }
                }
              }, NULL
      };

strlen is used as a local variable name which conflicts with strcmp()
in glibc-2.1.x.  When compiling with optimization (-O or -O2, but not
-Os) the preprocessor symbol __OPTIMIZE__ is defined and then
glibc-2.1.x defines strcmp() as a macro using the function strlen().
In mglparse.y however, strlen is defined as a variable, thus breaking
the call to strcmp() a few lines later.

The solution is to compile without -O or -O2, or better to rename the
variable strlen:

--- mknbi-mgl/mglparse.y.orig	Sun Jan  3 21:38:29 1999
+++ mknbi-mgl/mglparse.y	Tue Apr 11 12:34:19 2000
@@ -2373,7 +2373,7 @@
 			struct expr *ep;
 
 			/* We need this for the code generator */
-			static struct sym strlen = {
+			static struct sym str_len = {
 				funcsym, "", 0, -1, {
 				  { 0, 0, CMD_STRLEN, 1, &int_type,
 				    { &string_type },
@@ -2387,11 +2387,11 @@
 			    exprtype($1) == EXPR_STRING &&
 			    $3 != NULL && !strcmp($3->name, "len")) {
 				ep = newexpr();
-				ep->type = strlen.def.f.ret;
-				ep->opcode = strlen.def.f.opcode;
-				ep->exprnum = strlen.def.f.argnum;
+				ep->type = str_len.def.f.ret;
+				ep->opcode = str_len.def.f.opcode;
+				ep->exprnum = str_len.def.f.argnum;
 				ep->exprlist[0] = reorg($1);
-				ep->spec.func = &strlen;
+				ep->spec.func = &str_len;
 				$$ = ep;
 				break;
 			}
===========================================================================
This Mail was sent to netboot mailing list by:
Urs Thuermann <urs@isnogud.escape.de>
To get help about this list, send a mail with 'help' as the only string in
it's body to majordomo@baghira.han.de. If you have problems with this list,
send a mail to netboot-owner@baghira.han.de.



For requests or suggestions regarding this mailing list archive please write to netboot@gkminix.han.de.