Closed Earnestly closed 8 years ago
hmm i suspect this is due to sys/cdefs.h used here in-tree not being compatible with the Gnu one
try this: in sys/cdefs.h, add
#ifdef __GLIBC__
#include_next <sys/cdefs.h>
#endif
Ah, that looks much better. Now I get the following:
% make
cc -I. -I./libterminfo -DHAVE_WCHAR -I./tic -Werror-implicit-function-declaration -c -o tic/tic.o tic/tic.c
tic/tic.c: In function ‘easprintf’:
tic/tic.c:89:8: error: implicit declaration of function ‘vasprintf’ [-Werror=implicit-function-declaration]
ret = vasprintf(s, fmt, ap);
^
cc1: some warnings being treated as errors
GNUmakefile:303: recipe for target 'tic/tic.o' failed
make: *** [tic/tic.o] Error 1
Adding CPPFLAGS=-D_GNU_SOURCE
gets past this but then follows up with:
% make
cc -Werror-implicit-function-declaration -D_GNU_SOURCE -I. -I./libterminfo -DHAVE_WCHAR -c -o libterminfo/term.o libterminfo/term.c
libterminfo/term.c: In function ‘_ti_dbgetterm’:
libterminfo/term.c:286:2: error: implicit declaration of function ‘strlcpy’ [-Werror=implicit-function-declaration]
strlcpy(database, path, sizeof(database));
^
cc1: some warnings being treated as errors
<builtin>: recipe for target 'libterminfo/term.o' failed
make: *** [libterminfo/term.o] Error 1
I'm not at all sure if this is correct but I added the following to
libterminfo/term.c
:
#ifdef __GLIBC__
#include <bsd/string.h>
#endif
Which resulted in:
In file included from libterminfo/ti.c:35:0:
./libterminfo/term_private.h:158:21: error: unknown type name ‘uint8_t’
ssize_t _ti_flatten(uint8_t **, const TIC *);
^
In file included from /usr/include/features.h:368:0,
from /usr/include/assert.h:35,
from libterminfo/ti.c:33:
libterminfo/ti.c: In function ‘tigetstr’:
libterminfo/ti.c:133:10: error: ‘intptr_t’ undeclared (first use in this function)
return __UNCONST(ti_getstr(cur_term, id));
^
libterminfo/ti.c:133:10: note: each undeclared identifier is reported only once for each function it appears in
<builtin>: recipe for target 'libterminfo/ti.o' failed
make: *** [libterminfo/ti.o] Error 1
This implies missing #include <stdint.h>
so I tried adding the header to
temp_private.h
which worked. Next:
libterminfo/curterm.c: In function ‘set_curterm’:
libterminfo/curterm.c:102:12: error: implicit declaration of function ‘strlcpy’ [-Werror=implicit-function-declaration]
if ((n = strlcpy(p, nterm->name, l)) == strlen(p)) {
^
cc1: some warnings being treated as errors
<builtin>: recipe for target 'libterminfo/curterm.o' failed
make: *** [libterminfo/curterm.o] Error 1
Again, added #include <bsd/string.h>
but then we're back to square one:
cc -D_GNU_SOURCE -I. -I./libterminfo -DHAVE_WCHAR -I./libcurses -Werror-implicit-function-declaration -c -o libcurses/acs.o libcurses/acs.c
In file included from /usr/include/sys/types.h:132:0,
from libcurses/curses.h:43,
from libcurses/acs.c:37:
/usr/include/time.h:59:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘typedef’
typedef __clock_t clock_t;
^
/usr/include/time.h:60:1: error: unknown type name ‘__END_NAMESPACE_STD’
__END_NAMESPACE_STD
^
/usr/include/time.h: In function ‘__USING_NAMESPACE_STD’:
/usr/include/time.h:73:1: error: expected declaration specifiers before ‘__BEGIN_NAMESPACE_STD’
__BEGIN_NAMESPACE_STD
^
/usr/include/time.h:76:1: error: unknown type name ‘__END_NAMESPACE_STD’
__END_NAMESPACE_STD
^
And so on. I think though I see the pattern, in this case the solution
is to probably do the same thing with #include_next <sys/types.h>
?
(Although this doesn't work either and I'm mostly out of my depth :-/)
i pushed a clean fix for the sys/cdefs.h issue, please see e77e2817bec2f4f581f0adefd3a03e8b9629855c
regarding glibc's lack of strlcpy(), rather than pulling in libbsd i'd suggest to add this to netbsd_sys/cdefs.h until i come up with a proper fix:
#ifdef __GLIBC__
#include <stddef.h>
static inline size_t strlcpy(char* __restrict dst, const char * __restrict src, size_t size) {
size_t ret = 0;
while(*src && size>1) {
*dst=*src;
dst++,src++,size--,ret++;
}
if(size)*dst=0;
while(*(src++)) ret++;
return ret;
}
#endif
Ah thanks!
I added that definition but since tic/cdbw.h
includes <netbsd_sys/cdefs.h>
I get redefinition errors:
In file included from ./tic/cdbw.h:37:0,
from tic/tic.c:45:
./netbsd_sys/cdefs.h:58:22: error: redefinition of ‘strlcpy’
static inline size_t strlcpy(char* __restrict dst, const char * __restrict src, size_t size) {
^
In file included from tic/tic.c:35:0:
./netbsd_sys/cdefs.h:58:22: note: previous definition of ‘strlcpy’ was here
static inline size_t strlcpy(char* __restrict dst, const char * __restrict src, size_t size) {
^
GNUmakefile:303: recipe for target 'tic/tic.o' failed
I've temporarily added a simple #ifndef
guard to prevent it; unfortuantely later in the build this happens:
_(Even though curterm.c
includes <netbsd_sys/cdefs.h>
:-S)_
libterminfo/curterm.c: In function ‘set_curterm’:
libterminfo/curterm.c:102:12: error: implicit declaration of function ‘strlcpy’ [-Werror=implicit-function-declaration]
if ((n = strlcpy(p, nterm->name, l)) == strlen(p)) {
^
cc1: some warnings being treated as errors
<builtin>: recipe for target 'libterminfo/curterm.o' failed
make: *** [libterminfo/curterm.o] Error 1
There's still the issue of libterminfo/term_private.h
which doesn't include <stdint.h>
.
Thank you for your efforts and help thus far \o/
i pushed some commits, replaced all strlcpy calls (hopefully didnt introduce bugs). according to the information i have, it should compile now.
It seems to get a lot further, thank you for all the effort so far and it's
nice to see snprintf
being used instead of str*
, however I still get these
annoying syntax errors:
% CPPFLAGS=-D_GNU_SOURCE make
...
cc -D_GNU_SOURCE -I. -I./libterminfo -DHAVE_WCHAR -I./libcurses -Werror-implicit-function-declaration -c -o libcurses/acs.o libcurses/acs.c
In file included from /usr/include/sys/types.h:132:0,
from libcurses/curses.h:43,
from libcurses/acs.c:37:
/usr/include/time.h:59:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘typedef’
typedef __clock_t clock_t;
^
/usr/include/time.h:60:1: error: unknown type name ‘__END_NAMESPACE_STD’
__END_NAMESPACE_STD
^
This is in an unpatched build, all I add is CPPFLAGS=-D_GNU_SOURCE
(for
vasprintf
).
i suspect your sys/cdefs.h sees some macro defined and thinks it's not needed to define __END_NAMESPACE_STD. could you pastebin your sys/cdefs, sys/types.h and sys/time.h ?
Edit: Keep in mind that the errors about syntax go on for thousands of lines, not just ending at the NAMESPACE stuff.
oops what i needed was time.h, not sys/time.h :(
i think i found the culprit, try now ( 9635c9d )
Yeah, it's much better now although I needed to add #include <stdint.h>
to
libcurses/curses_private.h
due to this:
libcurses/color.c:642:2: error: unknown type name ‘uint32_t’
Although I seem to end up here:
cc -D_GNU_SOURCE -I. -I./libterminfo -DHAVE_WCHAR -I./libcurses -I./libmenu -I./libform -Werror-implicit-function-declaration -c -o libform/field.o libform/field.c
libform/field.c:30:0: warning: "_GNU_SOURCE" redefined
#define _GNU_SOURCE
^
<command-line>:0:0: note: this is the location of the previous definition
In file included from libform/field.c:35:0:
./netbsd_sys/cdefs.h:23:0: warning: "__P" redefined
#define __P(X) X
^
In file included from /usr/include/features.h:368:0,
from /usr/include/string.h:25,
from libform/field.c:31:
/usr/include/sys/cdefs.h:82:0: note: this is the location of the previous definition
#define __P(args) args
^
In file included from ./libcurses/curses.h:46:0,
from ./libform/form.h:38,
from libform/field.c:41:
/usr/include/stdio.h:314:6: error: unknown type name ‘_IO_cookie_io_functions_t’
_IO_cookie_io_functions_t __io_funcs) __THROW __wur;
^
GNUmakefile:315: recipe for target 'libform/field.o' failed
make: *** [libform/field.o] Error 1
i've fixed all compilation errors i encountered on an ancient glibc system, hope it works now for you as well.
Ah you even removed the need to manually add _GNU_SOURCE
.
Yes, it builds here without any issues, thank you for all your efforts; I wasn't expecting to even get glibc support without local modifications.
Sorry if I'm being dumb here but there seems to be some issue on my system with how includes or conditional macros are defined, as when attempting to build by simply running
make
I get the following errors:This continues for roughly 3000 lines before ending with:
I don't expect it to really build with glibc but these kinds of errors seem like syntax rules are being broken and I'm not sure where.