enable thready safety on Mac OS X 10.3.4

Started by Aaron Burghardtalmost 22 years ago12 messagesgeneral
Jump to latest
#1Aaron Burghardt
aburgh@mac.com

I attempted to compile 7.4.3 with enable-thread-safety but it fails and
says it's not supported. My configure command was:

./configure --enable-thread-safety

and the result:

checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
configure: error:
Cannot enable threads on your platform.
Please report your platform threading info to the PostgreSQL mailing
lists
so it can be added to the next release. Report all compile flags, link
flags,
functions, or libraries required for threading support.
See the comment at the top of src/port/thread.c for more information.

This is on OS X 10.3.4 with the latest developer tools. Am I doing
something wrong, or should this be reported as a bug?

Thanks,
----
Aaron Burghardt
aburgh@mac.com

#2Keary Suska
hierophant@pcisys.net
In reply to: Aaron Burghardt (#1)
Re: enable thready safety on Mac OS X 10.3.4

on 6/26/04 11:21 AM, aburgh@mac.com purportedly said:

I attempted to compile 7.4.3 with enable-thread-safety but it fails and
says it's not supported. My configure command was:

./configure --enable-thread-safety

This is what I did for 10.3.4/7.4.2:

1. Enabled thread support in the platform template: src/template/darwin (see
src/tools/thread/README for info)

2. Configured/compiled

3. Ran the thread_test program that was created by compile (in
src/tools/thread)

4. Followed any recommendations output by the program

5. Re-configured/compiled

Everything was fine.

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"

#3Aaron Burghardt
aburgh@mac.com
In reply to: Keary Suska (#2)
Re: enable thready safety on Mac OS X 10.3.4

Thanks, that worked!
----
Aaron Burghardt
aburgh@mac.com

On Jun 26, 2004, at 4:01 PM, Keary Suska wrote:

Show quoted text

on 6/26/04 11:21 AM, aburgh@mac.com purportedly said:

I attempted to compile 7.4.3 with enable-thread-safety but it fails
and
says it's not supported. My configure command was:

./configure --enable-thread-safety

This is what I did for 10.3.4/7.4.2:

1. Enabled thread support in the platform template:
src/template/darwin (see
src/tools/thread/README for info)

2. Configured/compiled

3. Ran the thread_test program that was created by compile (in
src/tools/thread)

4. Followed any recommendations output by the program

5. Re-configured/compiled

Everything was fine.

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"

---------------------------(end of
broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

#4Wes
wespvp@syntegra.com
In reply to: Keary Suska (#2)
Re: enable thready safety on Mac OS X 10.3.4

On 6/26/04 3:01 PM, "Keary Suska" <hierophant@pcisys.net> wrote:

I attempted to compile 7.4.3 with enable-thread-safety but it fails and
says it's not supported. My configure command was:

./configure --enable-thread-safety

This is what I did for 10.3.4/7.4.2:

1. Enabled thread support in the platform template: src/template/darwin (see
src/tools/thread/README for info)

2. Configured/compiled

3. Ran the thread_test program that was created by compile (in
src/tools/thread)

4. Followed any recommendations output by the program

5. Re-configured/compiled

Everything was fine.

You shouldn't have to mess with template/darwin. Back post 7.4.2 I went
through a number of iterations with the developers on this and it was
working out of the box. They were in the process of rewriting the threads
detection and configuration to be more clean and reliable.

I just tried it from the CVS source and it worked fine, even after a 'make
clean'. However, when I download 7.4.3 and try it, I get the same error as
you. The darwin template is identical between the two. I would have
thought all those code changes would have been incorporated in 7.4.3.

I think this requires some more investigation. Mac OS X 10.3.x should be
working off the bat.

Wes

#5Bruce Momjian
bruce@momjian.us
In reply to: Wes (#4)
Re: enable thready safety on Mac OS X 10.3.4

wespvp@syntegra.com wrote:

On 6/26/04 3:01 PM, "Keary Suska" <hierophant@pcisys.net> wrote:

I attempted to compile 7.4.3 with enable-thread-safety but it fails and
says it's not supported. My configure command was:

./configure --enable-thread-safety

This is what I did for 10.3.4/7.4.2:

1. Enabled thread support in the platform template: src/template/darwin (see
src/tools/thread/README for info)

2. Configured/compiled

3. Ran the thread_test program that was created by compile (in
src/tools/thread)

4. Followed any recommendations output by the program

5. Re-configured/compiled

Everything was fine.

You shouldn't have to mess with template/darwin. Back post 7.4.2 I went
through a number of iterations with the developers on this and it was
working out of the box. They were in the process of rewriting the threads
detection and configuration to be more clean and reliable.

I just tried it from the CVS source and it worked fine, even after a 'make
clean'. However, when I download 7.4.3 and try it, I get the same error as
you. The darwin template is identical between the two. I would have
thought all those code changes would have been incorporated in 7.4.3.

I think this requires some more investigation. Mac OS X 10.3.x should be
working off the bat.

The thread testing in 7.5 is dramatically different from 7.4 and can't
be backpatched. What should I add to template/darwin for 7.4.4?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#6Aaron Burghardt
aburgh@mac.com
In reply to: Bruce Momjian (#5)
Re: enable thready safety on Mac OS X 10.3.4

On Jul 6, 2004, at 12:06 AM, Bruce Momjian wrote:

wespvp@syntegra.com wrote:

On 6/26/04 3:01 PM, "Keary Suska" <hierophant@pcisys.net> wrote:

I attempted to compile 7.4.3 with enable-thread-safety but it fails
and
says it's not supported. My configure command was:

./configure --enable-thread-safety

This is what I did for 10.3.4/7.4.2:

1. Enabled thread support in the platform template:
src/template/darwin (see
src/tools/thread/README for info)

2. Configured/compiled

3. Ran the thread_test program that was created by compile (in
src/tools/thread)

4. Followed any recommendations output by the program

5. Re-configured/compiled

Everything was fine.

You shouldn't have to mess with template/darwin. Back post 7.4.2 I
went
through a number of iterations with the developers on this and it was
working out of the box. They were in the process of rewriting the
threads
detection and configuration to be more clean and reliable.

I just tried it from the CVS source and it worked fine, even after a
'make
clean'. However, when I download 7.4.3 and try it, I get the same
error as
you. The darwin template is identical between the two. I would have
thought all those code changes would have been incorporated in 7.4.3.

I think this requires some more investigation. Mac OS X 10.3.x
should be
working off the bat.

The thread testing in 7.5 is dramatically different from 7.4 and can't
be backpatched. What should I add to template/darwin for 7.4.4?

I added these two lines:

THREAD_SUPPORT=yes
NEED_REENTRANT_FUNCS=no

But, is it a mistake to have these defined when thread-safety is not
enabled?
----
Aaron Burghardt
aburgh@mac.com

#7Bruce Momjian
bruce@momjian.us
In reply to: Aaron Burghardt (#6)
Re: enable thready safety on Mac OS X 10.3.4

Aaron Burghardt wrote:

I think this requires some more investigation. Mac OS X 10.3.x
should be
working off the bat.

The thread testing in 7.5 is dramatically different from 7.4 and can't
be backpatched. What should I add to template/darwin for 7.4.4?

I added these two lines:

THREAD_SUPPORT=yes
NEED_REENTRANT_FUNCS=no

Great. It will be in the next 7.4.X release.

But, is it a mistake to have these defined when thread-safety is not
enabled?

Setting these are fine. It is only used when you use the configure
flag.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#8Wes
wespvp@syntegra.com
In reply to: Bruce Momjian (#5)
Re: enable thready safety on Mac OS X 10.3.4

On 7/5/04 11:06 PM, "Bruce Momjian" <pgman@candle.pha.pa.us> wrote:

The thread testing in 7.5 is dramatically different from 7.4 and can't
be backpatched. What should I add to template/darwin for 7.4.4?

I added these two lines:

THREAD_SUPPORT=yes
NEED_REENTRANT_FUNCS=no

I don't think this is safe. What I've been using since 7.4.1/Mac OS X 10.3
is:

# Apple's cpp-precomp seems a tad broken, so don't use it
# (Note: on OS X before 10.2, you might need -traditional-cpp instead)
CC="$CC -no-cpp-precomp"

# Select appropriate semaphore support
USE_NAMED_POSIX_SEMAPHORES=1

# tools/thread/thread_test must be run
THREAD_SUPPORT=yes
THREAD_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
THREAD_LIBS="-lpthread"

NEED_REENTRANT_FUNCS=yes

It appears with OS X 10.3.4, the THREAD_LIBS="-lpthread" is no longer
necessary (or is it due to PostgreSQL 7.3.4?). Previously it would not
build without this. With 7.3.4 and OS X 10.3.4, it will build with or
without it. I think -lpthread was required with OS X 10.2 (Jaguar).

I don't recall why -D_POSIX_PTHREAD_SEMANTICS was needed.

If I run thread_test many times, I get inconsistent results. I get both:

All your non-*_r functions are thread-safe.
Add this to your template/$port file:

NEED_REENTRANT_FUNCS=no

and:

Your gethostbyname() is _not_ thread-safe
Not all non-*_r functions are thread-safe.
Add this to your template/$port file:

NEED_REENTRANT_FUNCS=yes

Thus, to be safe I believe 'NEED_REENTRANT_FUNCS=yes' should be specified.
If I remember right from earlier discussions, the '-D_REENTRANT' *is*
required to insure errno is handled properly in a threaded environment.

See also the thread 'thread_test.c problems' back in of April. This was the
last entry from you on the subject:

OK, CVS is ready. I unconditionally defined:

-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS

for all ports. It can't hurt if they are not supported, but it makes
our job easier for porting. It allowed me to remove almost all the
port-specific thread stuff. The other tests are done by configure and
thread_test.

Should fix Darwin compile and other platforms without mucking with the
thread detection code.

Wes

#9Bruce Momjian
bruce@momjian.us
In reply to: Wes (#8)
Re: enable thready safety on Mac OS X 10.3.4

OK, I have removed the changes I just added to allow threads for 7.4.X
on OSX. This stuff had to be dealt with before 7.4 final, and I don't
want to play with it at this point. 7.5 thread testing is automatic so
people will have to wait for that.

---------------------------------------------------------------------------

wespvp@syntegra.com wrote:

On 7/5/04 11:06 PM, "Bruce Momjian" <pgman@candle.pha.pa.us> wrote:

The thread testing in 7.5 is dramatically different from 7.4 and can't
be backpatched. What should I add to template/darwin for 7.4.4?

I added these two lines:

THREAD_SUPPORT=yes
NEED_REENTRANT_FUNCS=no

I don't think this is safe. What I've been using since 7.4.1/Mac OS X 10.3
is:

# Apple's cpp-precomp seems a tad broken, so don't use it
# (Note: on OS X before 10.2, you might need -traditional-cpp instead)
CC="$CC -no-cpp-precomp"

# Select appropriate semaphore support
USE_NAMED_POSIX_SEMAPHORES=1

# tools/thread/thread_test must be run
THREAD_SUPPORT=yes
THREAD_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
THREAD_LIBS="-lpthread"

NEED_REENTRANT_FUNCS=yes

It appears with OS X 10.3.4, the THREAD_LIBS="-lpthread" is no longer
necessary (or is it due to PostgreSQL 7.3.4?). Previously it would not
build without this. With 7.3.4 and OS X 10.3.4, it will build with or
without it. I think -lpthread was required with OS X 10.2 (Jaguar).

I don't recall why -D_POSIX_PTHREAD_SEMANTICS was needed.

If I run thread_test many times, I get inconsistent results. I get both:

All your non-*_r functions are thread-safe.
Add this to your template/$port file:

NEED_REENTRANT_FUNCS=no

and:

Your gethostbyname() is _not_ thread-safe
Not all non-*_r functions are thread-safe.
Add this to your template/$port file:

NEED_REENTRANT_FUNCS=yes

Thus, to be safe I believe 'NEED_REENTRANT_FUNCS=yes' should be specified.
If I remember right from earlier discussions, the '-D_REENTRANT' *is*
required to insure errno is handled properly in a threaded environment.

See also the thread 'thread_test.c problems' back in of April. This was the
last entry from you on the subject:

OK, CVS is ready. I unconditionally defined:

-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS

for all ports. It can't hurt if they are not supported, but it makes
our job easier for porting. It allowed me to remove almost all the
port-specific thread stuff. The other tests are done by configure and
thread_test.

Should fix Darwin compile and other platforms without mucking with the
thread detection code.

Wes

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#10Wes
wespvp@syntegra.com
In reply to: Bruce Momjian (#9)
Re: enable thready safety on Mac OS X 10.3.4

On 7/8/04 11:28 AM, "Bruce Momjian" <pgman@candle.pha.pa.us> wrote:

OK, I have removed the changes I just added to allow threads for 7.4.X
on OSX. This stuff had to be dealt with before 7.4 final, and I don't
want to play with it at this point. 7.5 thread testing is automatic so
people will have to wait for that.

Just as a note to anyone searching the archives...

# tools/thread/thread_test must be run
THREAD_SUPPORT=yes
THREAD_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
THREAD_LIBS="-lpthread"

NEED_REENTRANT_FUNCS=yes

works on both OS X 10.2 and 10.3

Wes

#11Bruce Momjian
bruce@momjian.us
In reply to: Wes (#10)
Re: enable thready safety on Mac OS X 10.3.4

wespvp@syntegra.com wrote:

On 7/8/04 11:28 AM, "Bruce Momjian" <pgman@candle.pha.pa.us> wrote:

OK, I have removed the changes I just added to allow threads for 7.4.X
on OSX. This stuff had to be dealt with before 7.4 final, and I don't
want to play with it at this point. 7.5 thread testing is automatic so
people will have to wait for that.

Just as a note to anyone searching the archives...

# tools/thread/thread_test must be run
THREAD_SUPPORT=yes
THREAD_CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
THREAD_LIBS="-lpthread"

NEED_REENTRANT_FUNCS=yes

works on both OS X 10.2 and 10.3

OK, I put this back in for 7.4.X since you tested to OSX versions, which
helps me think it is reliable. Thanks.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#12Benjamin Reed
rangerrick@gmail.com
In reply to: Bruce Momjian (#11)
Re: enable thready safety on Mac OS X 10.3.4

On Thu, 8 Jul 2004 14:25:48 -0400 (EDT), Bruce Momjian
<pgman@candle.pha.pa.us> wrote:

works on both OS X 10.2 and 10.3

OK, I put this back in for 7.4.X since you tested to OSX versions, which
helps me think it is reliable. Thanks.

I can confirm this as well, and I'll be including these changes in the
next release of the PostgreSQL packages for Fink on Mac OS X.