You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Doesn't build when using netbsd curses on Linux #8087
/// Under curses, tputs expects an int (*func)(char) as its last parameter, but in ncurses, tputs
/// expects a int (*func)(int) as its last parameter. tputs_arg_t is defined to always be what tputs
/// expects. Hopefully.
#if !defined(NCURSES_VERSION) || defined(__NetBSD__)
typedef int tputs_arg_t;
#else
typedef char tputs_arg_t;
#endif
doesn't cover this specific use case. Ideally it would be possible to run a proper test in CMakeLists and use the result of that? Not urgent, it's easy to fix locally, but still a build bug.
CMake's weird FindCurses implementation has caused us lots of grief. We don't run on any platforms where pkgconfig isn't a thing; personally, if you want to open a PR that fixes the netbsd curses problem and happens to change FindCurses to a fallback for pkgconfig rather than the other way around, I would happy to review it.
NetBSD doesn't provide pkgconfig files for libcurses. That appears to be something the Linux port added... It should be easy to detect ncurses because it defines NCURSES_VERSION_MAJOR etc.
here. So unless my brain is refusing to logic again (not an impossibility, it does that sometimes), that should already be taken on NetBSD and on systems without ncurses.
Or is this specifically about NCURSES_VERSION_MAJOR?
@faho Hm, honestly I just scanned ncurses.h to look for something that would uniquely identify it as ncurses. But now I realize the problem is more complicated...
The problematic function is clearly a terminfo function, and I guess terminfo is usually provided by ncurses on non-NetBSD systems, but NetBSD libterminfo is still used on NetBSD if you're using ncurses (edit: actually, no, probably not?). Is the Linux port of NetBSD libcurses not using NetBSD libterminfo (that seems like a mistake), or is NCURSES_VERSION being defined somehow (also a mistake)?
This appears ŧo have its own tputs and I can't find an NCURSES_VERSION define anywhere.
There is sabotage-linux/netbsd-curses#43, which explains that libterminfo is still separate, so it appears our curses-finding magic finds ncurses terminfo and NetBSD curses.
Which, uh, yeah, that's... not gonna work, is it?
Using pkg-config if possible and falling back to FindCurses would probably fix even that, tho.
There is sabotage-linux/netbsd-curses#43, which explains that libterminfo is still separate, so it appears our curses-finding magic finds ncurses terminfo and NetBSD curses.
That isn't the case here. I have only netbsd-curses headers.
Either you have ncurses, and NCURSES_VERSION is defined, so it picks the datatype that's correct for ncurses,
or you don't have ncurses, and NCURSES_VERSION is not defined, so it picks the datatype that's appropriate for NetBSD-curses - including the linux port.
If NCURSES_VERSION is defined, then you probably also have ncurses installed and cmake picks it up partially (or you defined it yourself and that's the issue).
Either way, I would quite like to have at the very least the actual compiler error, and ideally some reproduction steps.
The issue here is that NetBSD uses the same prototype as ncurses, but netbsd-curses on Linux doesn't define __NetBSD__. So we fallback to the char definition, which is wrong. Without applying my changes:
/home/ericonr/mypro/fish-shell/src/output.cpp: In member function 'int outputter_t::term_puts(const char*, int)':
/home/ericonr/mypro/fish-shell/src/output.cpp:308:54: error: invalid conversion from 'int (*)(tputs_arg_t)' {aka 'int (*)(char)'} to 'int (*)(int)' [-fpermissive]
308 | int res = tputs(const_cast<char *>(str), affcnt, tputs_writer);
| ^~~~~~~~~~~~
| |
| int (*)(tputs_arg_t) {aka int (*)(char)}
In file included from /usr/include/term.h:2002,
from /home/ericonr/mypro/fish-shell/src/output.cpp:16:
/usr/include/termcap.h:40:31: note: initializing argument 3 of 'int tputs(const char*, int, int (*)(int))'
40 | int tputs(const char *, int, int (*)(int));
| ^~~~~~~~~~~~
[42/105] Building CXX object CMakeFiles/fishlib.dir/src/parse_execution.cpp.o
ninja: build stopped: subcommand failed.
Unless I am grossly misunderstanding this, this branch should also be taken if NCURSES_VERSION isn't defined. Which, since you've been swearing that you don't have ncurses, should be the case here?
Can you just check if you have NCURSES_VERSION defined?
Activity
ericonr commentedon Jun 28, 2021
Fixing this is not enough for it to build; this setup also confuses
FindPackage(Curses)and fish'spkg_configfallback isn't 100% correct.faho commentedon Jun 28, 2021
The
FindPackage(Curses)bit would of course have to be improved in cmake (or whatever else provides that).Tbh this isn't something I would want to work on as it's not a use case I have. Patches welcome!
ericonr commentedon Jun 28, 2021
No worries, this is mostly a documentation issue. If I can come up with a clean fix, I will open a PR; in the meantime I just ripped some stuff out.
ericonr commentedon Jun 28, 2021
Using
pkgconfigfirst instead of as a fallback would be almost enough, it's CMake's weird logic in FindCurses that gets things wrong.mqudsi commentedon Aug 13, 2021
CMake's weird
FindCursesimplementation has caused us lots of grief. We don't run on any platforms wherepkgconfigisn't a thing; personally, if you want to open a PR that fixes the netbsd curses problem and happens to changeFindCursesto a fallback forpkgconfigrather than the other way around, I would happy to review it.alarixnia commentedon Sep 15, 2021
NetBSD doesn't provide pkgconfig files for libcurses. That appears to be something the Linux port added... It should be easy to detect ncurses because it defines
NCURSES_VERSION_MAJORetc.faho commentedon Sep 15, 2021
@alarixnia I'm assuming you mean we should replace the curses-related
__NetBSD__checks withNCURSES_VERSION_MAJORchecks?I'm not sure if that would work, given we do
#if !defined(NCURSES_VERSION) || defined(__NetBSD__)here. So unless my brain is refusing to logic again (not an impossibility, it does that sometimes), that should already be taken on NetBSD and on systems without ncurses.
Or is this specifically about NCURSES_VERSION_MAJOR?
alarixnia commentedon Sep 15, 2021
@faho Hm, honestly I just scanned ncurses.h to look for something that would uniquely identify it as ncurses. But now I realize the problem is more complicated...
The problematic function is clearly a terminfo function, and I guess terminfo is usually provided by ncurses on non-NetBSD systems, but NetBSD libterminfo is still used on NetBSD if you're using ncurses (edit: actually, no, probably not?). Is the Linux port of NetBSD libcurses not using NetBSD libterminfo (that seems like a mistake), or is NCURSES_VERSION being defined somehow (also a mistake)?
faho commentedon Sep 15, 2021
This appears ŧo have its own tputs and I can't find an NCURSES_VERSION define anywhere.
There is sabotage-linux/netbsd-curses#43, which explains that libterminfo is still separate, so it appears our curses-finding magic finds ncurses terminfo and NetBSD curses.
Which, uh, yeah, that's... not gonna work, is it?
Using pkg-config if possible and falling back to FindCurses would probably fix even that, tho.
ericonr commentedon Sep 16, 2021
That isn't the case here. I have only netbsd-curses headers.
faho commentedon Sep 16, 2021
Then where/why is NCURSES_VERSION defined?
faho commentedon Sep 21, 2021
Okay, I don't see how this fails to build.
Either you have ncurses, and NCURSES_VERSION is defined, so it picks the datatype that's correct for ncurses,
or you don't have ncurses, and NCURSES_VERSION is not defined, so it picks the datatype that's appropriate for NetBSD-curses - including the linux port.
If NCURSES_VERSION is defined, then you probably also have ncurses installed and cmake picks it up partially (or you defined it yourself and that's the issue).
Either way, I would quite like to have at the very least the actual compiler error, and ideally some reproduction steps.
ericonr commentedon Sep 23, 2021
The issue here is that NetBSD uses the same prototype as ncurses, but netbsd-curses on Linux doesn't define
__NetBSD__. So we fallback to thechardefinition, which is wrong. Without applying my changes:faho commentedon Sep 23, 2021
But the condition isn't just about
__NetBSD__!What about the first half?
#if !defined(NCURSES_VERSION) || defined(__NetBSD__)Unless I am grossly misunderstanding this, this branch should also be taken if NCURSES_VERSION isn't defined. Which, since you've been swearing that you don't have ncurses, should be the case here?
Can you just check if you have NCURSES_VERSION defined?
faho commentedon Sep 23, 2021
Did you, uh, edit that code snippet? Because looking at the actual code it says:
fish-shell/src/fallback.h
Line 56 in 5a685c1
Without the
!!So I have no idea who even uses
charhere?faho commentedon Sep 23, 2021
Ah, our old friend, OpenIndiana/Solaris/Illumos uses char. Blergh, let's just try_compile the pain away.
Check for tputs type via cmake
ericonr commentedon Sep 25, 2021
Shoot, sorry! I edited it like that to compile successfully locally for me, didn't realize I had pasted the edited version here. Thanks!
CHANGELOG updates for 3.4.0