Bug 197757 - lang/python{27,32,33}: pythonX.Y-config --ldflags missing -L/usr/local/lib for shared library path
Summary: lang/python{27,32,33}: pythonX.Y-config --ldflags missing -L/usr/local/lib fo...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Kubilay Kocak
URL: http://bugs.python.org/issue7352
Keywords: patch
Depends on:
Blocks: 201342
  Show dependency treegraph
 
Reported: 2015-02-17 09:50 UTC by Antoine Brodin
Modified: 2015-10-19 17:14 UTC (History)
2 users (show)

See Also:
koobs: maintainer-feedback+
koobs: merge-quarterly+


Attachments
Mimic shell script (638 bytes, patch)
2015-03-04 17:58 UTC, Jan Beich
no flags Details | Diff
patch tested on python27 (2.50 KB, patch)
2015-05-05 13:11 UTC, Antoine Brodin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antoine Brodin freebsd_committer freebsd_triage 2015-02-17 09:50:57 UTC
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
Comment 1 Bugzilla Automation freebsd_committer freebsd_triage 2015-02-17 09:50:57 UTC
Auto-assigned to maintainer python@FreeBSD.org
Comment 2 Jan Beich freebsd_committer freebsd_triage 2015-03-04 17:58:46 UTC
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
Comment 3 Jan Beich freebsd_committer freebsd_triage 2015-03-04 18:11:34 UTC
(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
Comment 4 Kubilay Kocak freebsd_committer freebsd_triage 2015-03-07 09:01:21 UTC
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.
Comment 5 Antoine Brodin freebsd_committer freebsd_triage 2015-04-12 21:24:43 UTC
Hi python@ and Jan,

Do you plan to commit the proposed patch?
Comment 6 Kubilay Kocak freebsd_committer freebsd_triage 2015-04-14 09:02:24 UTC
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
Comment 7 Antoine Brodin freebsd_committer freebsd_triage 2015-05-05 13:11:31 UTC
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).
Comment 8 Kubilay Kocak freebsd_committer freebsd_triage 2015-10-18 07:22:08 UTC
Patch attached upstream (See URL) and merge requested
Comment 9 commit-hook freebsd_committer freebsd_triage 2015-10-18 09:50:55 UTC
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
Comment 10 Kubilay Kocak freebsd_committer freebsd_triage 2015-10-18 09:53:18 UTC
Thanks Antoine/Jan, sorry this took so long, some extra bits were needed for 3.2 and 3.3.

Waiting for approval on MFH.
Comment 11 commit-hook freebsd_committer freebsd_triage 2015-10-19 09:22:40 UTC
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
Comment 12 Jan Beich freebsd_committer freebsd_triage 2015-10-19 17:14:46 UTC
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.