Skip to content

find_library broken for binutils >= 2.32 / 2.34 #84916

Description

@FRidh
mannequin
BPO 40739
Nosy @vsajip, @amauryfa, @abalkin, @meadori, @FRidh

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2020-05-23.07:41:27.686>
labels = ['type-bug', '3.8', '3.9', '3.10', 'ctypes', '3.7']
title = 'find_library broken for binutils >= 2.32 / 2.34'
updated_at = <Date 2020-05-24.08:50:11.618>
user = 'https://github.com/FRidh'

bugs.python.org fields:

activity = <Date 2020-05-24.08:50:11.618>
actor = 'SilentGhost'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['ctypes']
creation = <Date 2020-05-23.07:41:27.686>
creator = 'Frederik Rietdijk'
dependencies = []
files = []
hgrepos = []
issue_num = 40739
keywords = []
message_count = 2.0
messages = ['369699', '369701']
nosy_count = 5.0
nosy_names = ['vinay.sajip', 'amaury.forgeotdarc', 'belopolsky', 'meador.inge', 'Frederik Rietdijk']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue40739'
versions = ['Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10']

Activity

  1. FRidh commented on May 23, 2020

    FRidhmannequin
    MannequinAuthor

    With binutils 2.34 Python 3 (any version) the following returns None

    python3 -c 'import ctypes.util; print((ctypes.util.find_library("c")))'
    

    instead of the requested library which we think may be caused by https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=727a29badd95a68d08b86fec0b98702ce756c660
    which is included in binutils 2.32 and up.

    With binutils at 2.31 we got

    # recent unstable
    $ nix-shell --pure -p hello --run 'ld -t -o /dev/null -lc'
    /nix/store/a57856fs4m8ir6vlv14h3gq3sv9aq2lb-binutils-2.31.1/bin/ld: mode elf_x86_64
    /nix/store/nwsn18fysga1n5s0bj4jp4wfwvlbx8b1-glibc-2.30/lib/libc.so.6
    /nix/store/nwsn18fysga1n5s0bj4jp4wfwvlbx8b1-glibc-2.30/lib/ld-linux-x86-64.so.2
    /nix/store/nwsn18fysga1n5s0bj4jp4wfwvlbx8b1-glibc-2.30/lib/ld-linux-x86-64.so.2
    /nix/store/a57856fs4m8ir6vlv14h3gq3sv9aq2lb-binutils-2.31.1/bin/ld: warning: cannot find entry symbol _start; not setting start address

    however with 2.34 we get

    # current staging
    $ nix-shell --pure -p hello --run 'ld -t -o /dev/null -lc'
    /nix/store/j1l6ds4mhm97nqw965w9sg07i9fric4d-glibc-2.30/lib/libc.so
    /nix/store/j1l6ds4mhm97nqw965w9sg07i9fric4d-glibc-2.30/lib/libc.so.6
    /nix/store/j1l6ds4mhm97nqw965w9sg07i9fric4d-glibc-2.30/lib/libc_nonshared.a
    /nix/store/j1l6ds4mhm97nqw965w9sg07i9fric4d-glibc-2.30/lib/ld-linux-x86-64.so.2
    /nix/store/j1l6ds4mhm97nqw965w9sg07i9fric4d-glibc-2.30/lib/libc_nonshared.a
    /nix/store/j1l6ds4mhm97nqw965w9sg07i9fric4d-glibc-2.30/lib/ld-linux-x86-64.so.2
    /nix/store/j284mk8hdv9ccxfdlhcdk1lg2jml4fhk-binutils-2.34/bin/ld: warning: cannot find entry symbol _start; not setting start address

    The text-file libc.so is present which find_library cannot handle.

    I suppose the regex needs to be fixed to exclude these references or otherwise handle them. It may be a bit late for binutils to revert their change.

    Note this issue was discovered with the CFFI test suite https://foss.heptapod.net/pypy/cffi/blob/2aa5775ffdd6a911e9f40e3c2f5ba766155349c5/c/test_c.py#L60

    Nixpkgs issue: NixOS/nixpkgs#86954 (comment)

  2. FRidh commented on May 23, 2020

    FRidhmannequin
    MannequinAuthor

    I suppose this issue was not found yet because a) regression testing is done with ubuntu 18.04 LTS which uses binutils 2.30 and b) it, along with most distro's, will use ldconfig, which we in Nixpkgs have patched out.

  3. transferred this issue fromon Apr 10, 2022
  4. encukou commented on Feb 23, 2026

    @encukou
    Member

    I'm proposing to soft-deprecate ctypes.util.find_library: https://discuss.python.org/t/106232

  5. encukou commented on Mar 20, 2026

    @encukou
    Member

    It is now soft-deprecated. It cannot be made to work correctly and consistently on all platforms, and any change runs a chance to break whatever workarounds people already have in place.
    I'm prioritizing stability over new features, and encourage solving this outside ctypes itself.

    Also, find_library is now documented to depend on ldconfig and such.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions