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
readline module fails to build against recent libedit #117845
Building Python 3.13.0a6 configured with --with-readline=editline fails like this for me:
./Modules/readline.c:1305:21: error: incompatible function pointer types assigning to 'rl_hook_func_t *' (aka 'int (*)(void)') from 'int (const char *, int)' [-Wincompatible-function-pointer-types]
rl_startup_hook = on_startup_hook;^~~~~~~~~~~~~~~~
./Modules/readline.c:1307:23: error: incompatible function pointer types assigning to 'rl_hook_func_t *' (aka 'int (*)(void)') from 'int (const char *, int)' [-Wincompatible-function-pointer-types]
rl_pre_input_hook = on_pre_input_hook;^~~~~~~~~~~~~~~~~~
2 errors generated.
It looks like e7e1116 is the cause. No editline header defines _RL_FUNCTION_TYPEDEF, but recent versions (in this case 20230828) declare these functions as taking void whereas Apple's version declares them the other way. I suspect that older clang versions and gcc may let you off with a warning rather than erroring on this type mismatch.
The upstream libedit "fixed" the function declaration in 1.53, which kind of creates a disaster for us. The apple version branched before that and arguably the most common libedit we will have. Linux user (or maybe Mac user that builds their own libedit) potentially could use any version.
I can't think of anything to distinguish between the versions, and I think there are multiple version mechanics out in the market (ubuntu seems to use the version 3.1 + date?). I don't know any C tricks to make this work because that's a different typedef, not MACRO.
I can think of a couple non-ideal solutions:
Let it be.
Ask user to pass -D_RL_FUNCTION_TYPEDEF under such case.
Use two different configuration names for libedit with two different callback signatures.
I don't think tricking compiler works in this case as the input argument number is different.
I can't think of anything to distinguish between the versions, and I think there are multiple version mechanics out in the market (ubuntu seems to use the version 3.1 + date?). I don't know any C tricks to make this work because that's a different typedef, not MACRO.
I think it would need to be an autoconf check, albeit a little more sophisticated than the one that was removed. You could check if a C function that calls function pointers of the appropriate types will compile when using the different numbers of args.
I'm not an expert on autoconf so I don't know if this kind of check is feasible or common for autoconf. @corona10 worked on the original option I believe and he might have a better idea of it.
Activity
gaogaotiantian commentedon Apr 13, 2024
The upstream libedit "fixed" the function declaration in 1.53, which kind of creates a disaster for us. The apple version branched before that and arguably the most common libedit we will have. Linux user (or maybe Mac user that builds their own libedit) potentially could use any version.
I can't think of anything to distinguish between the versions, and I think there are multiple version mechanics out in the market (ubuntu seems to use the version 3.1 + date?). I don't know any C tricks to make this work because that's a different typedef, not MACRO.
I can think of a couple non-ideal solutions:
-D_RL_FUNCTION_TYPEDEFunder such case.I don't think tricking compiler works in this case as the input argument number is different.
jmroot commentedon Apr 14, 2024
I think it would need to be an autoconf check, albeit a little more sophisticated than the one that was removed. You could check if a C function that calls function pointers of the appropriate types will compile when using the different numbers of args.
gaogaotiantian commentedon Apr 14, 2024
I'm not an expert on autoconf so I don't know if this kind of check is feasible or common for autoconf. @corona10 worked on the original option I believe and he might have a better idea of it.
pythongh-117845: Fix type mismatch for hook functions with libedit
erlend-aasland commentedon Apr 15, 2024
See also:
Module/readline.chas suspicious macro #108588gh-117845: Detect libedit hook function signature in configure (#117870)
erlend-aasland commentedon Apr 17, 2024
Resolved by:
pythongh-117845: Detect libedit hook function signature in configure (p…