patchGNU Autoconf Archive - Patches: patch #8081, AX_PTHREAD.m4 not setting...

 
 

patch #8081: AX_PTHREAD.m4 not setting PTHREAD_LIBS to -pthread for gcc 4.7.2

Submitted by:  Peter Simons <simons>
Submitted on:  Wed 19 Jun 2013 07:49:38 AM UTC  
 
Priority: 5 - NormalStatus: Invalid
Assigned to: Peter Simons <simons>Open/Closed: Closed

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 11 Nov 2013 03:31:48 PM UTC, comment #5:

Laurent: No, -pthread already implies use of the pthread library. From the GCC man page:

-pthread
Adds support for multithreading with the pthreads library.
This option sets flags for both the preprocessor and linker.

Daniel Richard G. <iskunk>
Mon 11 Nov 2013 08:21:13 AM UTC, comment #4:

Hi,

I might be wrong here, but shouldn't PTHREAD_LIBS also be containing '-lpthread' on linux platform?

On my machine:

LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"

is expanding to

LIBS=
CFLAGS=-g -O2 -pthread
CC=gcc

Laurent Bigonville <bigon>
Tue 09 Jul 2013 08:41:43 PM UTC, comment #3:

I think so.

It would have been nice to have heard back from the original reporter, but given that this issue came up on (Red Hat) Linux and not some obscure platform, I think we would have seen more user reports if there were a real bug here.

Daniel Richard G. <iskunk>
Fri 05 Jul 2013 11:20:55 AM UTC, comment #2:

Am I correct assuming that this issue can be closed?

Peter Simons <simons>
Project AdministratorIn charge of this item.
Wed 19 Jun 2013 04:16:06 PM UTC, comment #1:

As far as I could tell, the issue came down to not using PTHREAD_CFLAGS at link time. This is why the comment on lines 21-23 of m4/ax_pthread.m4 is there.

Flags like -pthread need to be used at both the compile step and the link step, and rather than duplicate these flags between PTHREAD_CFLAGS and PTHREAD_LIBS, it makes more sense to keep them in PTHREAD_CFLAGS, have PTHREAD_LIBS contain bits that are only needed at link time (like -lfoo directives), and use both variables when linking.

(I don't rule out the possibility of there being an actual problem here, but I haven't seen a clear indication of that yet.)

Daniel Richard G. <iskunk>
Wed 19 Jun 2013 07:49:38 AM UTC, original submission:

Al reported the following issue on the maintainers mailing list:

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)

Peter Simons <simons>
Project AdministratorIn charge of this item.

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #28352:  ax_pthread.m4.patch added by None (586B - text/x-patch - Here is Craig McQueen's patch, which I believe to be correct.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bigon (Posted a comment)
  • -unavailable- added by iskunk (Posted a comment)
  • -unavailable- added by simons (Submitted the item)
  • -unavailable- added by simons
  • -unavailable- added by simons
  • -unavailable- added by simons
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 10 Jul 2013 07:58:20 AM UTCsimonsOpen/ClosedOpen=>Closed
    Fri 05 Jul 2013 11:20:55 AM UTCsimonsStatusIn Progress=>Invalid
    Wed 19 Jun 2013 06:03:30 PM UTCNoneAttached File-=>Added ax_pthread.m4.patch, #28352
    Wed 19 Jun 2013 07:49:39 AM UTCsimonsCarbon-Copy-=>Added steven g. johnson
      Carbon-Copy-=>Added daniel richard g.
      Carbon-Copy-=>Added al pacifico

    Back to the top


    Powered by Savane 3.1-cleanup