autoconf-archive-maintainers
[Top][All Lists]
Advanced

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

AX_PTHREAD.m4 not setting PTHREAD_LIBS to -pthread for gcc 4.7.2


From: Al Pacifico
Subject: AX_PTHREAD.m4 not setting PTHREAD_LIBS to -pthread for gcc 4.7.2
Date: Mon, 17 Jun 2013 22:53:00 -0700

Have you seen this thread on stackoverflow.com?

http://stackoverflow.com/questions/17055279/autotools-for-pthreads-not-setting-correct-linker-flags


Just ran into the same problem, using the packaged Fedora autoconf-archive, and was rather surprised. The suggested patch in Craig McQueen's answer looks good to me, but I didn't know if -pthread was needed for compilation on some non-gcc compilers while passing some other flag to the linker was needed (i.e. patch would break that case).

Helpful context:
$gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.7.2/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --disable-build-with-cxx --disable-build-poststage1-with-cxx --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.7.2 20120921 (Red Hat 4.7.2-2) (GCC) 

$ diff -u /usr/share/aclocal/ax_pthread.m4 ~/Downloads/latest-ax_pthread.m4 
--- /usr/share/aclocal/ax_pthread.m4 2012-09-07 15:00:00.000000000 -0700
+++ /home/pacifico/Downloads/latest-ax_pthread.m4 2013-06-17 22:44:56.990042108 -0700
@@ -82,7 +82,7 @@
 #   modified version of the Autoconf Macro, you may extend this special
 #   exception to the GPL to apply to your modified version as well.
 
-#serial 18
+#serial 20
 
 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
 AC_DEFUN([AX_PTHREAD], [
@@ -283,16 +283,24 @@
         LIBS="$save_LIBS"
         CFLAGS="$save_CFLAGS"
 
-        # More AIX lossage: must compile with xlc_r or cc_r
-        if test x"$GCC" != xyes; then
-          AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
-        else
-          PTHREAD_CC=$CC
+        # More AIX lossage: compile with *_r variant
+        if test "x$GCC" != xyes; then
+            case $host_os in
+                aix*)
+                AS_CASE(["x/$CC"],
+                  [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
+                  [#handle absolute path differently from PATH based program lookup
+                   AS_CASE(["x$CC"],
+                     [x/*],
+                     [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
+                     [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
+                ;;
+            esac
         fi
-else
-        PTHREAD_CC="$CC"
 fi
 
+test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
+
 AC_SUBST(PTHREAD_LIBS)
 AC_SUBST(PTHREAD_CFLAGS)
 AC_SUBST(PTHREAD_CC)

It would be nice if one of you commented directly on stackoverflow.com.
-Al

--
Al Pacifico
Seattle, WA

reply via email to

[Prev in Thread] Current Thread [Next in Thread]