Thread: [Postgresql alpha3] Configure fails with --libxml on OpenBSD

[Postgresql alpha3] Configure fails with --libxml on OpenBSD

From
postgresql@raveland.org
Date:
Hi,

I'm testing postgresql 8.5 alpha3 on OpenBSD (-current , amd64 and macppc).
The port uses the option --libxml.

With this option, I have the following error:

[...]
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... no
checking whether pthreads work with -pthreads... no
checking whether pthreads work with -mthreads... no
checking for the pthreads library -lpthread... no
checking whether pthreads work with --thread-safe... no
checking whether pthreads work with -mt... no
checking for pthread-config... no
checking for the pthreads library -lpthreadGC2... no
checking for pthread.h... (cached) yes
checking for strerror_r... (cached) yes
[...]
checking thread safety of required library functions... no
configure: error: thread test program failed
This platform is not thread-safe.  Check the file 'config.log' or compile
and run src/test/thread/thread_test for the exact reason.
Use --disable-thread-safety to disable thread safety.



*OpenBSD must use -pthread.*

The config.log shows me these lines:

configure:20889: checking whether pthreads work with -pthread
configure:20984: cc -o conftest -O2 -pipe -Wall -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels
-fno-strict-aliasing -pthread  -I/usr/local/include/libxml2 -I/usr/local/include  -I/usr/local/include
-I/usr/include/kerberosV -L/usr/local/lib -L/usr/local/lib  -L/usr/local/lib conftest.c   -lxml2 -lssl -lcrypto
-lcom_err-lssl -lcrypto -lz -lreadline -ltermcap -lm  >&5 
conftest.c: In function `main':
conftest.c:154: warning: `th' might be used uninitialized in this function
/usr/local/lib/libxml2.so.11.0: warning: strcpy() is almost always misused, please use strlcpy()
/usr/local/lib/libxml2.so.11.0: warning: strcat() is almost always misused, please use strlcat()
configure:20991: $? = 0
configure:21037: result: no
[...]
configure:20941: checking for the pthreads library -lpthread
configure:20984: cc -o conftest -O2 -pipe -Wall -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels
-fno-strict-aliasing   -I/usr/local/include/libxml2 -I/usr/local/include  -I/usr/local/include -I/usr/include/kerberosV
-L/usr/local/lib -L/usr/local/lib  -L/usr/local/lib conftest.c -lpthread  -lxml2 -lssl -lcrypto -lcom_err -lssl
-lcrypto-lz -lreadline -ltermcap -lm  >&5 
conftest.c: In function `main':
conftest.c:154: warning: `th' might be used uninitialized in this function
/usr/local/lib/libxml2.so.11.0: warning: strcpy() is almost always misused, please use strlcpy()
/usr/local/lib/libxml2.so.11.0: warning: strcat() is almost always misused, please use strlcat()
configure:20991: $? = 0
configure:21037: result: no
[..]
configure:28181: checking thread safety of required library functions
configure:28214: cc -o conftest -O2 -pipe -Wall -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels
-fno-strict-aliasing -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -DIN_CONFIGURE
-I/usr/local/include/libxml2-I/usr/local/include  -I/usr/local/include -I/usr/include/kerberosV  -L/usr/local/lib
-L/usr/local/lib -L/usr/local/lib conftest.c -lxml2 -lssl -lcrypto -lcom_err -lssl -lcrypto -lz -lreadline -ltermcap
-lm  >&5 
/tmp//ccZIUQ7g.o(.text+0x56): In function `main':
: warning: strcpy() is almost always misused, please use strlcpy()
/usr/local/lib/libxml2.so.11.0: warning: strcat() is almost always misused, please use strlcat()
/tmp//ccZIUQ7g.o(.text+0xa4): In function `main':
: undefined reference to `pthread_mutex_lock'
/tmp//ccZIUQ7g.o(.text+0xb7): In function `main':
: undefined reference to `pthread_create'
/tmp//ccZIUQ7g.o(.text+0xca): In function `main':
: undefined reference to `pthread_create'
/tmp//ccZIUQ7g.o(.text+0x10b): In function `main':
: undefined reference to `pthread_mutex_unlock'
/tmp//ccZIUQ7g.o(.text+0x117): In function `main':
: undefined reference to `pthread_join'
/tmp//ccZIUQ7g.o(.text+0x123): In function `main':
: undefined reference to `pthread_join'
/tmp//ccZIUQ7g.o(.text+0x232): In function `func_call_1':
: undefined reference to `pthread_mutex_lock'
/tmp//ccZIUQ7g.o(.text+0x2e7): In function `func_call_2':
: undefined reference to `pthread_mutex_lock'
/tmp//ccZIUQ7g.o(.text+0x240): In function `func_call_1':
: undefined reference to `pthread_mutex_unlock'
/tmp//ccZIUQ7g.o(.text+0x2f5): In function `func_call_2':
: undefined reference to `pthread_mutex_unlock'
collect2: ld returned 1 exit status
configure:28218: $? = 1
configure: program exited with status 1




When I remove the option --libxml in the port, everything is ok.

checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... yes
checking whether pthreads work with -pthreads... no
checking whether pthreads work with -mthreads... no
checking for the pthreads library -lpthread... yes
checking whether pthreads work with --thread-safe... no
checking whether pthreads work with -mt... no
checking for the pthreads library -lpthreadGC2... no
checking for pthread.h... (cached) yes
checking for strerror_r... (cached) yes

Please note that both -pthread and -lpthread are on yes now.

And the config.log:

configure:20889: checking whether pthreads work with -pthread
configure:20984: cc -o conftest -O2 -pipe -Wall -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels
-fno-strict-aliasing -pthread   -I/usr/local/include -I/usr/include/kerberosV   -L/usr/local/lib conftest.c   -lssl
-lcrypto-lcom_err -lssl -lcrypto -lz -lreadline -ltermcap -lm  >&5 
conftest.c: In function `main':
conftest.c:152: warning: `th' might be used uninitialized in this function
configure:20991: $? = 0
configure:21037: result: yes
[...]
configure:20941: checking for the pthreads library -lpthread
configure:20984: cc -o conftest -O2 -pipe -Wall -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels
-fno-strict-aliasing -pthread    -I/usr/local/include -I/usr/include/kerberosV   -L/usr/local/lib conftest.c -lpthread
 -lssl -lcrypto -lcom_err -lssl -lcrypto -lz -lreadline -ltermcap -lm  >&5 
conftest.c: In function `main':
conftest.c:152: warning: `th' might be used uninitialized in this function
configure:20991: $? = 0
configure:21037: result: yes
[...]
configure:28181: checking thread safety of required library functions
configure:28214: cc -o conftest -O2 -pipe -Wall -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels
-fno-strict-aliasing -pthread  -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -DIN_CONFIGURE
-I/usr/local/include-I/usr/include/kerberosV   -L/usr/local/lib conftest.c -lssl -lcrypto -lcom_err -lssl -lcrypto -lz
-lreadline-ltermcap -lm   -lpthread    >&5 
/tmp//ccAUpoIA.o(.text+0x56): In function `main':
: warning: strcpy() is almost always misused, please use strlcpy()
configure:28218: $? = 0
configure:28224: ./conftest
Your errno is thread-safe.
Your system has sterror_r();  it does not need strerror().
Your system has getpwuid_r();  it does not need getpwuid().
Your system has getaddrinfo();  it does not need gethostbyname()
  or gethostbyname_r().

