patchGNU Autoconf Archive - Patches: patch #8847, AX_PTHREAD: improve support for...

 
 

patch #8847: AX_PTHREAD: improve support for Solaris

Submitter:  Alan Coopersmith <alanc>
Submitted:  Sun 10 Jan 2016 04:33:43 AM UTC
   
 
Priority:  5 - Normal Status:  Duplicate
Assigned to:  None Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 31 Jul 2017 11:03:28 PM UTC, comment #8: 

Alan, thank you for the information. I have a new -draft5 version of the macro ready; it is attached. Please give it a try.

I'm assuming that GCC continues to define _REENTRANT for -pthread builds on this platform; please let me know if that has changed as well.

I had another look at the patch you had submitted originally. Have the Solaris docs changed on the &quot;official&quot; way of linking pthreads, which last I saw was &quot;-mt -lpthread&quot; ?

(file #41377)

Daniel Richard G. <iskunk>
Mon 24 Jul 2017 01:02:55 AM UTC, comment #7: 

This changed in Studio 12.6 (aka __SUNPRO_C=0x5150) on Solaris releases after 11.3.x.  I'm not aware of any new #defines that are set instead.

Alan Coopersmith <alanc>
Wed 19 Jul 2017 11:40:04 PM UTC, comment #6: 

Is there some other preprocessor symbol that is defined/changed when -mt is given in this recent version? I'm surprised that they removed the definition of _REENTRANT rather than just conditionals that use it, especially when user code might want to key off of it.

Being able to detect -mt using the preprocessor one way or another was an easy way to make this pthreads check more robust, so I'd like to see if there's an alternative. Either way, would you know the __SUNPRO_C version number where this changed?

Daniel Richard G. <iskunk>
Wed 19 Jul 2017 10:47:53 PM UTC, comment #5: 

The next version of Solaris removed the requirement to #define _REENTRANT, so the new Studio compilers stop passing it as part of -mt when run on that version.  Since that version of Solaris has not yet shipped, the man pages have not yet been updated to reflect this.

No new flag needs to be supported, the macro just needs to stop enforcing the requirement that the old flag be defined when its no longer needed.

Alan Coopersmith <alanc>
Wed 19 Jul 2017 09:36:43 PM UTC, comment #4: 

Hi Will,

The -mt flag is being passed to the compiler, yet _REENTRANT is not implicitly defined?

I'm going to need more information on this, because this does not appear to be correct behavior for the Solaris vendor compiler. From the cc(1) man page on one system I have here:


     -mt  Passes D_REENTRANT to preprocessor.  Appends  -lthread.
          If  you are doing your own multithread coding, you must
          use this option in the  compile  and  link  steps.   To
          obtain  faster  execution,  this option requires a mul-
          tiprocessor system. On a single-processor  system,  the
          resulting executable usually runs more slowly with this
          option.


Do the docs for your compiler version describe something different? Is there a new flag that needs to be supported, perhaps?

Daniel Richard G. <iskunk>
Wed 19 Jul 2017 08:43:42 PM UTC, comment #3: 

This issue of conftest.c including:

#                       if !defined(_REENTRANT)
#                        error "_REENTRANT must be defined"
#                       endif

is causing:

configure:6446: checking whether pthreads work with -mt
configure:6540: /opt/developerstudio12.6/bin/cc -o conftest -xO4 -m64 -errtags=yes -errwarn=%all
-errwarn=no%E_STATEMENT_NOT_REACHED -errwarn=no%E_NO_IMPLICIT_DECL_ALLOWED -errwarn=no%E_EMPTY_TRANSLATION_UNIT
-errwarn=no%E_EMPTY_INITIALIZER -errwarn=no%E_EMPTY_DECLARATION -errwarn=no%E_ENUM_VAL_OVERFLOWS_INT_MAX
-errwarn=no%E_DEPRECATED_ATT -errwarn=no%E_INIT_SIGN_EXTEND -errwarn=no%E_ASSIGNMENT_TYPE_MISMATCH -mt   conftest.c  -lresolv

>&5

"conftest.c", line 42: #error: "_REENTRANT must be defined"
cc: acomp failed for conftest.c

When I compile MIT kerberos on a Solaris development build using the Oracle Studio v12.6 C compiler.  This patch needs to be applied to the current version of ax_pthread.m4.

Will Fiveash <wfiveash>
Mon 29 Feb 2016 10:20:45 AM UTC, comment #2: 

I suppose this patch is no longer required.

Peter Simons <simons>
Group administrator
Tue 09 Feb 2016 08:40:52 AM UTC, comment #1: 

Hi Alan,

I've been working on this as well, alongside improvements to the Clang support in AX_PTHREAD:

    http://savannah.gnu.org/patch/?8186

Could you try out the -draft3.m4 version of the macro that is attached to that patch record?

One thing I see in the flags you are returning: _REENTRANT should be implicitly defined by the compiler when -mt is passed in; this flag should not be defined manually. (In fact, I've updated part of the macro to check for this implicit definition, as it's a good hint that POSIX threads support has been correctly enabled.)

Daniel Richard G. <iskunk>
Sun 10 Jan 2016 04:33:43 AM UTC, original submission:  

This patch improves the selection of flags for gcc & Sun cc on
Solaris, dropping those no longer needed on modern versions,
while preserving support for older versions that still need them.

It also modifies the fix for http://savannah.gnu.org/patch/?7666
to use the existing compiler tests - previously that wasn't
effective because -lpthread was tested before -mt so it never
got to the -mt test - now it tests -mt & -lpthread in unison
so we add -mt only for compilers that support it, not for all
which aren't gcc (hence removing the need for the "What about
clang?" comment).

To test, I wrote a quick stub configure.ac:

AC_INIT(test, 0.1)
AM_INIT_AUTOMAKE([foreign])

AX_PTHREAD()

AC_MSG_NOTICE([host_os:        ${host_os}])
AC_MSG_NOTICE([PTHREAD_CC:     ${PTHREAD_CC}])
AC_MSG_NOTICE([PTHREAD_CFLAGS: ${PTHREAD_CFLAGS}])
AC_MSG_NOTICE([PTHREAD_LIBS:   ${PTHREAD_LIBS}])
       
AC_OUTPUT

Output on various machines using Studio cc:

configure: host_os:        solaris2.12
configure: PTHREAD_CC:     cc
configure: PTHREAD_CFLAGS:
configure: PTHREAD_LIBS:

configure: host_os:        solaris2.11
configure: PTHREAD_CC:     cc
configure: PTHREAD_CFLAGS: -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS
configure: PTHREAD_LIBS:

configure: host_os:        solaris2.10
configure: PTHREAD_CC:     cc
configure: PTHREAD_CFLAGS: -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS
configure: PTHREAD_LIBS:

configure: host_os:        solaris2.9
configure: PTHREAD_CC:     cc
configure: PTHREAD_CFLAGS: -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -mt
configure: PTHREAD_LIBS:   -lpthread

And using gcc:

configure: host_os:        solaris2.12
configure: PTHREAD_CC:     gcc
configure: PTHREAD_CFLAGS:
configure: PTHREAD_LIBS:

configure: host_os:        solaris2.11
configure: PTHREAD_CC:     gcc
configure: PTHREAD_CFLAGS: -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS
configure: PTHREAD_LIBS:

configure: host_os:        solaris2.10
configure: PTHREAD_CC:     gcc
configure: PTHREAD_CFLAGS: -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS
configure: PTHREAD_LIBS:

[I couldn't find a working pre-S10 machine with gcc to test on.]

And for comparison, prior to this fix:

configure: host_os:        solaris2.12
configure: PTHREAD_CC:     cc
configure: PTHREAD_CFLAGS: -mt -D_REENTRANT
configure: PTHREAD_LIBS:   -lpthread

configure: host_os:        solaris2.12
configure: PTHREAD_CC:     gcc
configure: PTHREAD_CFLAGS: -D_REENTRANT -pthreads
configure: PTHREAD_LIBS:

I've confirmed with the Solaris libc/threads, linker, and compiler teams that these are the correct flags for these OS'es.

Alan Coopersmith <alanc>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #41377:  ax_pthread-draft5.m4 added by iskunk (18KiB - application/x-m4)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by wfiveash (Posted a comment)
  • -email is unavailable- added by simons (Posted a comment)
  • -email is unavailable- added by iskunk (Posted a comment)
  • -email is unavailable- added by alanc (Submitted the item)
  •  

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-07-31 iskunk Attached File- Added ax_pthread-draft5.m4, #41377
    2016-02-29 simons StatusNone Duplicate
        Open/ClosedOpen Closed
    2016-02-09 iskunk Carbon-CopyRemoved iskunk -
    2016-02-09 iskunk Carbon-Copy- Added iskunk
    2016-01-10 alanc Attached File- Added 0001-AX_PTHREAD-improve-support-for-Solaris.patch, #35959

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code