Graphviz Issue Tracker
Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0002486graphvizBuild/Installpublic2014-09-09 18:322014-09-10 15:56
Assigned Toellson 
PlatformdarwinOSOS XOS Version10.9
Summary0002486: graphviz always links against system python
DescriptionWhen building the python bindings against e.g. python 2.7, -lpython2.7 is added to the linker command line but the linker's default search path is not modified. When users try to build against Homebrew's python, Homebrew's libpython2.7 is not in the default linker search path so it is not found and the module is linked against the system python framework instead, which causes a segfault on "import gv" from the Homebrew python.

This can be resolved a few different ways, probably in ascending order of correctness:
1. add -L$PYTHON_PREFIX/lib to the linker path
2. discover python build flags with e.g. python2.7-config --ldflags
3. link modules with -undefined dynamic_lookup so that Python symbols are resolved at import time and not at link time, which has the pleasant effect that modules built for one interpreter can be used with another without segfaults

I've provided a patch for option 1.
Steps To Reproduce1. Install Python from, Homebrew, Enthought, or some other vendor so that "python" invokes the new non-system python interpreter.
2. Install graphviz from source.
3. Run python -c "import gv" and observe that the interpreter segfaults.
Additional InformationOriginally reported to Homebrew as [^]
TagsNo tags attached.
FIX-COMMENTchanged to use suggested: "-undefined dynamic_lookup"
Attached Filespatch file icon 0001-explicitly-add-Python-lib-dir-to-linker-search-path.patch (Attachment missing)

- Relationships

-  Notes
User avatar (0000810)
tdsmith (reporter)
2014-09-09 18:43

To clarify, for option 3, "-undefined dynamic_lookup" replaces e.g. "-lpython2.7" since the interpreter provides the symbols at runtime.
User avatar (0000811)
ellson (administrator)
2014-09-10 10:12

I haven't tried this, but you should be able to use ./configure --with-extralibdir=<path_to_your_python's_libs>

My preference is to use pkg-config, but python didn't support that for a long time (still doesn't on RHEL5 or 6).

I'll work on converting to use pkg-config for python (with some fall back). So, when this is done, if you want to use a different python it will be your reponsibility to ensure that your python.pc is first in PKG_CONFIG_PATH.
User avatar (0000812)
tdsmith (reporter)
2014-09-10 13:18

Just as a note, neither OS X system Python or Homebrew Python installs .pc files in a global path so pkg-config will typically fail to find python on OS X; the system .pc files are in /System/Library/Frameworks/Python.framework/Versions/Current/lib/pkgconfig.

Homebrew promises that bindings will be built against the first Python in PATH (which may not be Homebrew python, even if it's installed), so it would be convenient for Homebrew if the fallback behavior helped us meet that promise. :)
User avatar (0000813)
ellson (administrator)
2014-09-10 14:56

Just tried "-undefined dynamic_lookup" on fedora-20, seems to work great. I assume it says "expect the undefined symbols to be already loaded into memory" ?

Perhaps I should be using this for all the language extensions...

Still testing that it works on antiquated systems like RHEL5.

I was going to try adding: -L$PYTHON_PREFIX/lib$LIBPOSTFIX
but I've no way of knowing if $LIBPOSTFIX is needed.
User avatar (0000814)
ellson (administrator)
2014-09-10 15:52

OK, I'm good with "-undefined dynamic_lookup"

Its in GIT now, and should be in all our builds tomorrow.

- Issue History
Date Modified Username Field Change
2014-09-09 18:32 tdsmith New Issue
2014-09-09 18:32 tdsmith File Added: 0001-explicitly-add-Python-lib-dir-to-linker-search-path.patch
2014-09-09 18:43 tdsmith Note Added: 0000810
2014-09-10 10:12 ellson Note Added: 0000811
2014-09-10 13:18 tdsmith Note Added: 0000812
2014-09-10 14:56 ellson Note Added: 0000813
2014-09-10 15:52 ellson Note Added: 0000814
2014-09-10 15:56 ellson FIX-COMMENT => changed to use suggested: "-undefined dynamic_lookup"
2014-09-10 15:56 ellson Status new => resolved
2014-09-10 15:56 ellson Resolution open => fixed
2014-09-10 15:56 ellson Assigned To => ellson

MantisBT 1.2.5[^]
Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker