unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* pthread versus freebsd
@ 2004-02-16  0:37 Kevin Ryde
  2004-03-19 22:15 ` Kevin Ryde
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Ryde @ 2004-02-16  0:37 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 302 bytes --]

The guile configury for pthreads doesn't work on freebsd, you have to
use "gcc -pthread" there, not -lpthread.  I'm looking at something
like the following, to hav that option used if it works.

Not quite sure if munging CFLAGS is the right thing to do.  Maybe CC
would be better, or maybe AM_CFLAGS.


[-- Attachment #2: configure.in.pthread.diff --]
[-- Type: text/plain, Size: 1099 bytes --]

--- configure.in.~1.230.~	2004-02-10 09:37:56.000000000 +1000
+++ configure.in	2004-02-16 10:32:42.000000000 +1000
@@ -914,12 +914,30 @@
 
 case "$with_threads" in
   "yes" | "pthread" | "pthreads" | "pthread-threads" | "")
+
+    # Note that gcc -pthread is vital on FreeBSD, there's no -lpthread
+    # normally used there, the threading stuff is in a special libc_r
+    # selected by gcc -pthread.
+    #
+    if test $GCC = yes; then
+      # try gcc -pthread
+      old_CFLAGS=$CFLAGS
+      CFLAGS="-pthread $CFLAGS"
+      AC_TRY_LINK([#include <pthread.h>], [pthread_yield();],
+        [SCM_I_GSC_USE_PTHREAD_THREADS=1
+         with_threads="pthreads"],
+        [CFLAGS=$old_CFLAGS])
+    fi
+
+    if test "$SCM_I_GSC_USE_PTHREAD_THREADS" != 1; then
+    # otherwise try just -lpthread
     AC_CHECK_LIB(pthread, main,
       LIBS="-lpthread $LIBS"
       SCM_I_GSC_USE_PTHREAD_THREADS=1
       with_threads="pthreads",
       with_threads="null")
-      
+    fi
+
     if test $GCC = yes; then
     AC_DEFINE(_THREAD_SAFE, 1,
       [Use thread safe versions of GNU Libc functions.])

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: pthread versus freebsd
  2004-02-16  0:37 pthread versus freebsd Kevin Ryde
@ 2004-03-19 22:15 ` Kevin Ryde
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Ryde @ 2004-03-19 22:15 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 227 bytes --]

Well, I've got doubts about the way gcc -pthread should be setup, so
I've added the entry below to the TODO file, and left it at that.

FreeBSD doesn't spring into life with just this change anyway, so
it'll all have to wait.


[-- Attachment #2: TODO.gcc-pthread.diff --]
[-- Type: text/plain, Size: 1951 bytes --]

--- TODO.~1.106.~	2003-11-15 06:45:14.000000000 +1000
+++ TODO	2004-03-20 08:15:03.000000000 +1000
@@ -90,6 +90,42 @@
 
 
 - Eventually
+  - Select pthreads compile with "gcc -pthread" when available, with
+    something like the block below in configure.in.
+
+    This is almost certainly the right way to get pthreads, but
+    consideration needs to be given to application compiles.  Will an
+    application need to compile and/or link with the same "gcc
+    -pthread"?  On systems like FreeBSD where -pthread changes the
+    libc used then very likely yes.  Emitting such an option from the
+    guile-config script would, however, make that script compiler
+    dependent, which would be undesirable.
+
+      # "gcc -pthread" is supposedly the way to get the right defines and
+      # libraries on pretty much all systems where it makes sense (though the
+      # gcc 3.3 manual only seems to describe it for a couple of targets).
+      #
+      # On FreeBSD, gcc -pthread is vital, there's no -lpthread on that system,
+      # instead -pthread option selects the special libc_r C library.
+      #
+      # Forcibly adding -pthread to user-selected CFLAGS is a bit rude, user
+      # stuff ought to be left alone.  But adding ensures we get what we need,
+      # and it's actually quite convenient if the user is just setting
+      # optimization options or whatever.
+      #
+      if test $GCC = yes; then
+        old_CFLAGS=$CFLAGS
+        CFLAGS="-pthread $CFLAGS"
+        AC_TRY_LINK([#include <pthread.h>], [pthread_yield();],
+          [SCM_I_GSC_USE_PTHREAD_THREADS=1
+           with_threads="pthreads"],
+          [CFLAGS=$old_CFLAGS])
+      fi
+
+      # If that didn't work then try just -lpthread.
+      #
+      if test "$SCM_I_GSC_USE_PTHREAD_THREADS" != 1; then
+        ...
 
   - pretty-print #:width can lower the allowed width, but cannot
     increase it, max-expr-width (50) appears to be a hard limit.

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-03-19 22:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-16  0:37 pthread versus freebsd Kevin Ryde
2004-03-19 22:15 ` Kevin Ryde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).