Threaded python on FreeBSD

Started by Jim C. Nasbyabout 19 years ago8 messages
#1Jim C. Nasby
jim@nasby.net

Currently, the FreeBSD ports make the following change when building
python:

--- src/pl/plpython/Makefile.orig       Fri Nov 19 20:23:01 2004
+++ src/pl/plpython/Makefile    Tue Dec 28 23:32:16 2004
@@ -9,7 +9,7 @@
 # shared library.  Since there is no official way to determine this
 # (at least not in pre-2.3 Python), we see if there is a file that is
 # named like a shared library.
-ifneq (,$(wildcard $(python_libdir)/libpython*$(DLSUFFIX)*))
+ifneq (,$(wildcard $(python_libdir)/../../libpython*$(DLSUFFIX)*))
 shared_libpython = yes
 endif

If that's not in-place, plpython won't build if the python that's
installed is multi-threaded:

http://pgbuildfarm.org/cgi-bin/show_log.pl?nm=tapir&dt=2006-10-14%2017:32:41

I'm turning off threading in my python for now, but ISTM it'd be good to
allow for building plpython from source. (This is python2.5 and FreeBSD 6.1). I
looked around the config files but didn't see a clean way to handle this (and
maybe the issue is actually with autoconf...)
--
Jim Nasby jim@nasby.net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Jim C. Nasby (#1)
Re: Threaded python on FreeBSD

Jim C. Nasby wrote:

Currently, the FreeBSD ports make the following change when building
python:

--- src/pl/plpython/Makefile.orig       Fri Nov 19 20:23:01 2004
+++ src/pl/plpython/Makefile    Tue Dec 28 23:32:16 2004
@@ -9,7 +9,7 @@
# shared library.  Since there is no official way to determine this
# (at least not in pre-2.3 Python), we see if there is a file that
is # named like a shared library.
-ifneq (,$(wildcard $(python_libdir)/libpython*$(DLSUFFIX)*))
+ifneq (,$(wildcard $(python_libdir)/../../libpython*$(DLSUFFIX)*))
shared_libpython = yes
endif

Since python_libdir is /usr/local/lib on this platform, this would look
for libpython in /usr, which makes no sense.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#3Jim C. Nasby
jim@nasby.net
In reply to: Peter Eisentraut (#2)
Re: Threaded python on FreeBSD

On Sun, Oct 15, 2006 at 10:39:49PM +0200, Peter Eisentraut wrote:

Jim C. Nasby wrote:

Currently, the FreeBSD ports make the following change when building
python:

--- src/pl/plpython/Makefile.orig       Fri Nov 19 20:23:01 2004
+++ src/pl/plpython/Makefile    Tue Dec 28 23:32:16 2004
@@ -9,7 +9,7 @@
# shared library.  Since there is no official way to determine this
# (at least not in pre-2.3 Python), we see if there is a file that
is # named like a shared library.
-ifneq (,$(wildcard $(python_libdir)/libpython*$(DLSUFFIX)*))
+ifneq (,$(wildcard $(python_libdir)/../../libpython*$(DLSUFFIX)*))
shared_libpython = yes
endif

Since python_libdir is /usr/local/lib on this platform, this would look
for libpython in /usr, which makes no sense.

Take a look at the failure output...

ERROR: could not load library
"/home/buildfarm/buildfarm/HEAD/inst/lib/postgresql/plpython.so": dlopen
(/home/buildfarm/buildfarm/HEAD/inst/lib/postgresql/plpython.so) failed:
/usr/local/lib/python2.5/config/libpython2.5.so: Undefined symbol
"pthread_attr_destroy"

For some reason, it's thinking that the lib directory is
/usr/local/lib/python2.5/config (there's a symlink of libpython2.5.so in
there). Looking at the python port, I don't see anything that indicates
this is a FreeBSD-ism, either...
--
Jim Nasby jim@nasby.net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jim C. Nasby (#3)
Re: Threaded python on FreeBSD

"Jim C. Nasby" <jim@nasby.net> writes:

Take a look at the failure output...

ERROR: could not load library
"/home/buildfarm/buildfarm/HEAD/inst/lib/postgresql/plpython.so": dlopen
(/home/buildfarm/buildfarm/HEAD/inst/lib/postgresql/plpython.so) failed:
/usr/local/lib/python2.5/config/libpython2.5.so: Undefined symbol
"pthread_attr_destroy"

I suspect the problem here is that the backend isn't linked with
-lpthread. We aren't going to let libpython dictate whether we do so,
either...

regards, tom lane

#5Jim C. Nasby
jim@nasby.net
In reply to: Tom Lane (#4)
Re: Threaded python on FreeBSD

On Sun, Oct 15, 2006 at 06:19:12PM -0400, Tom Lane wrote:

"Jim C. Nasby" <jim@nasby.net> writes:

Take a look at the failure output...

ERROR: could not load library
"/home/buildfarm/buildfarm/HEAD/inst/lib/postgresql/plpython.so": dlopen
(/home/buildfarm/buildfarm/HEAD/inst/lib/postgresql/plpython.so) failed:
/usr/local/lib/python2.5/config/libpython2.5.so: Undefined symbol
"pthread_attr_destroy"

I suspect the problem here is that the backend isn't linked with
-lpthread. We aren't going to let libpython dictate whether we do so,
either...

Isn't that what --enable-thread-safety does? I know I've made at least
one test with that enabled (though it may not be the failure I linked
up-thread).
--
Jim Nasby jim@nasby.net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

#6Bruce Momjian
bruce@momjian.us
In reply to: Jim C. Nasby (#5)
Re: Threaded python on FreeBSD

Jim C. Nasby wrote:

On Sun, Oct 15, 2006 at 06:19:12PM -0400, Tom Lane wrote:

"Jim C. Nasby" <jim@nasby.net> writes:

Take a look at the failure output...

ERROR: could not load library
"/home/buildfarm/buildfarm/HEAD/inst/lib/postgresql/plpython.so": dlopen
(/home/buildfarm/buildfarm/HEAD/inst/lib/postgresql/plpython.so) failed:
/usr/local/lib/python2.5/config/libpython2.5.so: Undefined symbol
"pthread_attr_destroy"

I suspect the problem here is that the backend isn't linked with
-lpthread. We aren't going to let libpython dictate whether we do so,
either...

Isn't that what --enable-thread-safety does? I know I've made at least
one test with that enabled (though it may not be the failure I linked
up-thread).

--enable-thread-safety doesn't add threading to the backend, only libpq
and ecpg.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#7Marko Kreen
markokr@gmail.com
In reply to: Bruce Momjian (#6)
1 attachment(s)
Re: Threaded python on FreeBSD

On 10/16/06, Bruce Momjian <bruce@momjian.us> wrote:

Jim C. Nasby wrote:

On Sun, Oct 15, 2006 at 06:19:12PM -0400, Tom Lane wrote:

I suspect the problem here is that the backend isn't linked with
-lpthread. We aren't going to let libpython dictate whether we do so,
either...

Fix config test to report this earlier.

--
marko

Attachments:

pybsd.diffapplication/octet-stream; name=pybsd.diffDownload
Index: config/python.m4
===================================================================
RCS file: /projects/cvsroot/pgsql/config/python.m4,v
retrieving revision 1.13
diff -u -c -r1.13 python.m4
*** config/python.m4	13 Oct 2005 20:40:04 -0000	1.13
--- config/python.m4	16 Oct 2006 13:27:16 -0000
***************
*** 84,90 ****
  if test "$pythreads" = "1"; then
    AC_MSG_RESULT(yes)
    case $host_os in
!   openbsd*|freebsd4*)
      AC_MSG_ERROR([*** Threaded Python not supported on this platform ***])
      ;;
    esac
--- 84,90 ----
  if test "$pythreads" = "1"; then
    AC_MSG_RESULT(yes)
    case $host_os in
!   openbsd*|freebsd*)
      AC_MSG_ERROR([*** Threaded Python not supported on this platform ***])
      ;;
    esac
#8Peter Eisentraut
peter_e@gmx.net
In reply to: Marko Kreen (#7)
Re: Threaded python on FreeBSD

Marko Kreen wrote:

On 10/16/06, Bruce Momjian <bruce@momjian.us> wrote:

Jim C. Nasby wrote:

On Sun, Oct 15, 2006 at 06:19:12PM -0400, Tom Lane wrote:

I suspect the problem here is that the backend isn't linked
with -lpthread. We aren't going to let libpython dictate
whether we do so, either...

Fix config test to report this earlier.

Fixed.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/