Bug 227528 - devel/ncurses and USES=ncurses is not sufficient (= is broken under some conditions)
Summary: devel/ncurses and USES=ncurses is not sufficient (= is broken under some cond...
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Steve Wills
Depends on:
Reported: 2018-04-15 16:07 UTC by Rudolf Čejka
Modified: 2019-01-17 19:30 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Rudolf Čejka 2018-04-15 16:07:34 UTC
This problem seems to be very intricate with many "if"s, so I try to explain it as I digged into it:

The problem: When net-im/centerim is compiled on a system without devel/ncurses, everything is good. However, when devel/ncurses is preinstalled and net-im/centerim then compiled, terminal output is broken.

The reason: It includes system ncurses.h, but uses ports libraries.

The explanation: System ncurses.h and system libraries libncurses/libtinfo define and use chtype as 8-byte long, but ports ncurses.h and ports libraries libncurses/libtinfo define and use chtype as 4-byte unsigned. The worst case is in definition of library's chtype acs_map[], which is used in application through ACS characters as ACS_* macros. If the headers and libraries are mismatched, the application do not reference correct ACS characters. Sometimes it writes nul characters (@), sometimes it dumps core.

When port has USES=ncurses and devel/ncurses is installed, the port should use -I${NCURSESINC} in CFLAGS and -L${NCURSESLIB} in LDFLAGS. However, it is not sufficient itself.

But why sysutils/screen with just NCURSESINC/NCURSESLIB does work? It is because it does not include any of ncurses headers. It needs just tget*() function family, and it is defined itself in osdef.h, without any external header. If you try to include ncurses.h in screen.c, you end on 'ncurses/ncurses_dll.h' file not found.

Well. And why net-mgmt/cnagios "works" without NCURSESINC/NCURSESLIB, linked with ports ncurses and included with system ncurses.h? Because it does not use ACS_* macros.

And so on. It seems to me that every port using ncurses is another case for itself, where universal instruction would be:
Add "-I${NCURSESINC} -I/usr/local/include" to CFLAGS and add "-L${NCURSESLIB}" to LDFLAGS, but as I feel, it does not look systemically at all.

I think that fixes are needed by both: Ncurses infrastructure and ports using USES=ncurses themselves. Sometimes they do not work at all, sometimes they just look that they work, and sometimes they would be correct.
Comment 1 Steve Wills freebsd_committer 2019-01-17 19:30:41 UTC
Sorry for the long delay on this. Looking over this, it seems to make sense, but there doesn't seem to be an easy solution.

Perhaps the best thing would be to figure out what changes to the infrastructure are needed and do those in this PR and then what changes would be needed in the PRs that use ncurses and open those in separate PRs.