Skip to content

readline module fails to build against recent libedit #117845

Closed

Description

@jmroot

Bug report

Bug description:

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.

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Apr 13, 2024
  2. added
    3.13only security fixes
    buildThe build process and cross-build
    on Apr 13, 2024
  3. gaogaotiantian commented on Apr 13, 2024

    @gaogaotiantian
    Member

    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:

    1. Let it be.
    2. Ask user to pass -D_RL_FUNCTION_TYPEDEF under such case.
    3. 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.

  4. jmroot commented on Apr 14, 2024

    @jmroot
    ContributorAuthor

    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.

  5. gaogaotiantian commented on Apr 14, 2024

    @gaogaotiantian
    Member

    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.

  6. added a commit that references this issue on Apr 14, 2024
  7. added a commit that references this issue on Apr 17, 2024
  8. erlend-aasland commented on Apr 17, 2024

    @erlend-aasland
    Contributor
  9. added a commit that references this issue on Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixesbuildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions