When built with NLS option turned off, -L/usr/local/lib is missing from pythonX.Y-config --ldflags: # python2.7-config --ldflags -lpython2.7 -lutil -lm -Wl,--export-dynamic # python3.2-config --ldflags -lutil -lm -lpython3.2mu -Wl,--export-dynamic # python3.3-config --ldflags -lutil -lm -lpython3.3m -Wl,--export-dynamic In version 3.4, python-config was rewritten and the problem seems fixed # python3.4-config --ldflags -L/usr/local/lib -lutil -lm -lpython3.4m -Wl,--export-dynamic
Auto-assigned to maintainer python@FreeBSD.org
Created attachment 153794 [details] Mimic shell script https://lists.freebsd.org/pipermail/freebsd-ports/2015-March/098241.html $ make WITH=PYTHON -C audio/alsa-lib [...] --- smixer-python.la --- CCLD smixer-python.la /usr/bin/ld: cannot find -lpython2.7 cc: error: linker command failed with exit code 1 (use -v to see invocation) *** [smixer-python.la] Error code 1 The patch is slightly from upstream version: - derive from exec_prefix like pkg-config or shell script - don't depend on LIBPL like shell script
(In reply to Antoine Brodin from comment #0) > In version 3.4, python-config was rewritten and the problem seems fixed More like the first sentence in issue16235 was a lie. -L$libdir wasn't present in the python script and *still* isn't. The fix just crept in without feedback from the folks in issue7352. http://bugs.python.org/issue16235
Liaising with upstream for expert advice on the most appropriate (root-cause) resolution. Ideally we can upstream a fix for this, using the existing patch as a reference without much effort.
Hi python@ and Jan, Do you plan to commit the proposed patch?
Jan, can you test the patch in issue 7352 [1] to confirm it works for you. Antoine, I have been following up the issue upstream and providing them with additional information [1] https://bugs.python.org/issue7352
Created attachment 156373 [details] patch tested on python27 Hello koobs, I confirm the patch from issue 7352 fixes the issue for me with python27 (patch against the ports tree attached).
Patch attached upstream (See URL) and merge requested
A commit references this bug: Author: koobs Date: Sun Oct 18 09:50:41 UTC 2015 New revision: 399611 URL: https://svnweb.freebsd.org/changeset/ports/399611 Log: lang/python{27,32,33}: Fix missing shlib path in python-config In Python 3.4+, upstream added and switched to using a shell implementation of the python-config script [1]. The Python implementation (python-config.py) remained used by all versions < 3.4. While the shell implementation returns the path to the Python shared library when using the --ldflags script argument, the Python implementation of the script does not. The bug has been reported, but has not yet been merged [2]. The Python ports currently default to including ${LOCALBASE}/lib in LIBS when the NLS option is enabled (which it is by default). When built *with* NLS (gettext) support, the flags added to LIBS are returned in `pythonX.Y-config --ldflags` output, which happens to match the path to the Python shared library. If the NLS option is disabled, ${LOCALBASE}/lib is not added to LIBS, and are therefore not returned in --ldflags output. This results in potential linking errors for software that uses python-config to obtain the correct library path, when the NLS option is disabled: $ make WITH=PYTHON -C audio/alsa-lib [...] --- smixer-python.la --- CCLD smixer-python.la /usr/bin/ld: cannot find -lpython2.7 This change modifies the python-config.in script to match the shell implementation, outputting the library path in --ldflags output. While I'm here: for Python 3.2 and Python 3.3 ports, backport a library order change [3]. This could affect linking with static libraries. Use standard length lines and reduce diffs in pkg-message [1] https://bugs.python.org/issue16235 [2] https://bugs.python.org/issue7352 [2] https://bugs.python.org/issue18096 PR: 197757 Submitted by: jbeich MFH: 2015Q4 Changes: head/lang/python27/Makefile head/lang/python27/files/patch-Misc_python-config.in head/lang/python27/pkg-message head/lang/python32/Makefile head/lang/python32/files/patch-Misc_python-config.in head/lang/python32/pkg-message head/lang/python33/Makefile head/lang/python33/files/patch-Misc_python-config.in head/lang/python33/pkg-message
Thanks Antoine/Jan, sorry this took so long, some extra bits were needed for 3.2 and 3.3. Waiting for approval on MFH.
A commit references this bug: Author: koobs Date: Mon Oct 19 09:22:31 UTC 2015 New revision: 399653 URL: https://svnweb.freebsd.org/changeset/ports/399653 Log: MFH: r399611 lang/python{27,32,33}: Fix missing shlib path in python-config In Python 3.4+, upstream added and switched to using a shell implementation of the python-config script [1]. The Python implementation (python-config.py) remained used by all versions < 3.4. While the shell implementation returns the path to the Python shared library when using the --ldflags script argument, the Python implementation of the script does not. The bug has been reported, but has not yet been merged [2]. The Python ports currently default to including ${LOCALBASE}/lib in LIBS when the NLS option is enabled (which it is by default). When built *with* NLS (gettext) support, the flags added to LIBS are returned in `pythonX.Y-config --ldflags` output, which happens to match the path to the Python shared library. If the NLS option is disabled, ${LOCALBASE}/lib is not added to LIBS, and are therefore not returned in --ldflags output. This results in potential linking errors for software that uses python-config to obtain the correct library path, when the NLS option is disabled: $ make WITH=PYTHON -C audio/alsa-lib [...] --- smixer-python.la --- CCLD smixer-python.la /usr/bin/ld: cannot find -lpython2.7 This change modifies the python-config.in script to match the shell implementation, outputting the library path in --ldflags output. While I'm here: for Python 3.2 and Python 3.3 ports, backport a library order change [3]. This could affect linking with static libraries. Use standard length lines and reduce diffs in pkg-message [1] https://bugs.python.org/issue16235 [2] https://bugs.python.org/issue7352 [2] https://bugs.python.org/issue18096 PR: 197757 Submitted by: jbeich Approved by: portmgr (erwin) Changes: _U branches/2015Q4/ branches/2015Q4/lang/python27/Makefile branches/2015Q4/lang/python27/files/patch-Misc_python-config.in branches/2015Q4/lang/python27/pkg-message branches/2015Q4/lang/python32/Makefile branches/2015Q4/lang/python32/files/patch-Misc_python-config.in branches/2015Q4/lang/python32/pkg-message branches/2015Q4/lang/python33/Makefile branches/2015Q4/lang/python33/files/patch-Misc_python-config.in branches/2015Q4/lang/python33/pkg-message
Sorry for lack of feedback to comment 6. I remember also testing upstream version that worked (probably attachment 156373 [details]) but run out of time reviewing it. As long as audio/alsa-lib + PYTHON=on reliably fails before ports r399611 with _non-ports compiler_ (see review V6) and works after there was no need to wait for me.