-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to evade library mismatches? #133
Comments
No idea if he gets a notification when referenced here, but it would definitely be useful to check with @wmcbrine about an approach he may also use. What do you think about creating this issue at his tracker, too (limiting the issue to utf8+wide, of course)? |
Well, I'll be gobsmacked... this might be easier than I thought. I just added the following lines to
|
The only thing this will break is that an existing library won't work on recompile and that a new compiled module won't work with an old library. |
He does. |
@wmcbrine Thank you for the note. While I don't want to pester you... |
Hmmm... well, we can get a workaround for the second case (old code will look for an un-mangled
It doesn't help with the first case (newly-compiled code will look for the mangled name in an old library that won't have it). Can't say I'm totally sold on this idea and I'm in no rush to implement it. But it may be less stupid than I originally thought. Might be good to add the major version number, so that it'd expand to (say) |
In this case I think it isn't a good idea - if William adds the same (which I hope) he won't have the 32/64 part in, so conflicts between this repo and his will still be visible without a _3/_4 suffix. And if ever a major version 5 comes out (I personally hope that William stays with 3 and you with 4) then the code from an older version should still work with it without relinking (as long as the chtype, utf8 and wide options are the same).
Seems useful for fall-back and also removes the need for the additional ifdef guard. |
Well, we can avoid that by not suffixing a '32'. William's version lacks 64-bit |
Totally, my point was that it is good that the "32"/"64"/none would be enough (and good) to ensure that cross-link and cross-use are not possible. |
@Bill-Gray can you please commit your "easy solution" with the adjusted name of |
… and 8-bit characters and linking to a library built with 64-bit chtypes and wide-chars). See issue #133. Implements my 'this _might_ be easier than I thought' approach.
I held off on committing that until I'd tried it a bit. I've done so, and nothing obvious has broken, so I've committed and pushed it. |
I agree, let's close this one. If you publish a beta2 I'll get the people recheck the reported color issue.
... in case you've missed it in the color issue: vt (win32 within msys) seems to be not working as expected (amount of displayed lines and overwrite).
|
... so with people using the installed 4.2beta an issue came up: Many programs are not directly linked against pdcurses but check which curses library and header is available and use whatever they find. The way GnuCOBOL's configure.ac handles this is similar to what other projects do: AC_CHECK_LIB([ncursesw], [initscr], [], [], [])
AC_CHECK_LIB([ncurses], [initscr], [], [], [])
AC_CHECK_LIB([pdcurses], [initscr], [], [], [])
AC_CHECK_LIB([curses], [initscr], [], [], []) In this case only the library itself is inspected which now doesn't work any more:
Of course people can change |
I'm having some second thoughts about this "improvement". The idea is not totally stupid, but there are some issues with it. |
While it looks more intrusive to adjust the library names it may be the best option. The biggest issue is that everyone builds against libpdcurses, if you change that name then many build systems could not use it out of the box... |
Hm, I've just thought about an option that would only "break" on using
Sounds good? Draft:
This way we end up with both the "new typed" and the "old" name exported, both will function; as soon as the header is included only the "new typed" will be called - if there's a mismatch you'd know this at link time. Opinions? |
Just coming back to this, in the process of checking outstanding issues... This seems reasonable. However... a year has passed. I originally called my posted solution "not totally stupid". It actually appears to be working well enough. I've had no further issues with library mismatches, nor has anybody asked about such (and they used to occur with some frequency). I think I'll call this a decently solved problem and close it. |
Thanks for checking. I really think the most reasonable way would be to create the "matching" pdcurses.h during
|
Hmmm... at present, running -- When copying, it could also insert -- The other ports, at present, lack the concept of a configure script. If they had one, they could similarly insert required #defines. Failing that, running, for example,
could insert whichever #defines were appropriate. As you suggest, we'd make the appropriate Your scheme, as I understand it, could lend itself to another nice thing : if you've run |
Yes, that's the point - and the reason to do this on If you do want to have that "someday" in PDCurses I suggest to reopen this issue. |
... and for XCurses curses.h should be created by the configure script with the relevant defines, if this isn't the case than I should be able to take care of this. |
Hm, I think this is still open until we actually adjust the pdcurses.h on install. @Bill-Gray re-open for automatic header adjustment during install? |
A variant of my previous suggestion:
This way:
|
I should have mentioned that some time back, I tackled what is probably the "tricky" part of this. I wrote a bit of code to configure/reconfigure Already, one can build A similar task could almost certainly have been done with bash and such, but this works on any platform with a C compiler. That leads to the question of how such a tool would be used. Ideally, it would mean that when you run (say) |
That's beautiful. If this is put into the makefiles then everything should "just work". We still have autoconf's "simple" So I totally vote for both curses_configure and internal initscr function to not break existing configure scripts and delay-loading of the library! Reopen? :-) |
I hesitated to reopen, because the current method of modifying (With the warning that I may not be doing a heck of a lot of work on this short-term.) |
It has - but created two big new ones (both in the previous version and in the current), which is a possibly reason that the approach did not reach "upstream" yet:
One may could argue that PDCursesMod is broken in both scenarios since two versions. The one thing that is related but - I agree - less important is to dynamically generate pdcurses.h, because this is about removing the need to manually define the correct matching options that were used during the build (which was always needed, even if cumbersome and partially worked around by people creating a pkconfig file [for posix / posix-like environments] or otherwise matching "port definition" [like it is done with vcpkg]). ... so, if you agree, but don't see any option to work on the entry point issue (actually I don't have the spare time either), then I try to do so. The point is to additional have an
|
I have no say in the compatibility side of things, but just as a comment on the efficacy of the initscr mangling - it worked on me! I threw PDCursesMod into python's windows-curses library to try and fix some issues with panels (it didn't, oh well...) and was forced to fix the names of the character width defines so the library linked correctly. Whatever ends up happening to make PDCursesMod work with more build scripts without having to modify them - I think the name mangling is an excellent solution to user mistakes. |
Looking back through this, I think I may have been a little stupid about one basic point, from @GitMensch's comment on 2021 Dec 6. Am I correct in thinking that the autoconf check in question is solely on There is no real reason I can see that name mangling has to occur on If that would actually do the trick, all I'd need do is go through Still leaves us with the desirability of using |
Commonly.
And do a release.
Totally! Until that is done the docs may should suggest to manually adjust the installed header. |
…it/UTF-8/wide-character, and other settings. See issue #133 and the discussion starting at 'a bit of code to configure/reconfigure'.
I think I may have a workable solution. The basic idea resembles the process for X11 : you run a 'configure' step to specify the flags you want. Unlike that process, the flags are set within To use this solution, first do a Next, you'll need to modify a configure :
$(CC) $(CFLAGS) -o config_curses$(E) $(common)/config_curses.c
ifdef ON_WINDOWS
config_curses -v -d.. $(CFLAGS)
else
wine config_curses -v -d.. $(CFLAGS)
endif
rm config_curses$(E) For VT, edit the configure :
$(CC) $(CFLAGS) -o config_curses$(E) $(common)/config_curses.c
ifdef PREFIX
wine config_curses -v -d.. $(CFLAGS)
else
./config_curses -v -d.. $(CFLAGS)
endif
rm config_curses$(E) Then run @GitMensch , if you try this and find that it works for you, I'll add it for 4.3.5. Otherwise, we can just charge ahead with 4.3.5 "as is", and have this in 4.3.6. I do want to make this work on other compilers and platforms, but it sounds as if the most urgent need is for MinGW on these three platforms. And results from them may inform our handling for the (numerous) other cases. |
Yes, but that would be actually "all GCC", not only MinGW [ok only includes additional Cygwin for wincon, but still "all" for vt]? So that would be a big plus. Note: the ON_WINDOWS and PREFIX checks looks quite ... special. I'm not sure when I'm getting some time to test this. If we can get this into all ports and Makefiles then we can rename curses.h to curses.h.in, add curses.h as dependency for libcurses (if it isn't already in) and have "make configure" be executed automatically if the file is missing. |
True. I think we've got that (haven't tested all permutations yet, though).
You're thinking Wine use is unusual? Possibly so. I do get inquiries about it from time to time, and almost all of my own testing occurs via Wine.
I would expect that might happen eventually. But given the number of ports we have and their various permutations, it'd take a while. The nice thing about the current scheme is that we can build on it gradually. Once it's applied to all ports, we could conceivably switch over to providing |
I think the original issue is solved now; the only thing that this is "related" to that is open is the configure part and as far as I know that should be in a quite good state, too. The most missing part for the configure is to adjust the build instructions in the ports (maybe "as an alternative..."?). Shouldn't we close this issue now? |
(This is a note for future work, basically just to make sure the problem doesn't get completely forgotten about.)
We've had occasional issues where (for example) the PDCurses library is compiled with 32-bit
chtype
s and 8-bit characters, and then the actual program is compiled with 64-bitchtype
s in wide-char mode. Everything links, and then you get bogus results such as shown in the black-and-white screenshot for issue #129. You can also get situations where everything works, except that the keyboard isn't recognized. Or certain characters come out corrupted (mojibake).Not something for the currently pending 4.2.0 release, but I'm inclined to try to do some sort of function name mangling, such that in the above example, the PDCurses library would be compiled with, say,
initscr()
expanded toinitscr_c32()
and the program toinitscr_c64_w()
. A UTF8 build would expand that function toinitscr_c64_u()
. Then, when you tried to mislink, you'd get errors.I chose
initscr()
in the above because it'll always be called and will therefore either be found in the library or not found.Adding suffixes to the name of the libraries, so you'd have (for example)
pdcurses_u32.lib
and.dll
for a build with 32-bitchtype
s and UTF8, could also do the job. I'm a little fuzzy on exactly how we'd avoid library matches, but one or both of these solutions might do it.The text was updated successfully, but these errors were encountered: