msg95456 - (view) |
Author: François Mauger (mauger) |
Date: 2009-11-18 21:07 |
Hi Python!
I installed python2.6 from official source tarball under Scientific
Linux 5.2. I use the python2.6-config utility through makefiles to link
against lipython2.6.so. The installation prefix is NOT /usr nor some
standard /usr/local path.
The problem is that the python2.6-config --ldflags
does not print the linker -L<install shared library path>
so 'ld' failed with some "non found lipython2.6.so" error.
Is it a feature or a mistake in the
build/installation process of Python2.6 ?
Thanks a lot to give any useful hint.
Some details of my config follow:
>>>
bash-3.2$ cat /etc/redhat-release
Scientific Linux SL release 5.3 (Boron)
bash-3.2$ uname -a
Linux XXXXXX 2.6.18-164.6.1.el5 #1 SMP Tue Nov 3 23:02:51 EST 2009
x86_64 x86_64 x86_64 GNU/Linux
bash-3.2$ python -V
Python 2.6.4
bash-3.2$ python2.6-config --prefix
/some_path/sw/python/install_2.6.4_Linux-x86_64
bash-3.2$ ls -l /some_path/sw/python/install_2.6.4_Linux-x86_64/lib
total 5419
lrwxr-xr-x 1 mauger nemo 19 Nov 18 11:03 libpython2.6.so ->
libpython2.6.so.1.0
-r-xr-xr-x 1 mauger nemo 5524796 Nov 18 11:03 libpython2.6.so.1.0
drwxr-xr-x 25 mauger nemo 22528 Nov 18 11:04 python2.6
bash-3.2$ python2.6-config --cflags
-I/some_path/sw/python/install_2.6.4_Linux-x86_64/include/python2.6
-I/some_path/sw/python/install_2.6.4_Linux-x86_64/include/python2.6
-fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes
HERE I don't get the -L/some_path/sw/python/install_2.6.4_Linux-x86_64/lib:
bash-3.2$ python2.6-config --ldflags
-lpthread -ldl -lutil -lm -lpython2.6
<<<
|
msg109642 - (view) |
Author: Joel Brobecker (brobecke) |
Date: 2010-07-08 23:02 |
GDB can suffer from the same sort of problem. In my case, I picked up a Python binary tarball built on a different machine (without --enable-shared), and the path in -L<path> returned by python-config --ldflags refered to the prefix used at configure time. But, by comparison, --cflags returns the correct include path.
To give more context: GDB can be linked against libpython to add python scripting support in GDB. To determine how to compile&link Python in GDB, we have a copy of python-config in GDB, and do "python /path/to/python-config --cflags/ldflags.
Because it is often convenient to pick up a binary install, and because this install is not always at the same location as the prefix used at configure time, python-config --ldflags returns a -L<path> with a path that is irrelevant in our case.
The attached patch fixes this issue.
The patch also fixes the issue originally reported: I think that python-config --ldflags should also print -L<prefix>/lib in the case where python was configured with --enable-shared. This is necessary when prefix is not a standard location.
This was tested with Python 2.5, 2.6, and 2.7, static and shared, by calling the script with --ldflags, and by verifying the output.
|
msg113188 - (view) |
Author: Terry J. Reedy (terry.reedy) * |
Date: 2010-08-07 18:30 |
I am not sure that such a change to python-config.in could go into a bugfix release as it might need more testing on a variety of systems than bugfix releases tend to get. Does (in your opinion) 3.1/2 need the same change?
Martin, who should look at Linux build/install issues?
|
msg113191 - (view) |
Author: Joel Brobecker (brobecke) |
Date: 2010-08-07 19:11 |
I agree that more testing in head would be useful before possibly considering inclusion in one of the bug-fix releases. Given that this only affects binaries installed at a different location than the configure prefix, this seems hardly critical (and easy to fix locally).
|
msg114055 - (view) |
Author: Joel Brobecker (brobecke) |
Date: 2010-08-16 17:31 |
More update on this patch: It's incomplete, and possibly wrong, unfortunately. The issue that someone else noticed is that it does not handle the case when Python was configured with --libdir=...; and I think that the default lib dir on platforms such as Windows and Darwin might be different from the traditional <prefix>/lib as well, although I don't remember anymore (I did the investigation a couple of weeks ago).
I tried to find simple ways to update the script to make it work with a different libdir, but to no avail. :-(
I think that the best option is to enhance the sysconfig module to return the relocated lib path, but the problem is that the script would no longer work with older versions of Python (as older versions of Python would be missing that function). Perhaps one possible acceptable compromise is to call that function only when available and default to the old behavior otherwise. So it'd still be working as well as it does now with older versions of Python, while being slightly better with newer ones...
Just some thoughts...
|
msg237429 - (view) |
Author: Kubilay Kocak (koobs) |
Date: 2015-03-07 09:11 |
Still an issue on 2.7, 3.2, 3.3. Updating Versions to reflect this fact and assist downstreams in backporting a forthcoming fix to those versions that won't get it due to security-fix only branches.
See Also:
Issue: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197757
Patch: https://bz-attachments.freebsd.org/attachment.cgi?id=153794
|
msg237430 - (view) |
Author: Kubilay Kocak (koobs) |
Date: 2015-03-07 09:11 |
+nosy doko on ned_deily's advice
|
msg237474 - (view) |
Author: Matthias Klose (doko) * |
Date: 2015-03-07 20:07 |
this seems to work for me:
$ python-config --ldflags
-L/usr/lib/python2.7/config-x86_64-linux-gnu -L/usr/lib -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions
the patch is incomplete, no patch for the shell script is provided.
|
msg239951 - (view) |
Author: Kubilay Kocak (koobs) |
Date: 2015-04-03 01:58 |
@doko, as per the original report by Joel, the issue is:
* Reproducible with --enable-shared (most downstream OS's / packages use this)
Additionally:
* in the python script, not the shell script (by default used by < 3.4)
* Is reproducible in all branches (including default)
See the following test matrix from 'default'
========================================================================
./configure && make
========================================================================
LD_LIBRARY_PATH=. ./python python-config.py --ldflags
-L/usr/local/lib/python3.5/config-3.5m -lpython3.5m -lutil -lm -Wl,--export-dynamic
sh python-config --ldflags
-LNONE/lib/python3.5/config-3.5m -L/mnt/home/user/repos/lib -lpython3.5m -lutil -lm -Wl,--export-dynamic
^--- hmm .. "NONE" ... what?
========================================================================
./configure --prefix=/usr/local && make
========================================================================
LD_LIBRARY_PATH=. ./python python-config.py --ldflags
-L/usr/local/lib/python3.5/config-3.5m -lpython3.5m -lutil -lm -Wl,--export-dynamic
sh python-config --ldflags
-L/mnt/home/user/repos/lib/python3.5/config-3.5m -L/mnt/home/user/repos/lib -lpython3.5m -lutil -lm -Wl,--export-dynamic
========================================================================
./configure --enable-shared && make
========================================================================
LD_LIBRARY_PATH=. ./python python-config.py --ldflags
-lpython3.5m -lutil -lm -Wl,--export-dynamic
sh python-config --ldflags
-L/mnt/home/user/repos/lib -lpython3.5m -lutil -lm -Wl,--export-dynamic
========================================================================
./configure --enable-shared --prefix=/usr/local && make
========================================================================
LD_LIBRARY_PATH=. ./python python-config.py --ldflags
-lpython3.5m -lutil -lm -Wl,--export-dynamic
sh python-config --ldflags
-L/mnt/home/user/repos/lib -lpython3.5m -lutil -lm -Wl,--export-dynamic
While I'm here, update versions.
Note: This issue was originally reported for 2.7, 3.2, 3.3
|
msg252454 - (view) |
Author: Maxim Egorushkin (max0x7ba) |
Date: 2015-10-07 08:02 |
I encountered this issue when compiling gdb against my own build of Python 2.7 in a non-standard location. gdb could not locate libpython2.7.so.
The solution is to configure Python with LINKFORSHARED variable which contains additional linker flags required to link against libpython2.7.so. Here are the relevant bits (in Makefile syntax):
prefix := /opt/toolchain
python_version := 2.7.10
PREFIX := ${prefix}/python-${python_version}
CPPFLAGS := -fmessage-length=0
LINKFORSHARED := -L${PREFIX}/lib64 -Wl,-rpath=${PREFIX}/lib64
./configure --prefix=${PREFIX} --libdir=${PREFIX}/lib64 --enable-shared --enable-unicode=ucs4 CPPFLAGS="${cppflags}" LDFLAGS="${LDFLAGS}" LINKFORSHARED="${LINKFORSHARED}"
After Python is built and installed verify the flags:
$ /opt/toolchain/python-2.7.10/bin/python-config --ldflags
-lpython2.7 -lpthread -ldl -lutil -lm -L/opt/toolchain/python-2.7.10/lib64 -Wl,-rpath=/opt/toolchain/python-2.7.10/lib64
|
msg253146 - (view) |
Author: Kubilay Kocak (koobs) |
Date: 2015-10-18 07:19 |
The attached patch courtesy of Jan Beich @ FreeBSD minimally mimics (in the python version), the --ldflags output of the shell version of python-config(.sh).
The ideal scenario of course would be to use the shell script across all versions, as per revision c0370730b364 from #16235, so that two different versions of python-config no longer need to be maintained (as doko suggested in msg173710) and a whole bunch of now divergent code can be relegated to the depths.
@doko - can we please get this in for at least 2.7 and 3.4 please, downstreams can at least then manage backports themselves for 3.3 and below if necessary. This *is* a bug.
|
msg253147 - (view) |
Author: Kubilay Kocak (koobs) |
Date: 2015-10-18 07:34 |
To clarify, the bug remains in all branches including default, but only 3.4+ use the .sh script, leaving 3.3, 3.2, 2.7 using the python implementation.
|
|
Date |
User |
Action |
Args |
2022-04-11 14:56:54 | admin | set | github: 51601 |
2015-10-18 07:34:15 | koobs | set | messages:
+ msg253147 versions:
+ Python 3.6 |
2015-10-18 07:19:51 | koobs | set | files:
+ patch-issue7352.txt
messages:
+ msg253146 |
2015-10-07 08:02:52 | max0x7ba | set | nosy:
+ max0x7ba messages:
+ msg252454
|
2015-06-15 06:12:26 | Arfrever | set | nosy:
+ Arfrever
|
2015-06-15 05:49:13 | koobs | set | keywords:
+ needs review components:
+ Build |
2015-04-03 01:58:07 | koobs | set | messages:
+ msg239951 versions:
+ Python 3.4, Python 3.5, - Python 3.2, Python 3.3 |
2015-03-07 20:07:44 | doko | set | messages:
+ msg237474 |
2015-03-07 17:41:26 | terry.reedy | set | nosy:
- terry.reedy
|
2015-03-07 09:11:42 | koobs | set | nosy:
+ doko messages:
+ msg237430
|
2015-03-07 09:11:05 | koobs | set | nosy:
+ vstinner
messages:
+ msg237429 versions:
+ Python 2.7, Python 3.3 |
2015-03-07 08:38:49 | koobs | set | nosy:
+ koobs
|
2010-08-16 18:45:03 | terry.reedy | set | title: python2.6-config --ldflags out of /usr and missing -L<install_lib_dir> -> pythonx.y-config --ldflags out of /usr and missing -L<install_lib_dir> versions:
+ Python 3.2, - Python 2.7 |
2010-08-16 17:55:53 | eric.araujo | set | nosy:
+ tarek, eric.araujo
|
2010-08-16 17:31:48 | brobecke | set | messages:
+ msg114055 |
2010-08-07 19:11:47 | brobecke | set | messages:
+ msg113191 |
2010-08-07 18:30:12 | terry.reedy | set | nosy:
+ loewis, terry.reedy
messages:
+ msg113188 versions:
+ Python 2.7, - Python 2.6 |
2010-07-08 23:02:36 | brobecke | set | files:
+ python-config.diff
nosy:
+ brobecke messages:
+ msg109642
keywords:
+ patch |
2009-11-18 21:07:45 | mauger | set | messages:
+ msg95456 |
2009-11-18 20:58:57 | mauger | create | |