-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Module/readline.c
has suspicious macro
#108588
Comments
If we care about support for old readline versions, then option 2 as the commit likely broke it. It looks like readline library has always defined |
cc @iritkatriel |
I made that commit to silence some warning. I don't have an opinion on this. |
I currently get a compiler warning for $ touch Modules/readline.c
$ make
gcc -fno-strict-overflow -g -Og -Wall -fprofile-instr-generate -fcoverage-mapping -Og -std=c11 -Werror=implicit-function-declaration -fvisibility=hidden -I/Users/erlend.aasland/src/cpython.git/Include/internal -IObjects -IInclude -IPython -I. -I/Users/erlend.aasland/src/cpython.git/Include -c /Users/erlend.aasland/src/cpython.git/Modules/readline.c -o Modules/readline.o
/Users/erlend.aasland/src/cpython.git/Modules/readline.c:1257:21: warning: incompatible function pointer types assigning to 'Function *' (aka 'int (*)(const char *, int)') from 'int (void)' [-Wincompatible-function-pointer-types]
rl_startup_hook = on_startup_hook;
^ ~~~~~~~~~~~~~~~
/Users/erlend.aasland/src/cpython.git/Modules/readline.c:1259:23: warning: incompatible function pointer types assigning to 'Function *' (aka 'int (*)(const char *, int)') from 'int (void)' [-Wincompatible-function-pointer-types]
rl_pre_input_hook = on_pre_input_hook;
^ ~~~~~~~~~~~~~~~~~
2 warnings generated.
gcc -bundle -undefined dynamic_lookup -fprofile-instr-generate -fcoverage-mapping Modules/readline.o -lreadline -o Modules/readline.cpython-313d-darwin.so
Checked 107 modules (31 built-in, 76 shared, 0 n/a on macosx-13.4-arm64, 0 disabled, 0 missing, 0 failed on import)
$ git revert a9305b5e80e414b8b9b2bd366e96b43add662d70
$ make
gcc -fno-strict-overflow -g -Og -Wall -fprofile-instr-generate -fcoverage-mapping -Og -std=c11 -Werror=implicit-function-declaration -fvisibility=hidden -I/Users/erlend.aasland/src/cpython.git/Include/internal -IObjects -IInclude -IPython -I. -I/Users/erlend.aasland/src/cpython.git/Include -c /Users/erlend.aasland/src/cpython.git/Modules/readline.c -o Modules/readline.o
gcc -bundle -undefined dynamic_lookup -fprofile-instr-generate -fcoverage-mapping Modules/readline.o -lreadline -o Modules/readline.cpython-313d-darwin.so
Checked 107 modules (31 built-in, 76 shared, 0 n/a on macosx-13.4-arm64, 0 disabled, 0 missing, 0 failed on import) |
@iritkatriel, do you get a compiler warning if you revert a9305b5? |
Go ahead and revert it. I don't remember the details of why I put it in. |
I do get a warning actually when I revert it:
|
This comment was marked as outdated.
This comment was marked as outdated.
Right, so we should try and find out the real fix, then. |
What's the output of |
@erlend-aasland no, I don't work on this issue, I don't have any knowledge about |
|
This issue is not related to whether we have to declare the params as void or not, it's just difference between explict declaration or not.
I am not sure, so it looks like, the right solution is detecting different signatures between different readline versions and compiling with conditional compilation as we discussed from #105323? no? |
Your issue is solved for me if I revert Irit's commit, so I do think they are related. |
@corona10, see #108588 (comment). |
If you are arguing that the issue is just about ignoring the compiler warning, you are right. |
All right, I leave it to you to consider if this issue, #105323, and #105240 are related :) I don't have the bandwidth for this. FTR, here's some info from my machine: $ echo '#include <editline/readline.h>' | gcc -E - | grep "typedef.*Function"
typedef int Function(const char *, int);
typedef void VFunction(void);
typedef void VCPFunction(char *);
typedef char *CPFunction(const char *, int);
typedef char **CPPFunction(const char *, int, int);
$ echo '#include <readline/readline.h>' | gcc -E - | grep "typedef.*Function"
typedef int Function(const char *, int);
typedef void VFunction(void);
typedef void VCPFunction(char *);
typedef char *CPFunction(const char *, int);
typedef char **CPPFunction(const char *, int, int); |
Patch is submitted for macOS: #108633 |
I don't have a lot of insight into this and I likely won't have time to look at it further for the next two weeks. But, AFAIK, there are at least three cases of interest that need to be covered: 1. linking the Python readline module with GNU readline; 2. linking with the latest BSD editline (libedit) module; and 3. linking with the version of BSD editline (libedit) that Apple ships with macOS. Note that editline provides an old GNU readline compatibility shim and that is what we link to when using any version of libedit, i.e. we do not support the native editline/libedit API. All three of those cases are being used today on macOS by various distributors so we should be sure they all work. The first two are used on other platforms and should also be tested. There may be other configurations of interest. |
I think we can close this now that #117870 has landed. |
Bug report
readline
has two identical function signatures under different macro branches:cpython/Modules/readline.c
Lines 1019 to 1024 in f75cefd
and
cpython/Modules/readline.c
Lines 1033 to 1039 in f75cefd
Looks like that they became identical after a9305b5
Original issue when this macro was introduced: #64573
But, new versions of
readline
do not ship_RL_FUNCTION_TYPEDEF
anymore: https://git.savannah.gnu.org/cgit/readline.git/tree/rltypedefs.h#n50So, what should we do?
#if defined
The text was updated successfully, but these errors were encountered: