Skip to content
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

ctypes.util.find_library does not work under Solaris #49539

Closed
kewang mannequin opened this issue Feb 17, 2009 · 7 comments
Closed

ctypes.util.find_library does not work under Solaris #49539

kewang mannequin opened this issue Feb 17, 2009 · 7 comments
Assignees
Labels
topic-ctypes type-bug An unexpected behavior, bug, or error

Comments

@kewang
Copy link
Mannequin

kewang mannequin commented Feb 17, 2009

BPO 5289
Nosy @smontanaro, @theller, @tpn
Files
  • util.diff
  • util.diff: Fixed the TabError
  • 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 = 'https://github.com/theller'
    closed_at = <Date 2013-02-04.00:27:26.886>
    created_at = <Date 2009-02-17.08:17:14.364>
    labels = ['ctypes', 'type-bug']
    title = 'ctypes.util.find_library does not work under Solaris'
    updated_at = <Date 2013-02-04.00:27:26.884>
    user = 'https://bugs.python.org/kewang'

    bugs.python.org fields:

    activity = <Date 2013-02-04.00:27:26.884>
    actor = 'python-dev'
    assignee = 'theller'
    closed = True
    closed_date = <Date 2013-02-04.00:27:26.886>
    closer = 'python-dev'
    components = ['ctypes']
    creation = <Date 2009-02-17.08:17:14.364>
    creator = 'kewang'
    dependencies = []
    files = ['13129', '13133']
    hgrepos = []
    issue_num = 5289
    keywords = ['patch']
    message_count = 7.0
    messages = ['82303', '82317', '82412', '82449', '146076', '180725', '181305']
    nosy_count = 9.0
    nosy_names = ['skip.montanaro', 'theller', 'trent', 'laca', 'kewang', 'automatthias', 'python-dev', 'aliles', 'FalkNisius']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue5289'
    versions = ['Python 2.7']

    @kewang
    Copy link
    Mannequin Author

    kewang mannequin commented Feb 17, 2009

    Under Solaris, find_library can not give the correct path.
    Solaris does not have /sbin/ldconfig, so _findLib_gcc is used.

    def _findLib_gcc(name):
            expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)
            fdout, ccout = tempfile.mkstemp()
            os.close(fdout)
            cmd = 'if type gcc >/dev/null 2>&1; then CC=gcc; else CC=cc; fi;' \
                  '$CC -Wl,-t -o ' + ccout + ' 2>&1 -l' + name
            try:
                f = os.popen(cmd)
                trace = f.read()
                f.close()
            finally:
                try:
                    os.unlink(ccout)
                except OSError, e:
                    if e.errno != errno.ENOENT:
                        raise
            res = re.search(expr, trace)
            if not res:
                return None
            return res.group(0)

    I executed these code manually, and after ‘trace = f.read()‘, I printed
    the content of 'trace', which was just as following:

    Undefined first referenced
    symbol in file
    main /usr/lib/crt1.o
    ld: fatal: symbol referencing errors. No output written to /tmp/tmpYN85Fm
    collect2: ld returned 1 exit status

    @kewang kewang mannequin assigned theller Feb 17, 2009
    @kewang kewang mannequin added topic-ctypes type-bug An unexpected behavior, bug, or error labels Feb 17, 2009
    @kewang
    Copy link
    Mannequin Author

    kewang mannequin commented Feb 17, 2009

    I tested the command 'gcc -Wl,-t' on Ubuntu, it works fine.
    But on Solaris, it doesn't work as expected.

    Finally I find that gcc does not use GNU ld on Solaris, instead, it uses
    SUN ld.

    @kewang
    Copy link
    Mannequin Author

    kewang mannequin commented Feb 18, 2009

    On Solaris, we can use crle to find system library path.

    Attached a patch to get find_library work with Solaris.

    @kewang
    Copy link
    Mannequin Author

    kewang mannequin commented Feb 19, 2009

    Above patch failed in a TabError.
    Attached a new one.

    @FalkNisius
    Copy link
    Mannequin

    FalkNisius mannequin commented Oct 21, 2011

    Under Ubuntu 11.04 is the _findLib_gcc used and not a ldconfig method.

    Why should I install a gcc only to find a dynamic library ? It seems not a well design. The usage of ldconfig, what is more natural at a server in the net than a c compiler. Perhaps it can be changed in the next version, because I can see that on other os th ldconfig method would be preferred.

    I'm not an python programmer and have not the possibilities to make a regeression test, thats why I can not help.

    @smontanaro
    Copy link
    Contributor

    Is there still time to get this bug fixed in 2.7.3? I patched my 2.7 ctypes/util.py with the latest version (offset a few lines, but no other problems) and verified that it seems to fix the issue. When running util.py as a main program I see this before running patch:

    % python /opt/TWWfsw/python27/lib/python2.7/ctypes/util.py
    None
    None
    None
    <CDLL 'libm.so', handle fed807b8 at 82c320c>
    <CDLL 'libcrypt.so', handle feb703a8 at 82c320c>
    None

    After applying the patch:
    % python /opt/TWWfsw/python27/lib/python2.7/ctypes/util.py
    libm.so.2
    libc.so.1
    libbz2.so.1
    <CDLL 'libm.so', handle fed807b8 at 82c296c>
    <CDLL 'libcrypt.so', handle feb703a8 at 82c296c>
    libcrypt_d.so.1

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Feb 4, 2013

    New changeset d76fb24d79c3 by Benjamin Peterson in branch '2.7':
    fix find_library on Solaris (closes bpo-5289)
    http://hg.python.org/cpython/rev/d76fb24d79c3

    New changeset 73574de2068b by Benjamin Peterson in branch '3.3':
    fix find_library on Solaris (closes bpo-5289)
    http://hg.python.org/cpython/rev/73574de2068b

    New changeset 640a80adb9df by Benjamin Peterson in branch 'default':
    merge 3.3 (bpo-5289)
    http://hg.python.org/cpython/rev/640a80adb9df

    @python-dev python-dev mannequin closed this as completed Feb 4, 2013
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-ctypes type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants