Page MenuHomeFreeBSD

devel/readline: Fix build for dependent ports.
ClosedPublic

Authored by des on Oct 5 2024, 8:20 AM.
Tags
None
Referenced Files
F104208429: D46957.diff
Wed, Dec 4, 6:49 PM
Unknown Object (File)
Thu, Nov 28, 11:38 PM
Unknown Object (File)
Tue, Nov 26, 1:12 AM
Unknown Object (File)
Wed, Nov 20, 2:49 AM
Unknown Object (File)
Thu, Nov 7, 4:50 PM
Unknown Object (File)
Nov 1 2024, 4:08 PM
Unknown Object (File)
Oct 30 2024, 3:51 AM
Unknown Object (File)
Oct 10 2024, 3:17 AM
Subscribers

Details

Summary

The previous commit made a bad situation worse by replacing declarations
with incorrect prototypes, thus breaking any software that calls
rl_message() and doesn't know the secret sauce to get the correct
prototype (e.g. devel/rlwrap). Fix this by dropping K&R support and
instead offering an annotated prototype for compilers that understand
the GCC format attribute and an unannotated one for those that don't.

Fixes: ee994524fffd
PR: 281633

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 59783
Build 56669: arc lint + arc unit

Event Timeline

des requested review of this revision.Oct 5 2024, 8:20 AM
des created this revision.

Just noticed the second half of the patch...

arrowd added inline comments.
devel/readline/files/patch-clang18
8

The rlstdc.h header contains this:

/* Moved from config.h.in because readline.h:rl_message depends on these
   defines. */
#if defined (__STDC__) && defined (HAVE_STDARG_H)
#  define PREFER_STDARG
#  define USE_VARARGS
#else
#  if defined (HAVE_VARARGS_H)
#    define PREFER_VARARGS
#    define USE_VARARGS
#  endif
#endif

So we should end with USE_VARARGS and PREFER_STDARG defined and this replacement shouldn't be needed.

Only if the translation unit that includes <readline/readline.h> also includes <stdarg.h>, which is required to define rl_message() since it uses va_start() etc but should not be required to merely call it.

Sorry, I misread HAVE_STDARG_H as STDARG_H_INCLUDED which would indicate that <stdarg.h> has been included. This is even worse: it requires the caller to use something like autoconf and to explicitly check for the existence of <stdarg.h> which, again, is not needed to simply use libreadline.

des marked an inline comment as done.Oct 6 2024, 9:01 AM

Oh, right, this is indeed silly from the readline side.

LGTM but I'd like to ask dim@ to take a look. Thanks.

For Function, VFunction etc this goes back to the old situation, where for C the prototypes do not say anything about their arguments, which would not really solve the issue with samba (as in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=281776). The problem there was that it didn't use rl_completion_func_t as it ought to have done.

I don't really like the #if defined(__GNUC__) || defined(__clang__) trick, but it is probably the easiest way to work around the detection of varargs support. In fact you could maybe make it unconditional, as I expect the number of people building FreeBSD with a compiler without varargs support to be zero. :)

This revision is now accepted and ready to land.Oct 9 2024, 11:46 AM
This revision was automatically updated to reflect the committed changes.

It's not trying to detect varargs support, it's trying to detect support for __attribute__((__format__)).