Page MenuHome GnuPG

Build failure with Clang 15 (pinentry-curses.c, error: call to undeclared function 'addnwstr' ...)
Closed, InvalidPublic

Description

Clang 15 makes implicit function declarations an error by default (see https://releases.llvm.org/15.0.0/tools/clang/docs/ReleaseNotes.html#improvements-to-clang-s-diagnostics)

I get the following error when trying to build pinentry 1.2.1 on Gentoo with Clang 15:

clang -DHAVE_CONFIG_H -I. -I..   -I../secmem -Wall -I/usr/include/ncursesw  -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -Wall -Wno-pointer-sign -Wpointer-arith -c -o libpinentry_curses_a-pinentry-curses.o `test -f 'pinentry-curses.c' || echo './'`pinentry-curses.c
pinentry-curses.c:651:8: error: call to undeclared function 'addnwstr'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
              ADDCH (start[i]);
              ^
pinentry-curses.c:283:18: note: expanded from macro 'ADDCH'
#define ADDCH(x) addnwstr (&x, 1);
                 ^
pinentry-curses.c:651:8: note: did you mean 'addnstr'?
pinentry-curses.c:283:18: note: expanded from macro 'ADDCH'
#define ADDCH(x) addnwstr (&x, 1);
                 ^
/usr/include/ncursesw/curses.h:609:28: note: 'addnstr' declared here
extern NCURSES_EXPORT(int) addnstr (const char *, int);                 /* generated */
                           ^
pinentry-curses.c:654:6: error: call to undeclared function 'addnwstr'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
            ADDCH (start[len - 1]);
            ^
pinentry-curses.c:283:18: note: expanded from macro 'ADDCH'
#define ADDCH(x) addnwstr (&x, 1);
                 ^
pinentry-curses.c:687:7: error: call to undeclared function 'addnwstr'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
                    ADDCH (*p);
                    ^
pinentry-curses.c:283:18: note: expanded from macro 'ADDCH'
#define ADDCH(x) addnwstr (&x, 1);
                 ^
pinentry-curses.c:724:8: error: call to undeclared function 'addnwstr'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
              ADDCH (*(p++));
              ^
pinentry-curses.c:283:18: note: expanded from macro 'ADDCH'
#define ADDCH(x) addnwstr (&x, 1);
                 ^
4 errors generated.
make[2]: *** [Makefile:473: libpinentry_curses_a-pinentry-curses.o] Error 1
make[2]: *** Waiting for unfinished jobs....

Full log:


config.log:

Details

External Link
https://bugs.gentoo.org/869128
Version
1.2.1

Event Timeline

It looks like there was a problem similar to this a while ago: https://dev.gnupg.org/T2320 where it turned out for unicode ncurses builds, a specific header had to be included, but that workaround seems to have been removed from pinentry since.

thesamesam set External Link to https://bugs.gentoo.org/869128.Sep 8 2022, 1:19 AM

Could you please check what pkg-config --cflags ncurses returns?
In my environment (of Debian), it returns:

-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600

... which enables NCURSES_WIDECHAR as 1 in curses.h, and gives declarations for addnwstr and its friends.

Mysteriously, I get nothing:

$ pkg-config --cflags nurses

But in my normal environment (outside of the clang-must chroot):

$ pkg-config --cflags ncurses
-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600

I'll try to poke further, but I welcome any suggestions as to why this might be while I look...

Thanks for your help @gniibe and apologies for wasting your time. It looks like this is an issue with ncurses on musl systems and I'll pursue it there. I have a patch to their configure which works & fixes building pinentry.