ack
ack copied to clipboard
Failed to compile in FreeBSD 10.3 i386
Compile ack default
branch in FreeBSD 10.3 i386 failed with following error:
CPP /tmp/ack-build/obj/i86/mach/proto/as/comm2.y.m
INSTALL /tmp/ack-build/obj/plat/pc86//preprocessed-comm2.y
YACC /tmp/ack-build/obj/plat/pc86//y.tab.c
yacc: 1 shift/reduce conflict.
CC /tmp/ack-build/obj/i86//tmp/ack-build/obj/plat/pc86//y.tab.o
/tmp/ack-build/obj/plat/pc86//preprocessed-comm2.y:96:3: error: conflicting types for '__mbstate_t'
} __mbstate_t;
^
In file included from /usr/local/lib/gcc48/gcc/i386-portbld-freebsd10.1/4.8.5/include-fixed/stdlib.h:47:0,
from /tmp/ack-build/obj/plat/pc86//preprocessed-comm2.y:2:
/usr/include/sys/_types.h:113:3: note: previous declaration of '__mbstate_t' was here
} __mbstate_t;
^
plat/pc86/build.mk:29: recipe for target '/tmp/ack-build/obj/i86//tmp/ack-build/obj/plat/pc86//y.tab.o' failed
gmake: *** [/tmp/ack-build/obj/i86//tmp/ack-build/obj/plat/pc86//y.tab.o] Error 1
I don't get this error, but I find a similar problem with OpenBSD 6.0 amd64. The C compiler sees two copies of <machine/_types.h>.
This happens because we run cpp twice. We run cpp before yacc, and then cc runs cpp as usual when compiling y.tab.c from yacc. The source file mach/proto/as/comm2.y has #define _include #include
. Any #include
happens in the first cpp, but _include
happens in the second cpp.
Now comm2.y does #include "comm0.h"
, and mach/proto/as/comm0.h does #include <stdint.h>
and #include "out.h"
, and h/out.h has another #include <stdint.h>
. So the first cpp enters <stdint.h>. But comm0.h also does _include <stdlib.h>
. So the second cpp enters <stdlib.h>. In OpenBSD, both <stdint.h> and <stdlib.h> include <machine/_types.h>. So both the first cpp and the second cpp enter <machine/_types.h>.
The file obj/plat/linuxppc/as/yacc/yaccinput/comm2.y is the output of the first cpp. I can see that all typedefs from <machine/_types.h> and <stdint.h> have been copied to the yacc input. The #include <stdlib.h>
is also in the yacc input. The files obj/plat/linuxppc/as/yacc/y.tab.[ch] are the yacc output. Again, I see both the typedefs and the #include
in y.tab.c. So when we compile y.tab.c, the compiler sees two copies of <machine/_types.h>: one copy in y.tab.c and one included from <stdlib.h>.
OpenBSD declares __mbstate_t in <sys/_types.h>, but luckily for me, <stdint.h> never includes <sys/_types.h>, so I never get the error of two __mbstate_t declarations.
With the fix in #44, compliation in FreeBSD can proceed further, but still failed with following error:
plat/linux68k/include+pkg
lang/b/lib+lib_linux68k/init
opt2: error on line 0: wrong input file
/tmp/ack-build/staging/bin/ack: /tmp/ack-build/staging/lib/ack/em_opt2 died with signal 6
*** Error code 1