Re: Pthread detection in glib 2.2.1



Hi Albert,

> Pthread detection in glib 2.2.1 doesn't work on AIX. If using the
> IBM xlc_r compiler, -pthread doesn't cause the compiler to fail so the
> wrong flag is selected:
>   $ xlc -c -pthread a.c
>   xlc: 1501-210 command option t contains an incorrect subargument
>   $ echo $?
>   0
> 
>   $ xlc -c -pthreads a.c
>   xlc: 1501-210 command option t contains an incorrect subargument
>   $ echo $?
>   0
> 
> -pthreads is detected and every compile command generates the above
> warning. How about a more reliable method to detech the pthread flags?
> I think the first thing to do is use the default compiler options and
> then start adding to $CFLAGS or $CPPFLAGS. I've started a patch below.

     # both CPPFLAG and LIBS. 
     # One of them does for most gcc versions and some other platforms/compilers
     # too and could be considered as the canonical way to go. 
-    for flag in pthread pthreads; do
+    for flag in "" -pthread -pthreads; do
       glib_save_CFLAGS="$CFLAGS"
-      CFLAGS="$CFLAGS -$flag"
+      CFLAGS="$CFLAGS $flag"
       AC_TRY_RUN(glib_thread_test,
                  glib_flag_works=yes,
                  glib_flag_works=no,

The problem with that is, that running might work without flags, but the
resulting binary wouldn't be threadsafe (I might be wrong here)

I would rather special-case xlc et al in that case. The attached path
does just that. Is it a solution for your problems?

Bye,
Sebastian 
-- 
Sebastian Wilhelmi                 |            här ovanför alla molnen
mailto:seppi seppi de              |     är himmlen så förunderligt blå
http://seppi.de
Index: configure.in
===================================================================
RCS file: /cvs/gnome/glib/configure.in,v
retrieving revision 1.348
diff -p -u -b -B -r1.348 configure.in
--- configure.in	4 Mar 2003 10:10:15 -0000	1.348
+++ configure.in	10 Mar 2003 15:05:52 -0000
@@ -1373,6 +1373,11 @@ if test x"$have_threads" != xno; then
     # both CPPFLAG and LIBS. 
     # One of them does for most gcc versions and some other platforms/compilers
     # too and could be considered as the canonical way to go. 
+    # Some compilers however should not be tested, as they accept
+    # -pthread, even though it shouldn't be used.
+    case $CC in
+      cc_r|xlc_r) ;;
+      *)
     for flag in pthread pthreads; do
       glib_save_CFLAGS="$CFLAGS"
       CFLAGS="$CFLAGS -$flag"
@@ -1388,6 +1393,8 @@ if test x"$have_threads" != xno; then
 	 G_THREAD_LIBS=-$flag
       fi
     done
+        ;;
+    esac
   fi
 
   if test x"$G_THREAD_CFLAGS" = x; then
@@ -1481,7 +1488,12 @@ case $have_threads in
               *-aix*)
                 # We are not using gcc (would have set G_THREAD_LIBS) and thus 
                 # probably using the aix compiler.
+		case "$CC" in
+		  cc_r|xlc_r) ;;
+                  *)
 		AC_MSG_WARN($AIX_COMPILE_INFO)
+                    ;;
+                esac
                 ;;
               *)
                 G_THREAD_LIBS=error


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]