Your platform is thread-safe.
configure:28228: $? = 0
configure:28230: result: yes


I don't understand why the detection of both -pthread and -lpthread fails with --libxml (may
the messages about strcpy/strcat be the cause) ?

Regards,


Re: [Postgresql alpha3] Configure fails with --libxml on OpenBSD

From
Greg Smith
Date:
postgresql@raveland.org wrote:
> I don't understand why the detection of both -pthread and -lpthread fails with --libxml (may
> the messages about strcpy/strcat be the cause) ?
>
Those warning are just that:  warnings, nothing related to your problem.

My first guess is that you're using a libxml from before thread safety
was introduced, or have a version that wasn't compiled to support it:

http://xmlsoft.org/threads.html

There was a recent change to PostgreSQL that switched the default to
turning on thread safety for clients when you build.  You can easily
turn it back off again with passing --disable-thread-safety if you just
don't have an installed libxml that is thread-safe.

--
Greg Smith    2ndQuadrant   Baltimore, MD
PostgreSQL Training, Services and Support
greg@2ndQuadrant.com  www.2ndQuadrant.com


Re: [Postgresql alpha3] Configure fails with --libxml on OpenBSD

From
postgresql@raveland.org
Date:
On Wed, Dec 30, 2009 at 11:34:17AM -0500, Greg Smith wrote:
> postgresql@raveland.org wrote:
> >I don't understand why the detection of both -pthread and
> >-lpthread fails with --libxml (may the messages about
> >strcpy/strcat be the cause) ?
> Those warning are just that:  warnings, nothing related to your problem.
>
> My first guess is that you're using a libxml from before thread
> safety was introduced, or have a version that wasn't compiled to
> support it:
>
> http://xmlsoft.org/threads.html
>
> There was a recent change to PostgreSQL that switched the default to
> turning on thread safety for clients when you build.  You can easily
> turn it back off again with passing --disable-thread-safety if you
> just don't have an installed libxml that is thread-safe.
>

Hi Greg,

Thanks for your answer.
You're right: the libxml (on OpenBSD) is build without the threads support.
I already use --disable-thread-safety but I was curious about the error
with libxml.

Regards,