>Number: 185071 >Category: misc >Synopsis: python3-config --ldflags returning bad values (no >-L/usr/local/lib) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Dec 21 16:50:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Ryan Lortie >Release: FreeBSD 10-RC1 >Organization: >Environment: FreeBSD beastie 10.0-RC1 FreeBSD 10.0-RC1 #0 r259068: Sat Dec 7 17:45:20 UTC 2013 r...@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64
>Description: python3-config is returning bad values with python33 installed via 'pkg'. [desrt@beastie ~]$ python3-config --ldflags -L/usr/local/lib/python3.3/config-3.3m -lintl -lutil -lm -lpython3.3m -Wl,--export-dynamic The problem is that there is no -L/usr/local/lib in here, which prevents shared linking against the -lpython3.3m found in /usr/local/lib. Instead, the linker will find only the static library in /usr/local/lib/python3.3/config-3.3m and try to use that instead. That will fail if trying to build another library, because the static library wasn't built with -fPIC. For comparison, note: [desrt@beastie ~]$ python2-config --ldflags -L/usr/local/lib/python2.7/config -L/usr/local/lib -pthread -lintl -lutil -lm -lpython2.7 -Wl,--export-dynamic Note also that the shared library is installed properly: [desrt@beastie ~]$ ls -l /usr/local/lib/libpython3* -r-xr-xr-x 1 root wheel 3736818 Dec 12 12:23 /usr/local/lib/libpython3.3m.a lrwxr-xr-x 1 root wheel 18 Dec 12 12:23 /usr/local/lib/libpython3.3m.so -> libpython3.3m.so.1 -r-xr-xr-x 1 root wheel 2251736 Dec 12 12:23 /usr/local/lib/libpython3.3m.so.1 >How-To-Repeat: Try to build a library that depends on python3. libpeas from GNOME is one such example. You will see this: [desrt@beastie /usr/home/desrt/jhbuild/checkout/libpeas/loaders/python3]$ gmake V=1 /bin/sh ../../libtool --tag=CC --mode=link cc -isystem /usr/local/include -module -avoid-version -L/usr/local/lib/python3.3/config-3.3m -lintl -lutil -lm -lpython3.3m -Wl,--export-dynamic -L/home/desrt/jhbuild/install/lib -Wl,-Y/usr/local/lib -o libpython3loader.la -rpath /home/desrt/jhbuild/install/lib/libpeas-1.0/loaders peas-plugin-loader-python.lo -Wl,--export-dynamic -lgmodule-2.0 -pthread -lgio-2.0 -lgirepository-1.0 -lgobject-2.0 -L/home/desrt/jhbuild/install/lib -lglib-2.0 -lintl -lgobject-2.0 -L/home/desrt/jhbuild/install/lib -lglib-2.0 -lintl -lintl -lutil -lm -lpython3.3m libtool: link: cc -shared -fPIC -DPIC .libs/peas-plugin-loader-python.o -L/usr/local/lib/python3.3/config-3.3m -L/home/desrt/jhbuild/install/lib -lgmodule-2.0 -lgio-2.0 -lgirepository-1.0 -lgobject-2.0 -lglib-2.0 -lintl -lutil -lm -lpython3.3m -Wl,--export-dynamic -Wl,-Y/usr/local/lib -Wl,--export-dynamic -pthread -pthread -Wl,-soname -Wl,libpython3loader.so -o .libs/libpython3loader.so /usr/bin/ld: /usr/local/lib/python3.3/config-3.3m/libpython3.3m.a(abstract.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/python3.3/config-3.3m/libpython3.3m.a: could not read symbols: Bad value cc: error: linker command failed with exit code 1 (use -v to see invocation) gmake: *** [libpython3loader.la] Error 1 >Fix: The python3-config script contains this code: elif opt in ('--libs', '--ldflags'): libs = getvar('LIBS').split() + getvar('SYSLIBS').split() libs.append('-lpython' + pyver + sys.abiflags) # add the prefix/lib/pythonX.Y/config dir, but only if there is no # shared library in prefix/lib/. if opt == '--ldflags': if not getvar('Py_ENABLE_SHARED'): libs.insert(0, '-L' + getvar('LIBPL')) if not getvar('PYTHONFRAMEWORK'): libs.extend(getvar('LINKFORSHARED').split()) print(' '.join(libs)) The values of various things, from my python3 install: >Release-Note: >Audit-Trail: >Unformatted: >>> getvar('Py_ENABLE_SHARED') 0 >>> getvar('PYTHONFRAMEWORK') '' >>> getvar('LIBPL') '/usr/local/lib/python3.3/config-3.3m' >>> getvar('LINKFORSHARED') '-Wl,--export-dynamic' >>> getvar('LIBS') '-lintl -lutil' >>> getvar('SYSLIBS') '-lm' >>> sys.abiflags 'm' >>> getvar('VERSION') '3.3' Note this line in python2-config: elif opt in ('--libs', '--ldflags'): libs = getvar("LDFLAGS").split() + getvar('LIBS').split() + getvar('SYSLIBS').split() ie: getvar("LDFLAGS") is here, while missing in python3. On my system python3: >>> getvar("LDFLAGS") '-L/usr/local/lib -pthread' So it seems that the fix is to make sure getvar("LDFLAGS") is in the python3-config version of this line... _______________________________________________ freebsd-bugs@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"