Dagobert Michelsen <[email protected]> writes:

> Hi Peter,
>
> Am 08.01.2011 um 14:06 schrieb Peter FELECAN:
>> Dagobert Michelsen <[email protected]> writes:
>>> Am 08.01.2011 um 10:43 schrieb Peter FELECAN:
>>>> Ben Walton <[email protected]> writes:
>>>>> Excerpts from Peter FELECAN's message of Fri Jan 07 03:23:59 -0500 2011:
>>>>> 
>>>>>> I think that we can use libintl without much worry; the kludgy way
>>>>>> that they use to alleviate a SUN libc issue will fade away when the
>>>>>> support for Solaris 9 is terminated. Anyway, caution is always a
>>>>>> good stance.
>>>>> 
>>>>> I have a mostly up-to-date build description for ggettext ready to go,
>>>>> but I stalled it while waiting for the arbitration results.  It needs
>>>>> a bit of testing yet too.
>>>>> 
>>>>> I think this package would benefit from being built separately on sol9
>>>>> and sol10 so that this issue only affects sol9.  I'll try to get back
>>>>> to this, but if someone else wants to pick it up, most of the work is
>>>>> done already.
>>>> 
>>>> I don't think that is necessary to have separate packages. In the code
>>>> that I cited in my detailed mail, you can add a run-time detection of
>>>> the release of Solaris on which it actually runs and act accordingly. I
>>>> can provide an easy patch , preferably for 0.18.1. If we validate this,
>>>> we can submit the patch upstream.
>>> 
>>> That would be excellent!!
>> 
>> Note that I'll publicly provide the patch only on request from the
>> person who intent to package a new gettext set based on 0.18.1 or
>> greater.
>
> As Ben already did most of the work I'll of course let him the honour
> of submitting it :-) Of course I lend him a hand if necesssary, so
> you can already start patching!

Here are the patches, to apply on the 0.18.1 release of gettext, and the
report that I made to the upstream project
http://savannah.gnu.org/bugs/?32087

                 Summary: libpthread linkage detection on Solaris
                 Project: GNU gettext
            Submitted by: pfelecan
            Submitted on: Mon 10 Jan 2011 11:31:30 AM CET
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

While I package gdb on Solaris 10 for the Open CSW project
(http://www.opencsw.org/) I found that the dynamic detection for
linking with pthread library by creating an ephemeral thread triggers
an assertion in gdb's thread management. This is clearly a bug in gdb
which I'll report on the corresponding system.

However, this behavior can be avoided by changing the detection
method.

Solaris 9 and previous had an issue with defining the POSIX thread
related symbols in libc but with non operational code. For this
reason, a test in the configure process is made in
gettext-runtime/m4/threadlib.m4 and if it detects that we are
configuring on Solaris the dynamic detection in activated in the
threadlib.c code in 3 sub-directories.

On Solaris 10 and later releases the original reason is no more
pertinent as the defined symbols in libc are correct. I tested
this on SPARC and Intel using the code in threadlib.c and without
linking with libpthread.

Consequently I propose a 2 pronged patch:

1. if the package is configured on Solaris 10 or later do not
   activate PTHREAD_IN_USE_DETECTION_HARD.

diff --recursive '--context=2' --unidirectional-new-file '--exclude=CVS' gettext-0.18.1-reference/gettext-runtime/m4/threadlib.m4 gettext-0.18.1-modified/gettext-runtime/m4/threadlib.m4
*** gettext-0.18.1-reference/gettext-runtime/m4/threadlib.m4	Sun Apr 25 16:05:49 2010
--- gettext-0.18.1-modified/gettext-runtime/m4/threadlib.m4	Sun Jan  9 20:15:20 2011
***************
*** 160,169 ****
            AC_CHECK_LIB([pthread], [pthread_kill],
              [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread
!              # On Solaris and HP-UX, most pthread functions exist also in libc.
               # Therefore pthread_in_use() needs to actually try to create a
               # thread: pthread_create from libc will fail, whereas
               # pthread_create will actually create a thread.
               case "$host_os" in
!                solaris* | hpux*)
                   AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
                     [Define if the pthread_in_use() detection is hard.])
--- 160,169 ----
            AC_CHECK_LIB([pthread], [pthread_kill],
              [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread
!              # On Solaris < 2.10 and HP-UX, most pthread functions exist also in libc.
               # Therefore pthread_in_use() needs to actually try to create a
               # thread: pthread_create from libc will fail, whereas
               # pthread_create will actually create a thread.
               case "$host_os" in
!                solaris2.[1-9] | solaris2.[1-9].* | hpux*)
                   AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
                     [Define if the pthread_in_use() detection is hard.])

2. if the package is configured and built on Solaris 9 or previous but
   run on Solaris 10 or later the test using the ephemeral thread is
   not necessary.

diff --recursive '--context=2' --unidirectional-new-file '--exclude=CVS' gettext-0.18.1-reference/gettext-runtime/intl/threadlib.c gettext-0.18.1-modified/gettext-runtime/intl/threadlib.c
*** gettext-0.18.1-reference/gettext-runtime/intl/threadlib.c	Sat Dec 12 16:08:01 2009
--- gettext-0.18.1-modified/gettext-runtime/intl/threadlib.c	Sun Jan  9 19:34:07 2011
***************
*** 31,34 ****
--- 31,37 ----
  
  # if PTHREAD_IN_USE_DETECTION_HARD
+ #include <strings.h>
+ #include <errno.h>
+ #include <sys/utsname.h>
  
  /* The function to be executed by a dummy thread.  */
***************
*** 45,48 ****
--- 48,84 ----
    static int result; /* 1: linked with -lpthread, 0: only with libc */
  
+   /* dynamic detection for running on Solaris 5.10 or higher; starting
+    * with Solaris 10 the libc resolves correctly the POSIX threads
+    * symbols. */
+   if (!tested)
+   {
+ 	  struct utsname un;
+ 	  if(uname(&un) != -1)
+ 	  {
+ 		  if(strcmp(un.sysname, "SunOS") == 0)
+ 		  {
+ 			  char* dot = strchr(un.release, '.');
+ 			  errno = 0;
+ 			  if(dot != (char*)0)
+ 			  {
+ 				  int minor = atoi(dot + 1);
+ 				  *dot = '\0';
+ 				  if(!errno)
+ 				  {
+ 					  int major = atoi(un.release);
+ 					  if(!errno)
+ 					  {
+ 						  if(major >= 5 && minor >= 10)
+ 						  {
+ 							  tested = 1;
+ 							  result = 1;
+ 						  }
+ 					  }
+ 				  }
+ 			  }
+ 		  }
+ 	  }
+   }
+   
    if (!tested)
      {
diff --recursive '--context=2' --unidirectional-new-file '--exclude=CVS' gettext-0.18.1-reference/gettext-tools/gnulib-lib/glthread/threadlib.c gettext-0.18.1-modified/gettext-tools/gnulib-lib/glthread/threadlib.c
*** gettext-0.18.1-reference/gettext-tools/gnulib-lib/glthread/threadlib.c	Mon May 24 11:42:37 2010
--- gettext-0.18.1-modified/gettext-tools/gnulib-lib/glthread/threadlib.c	Sun Jan  9 19:35:42 2011
***************
*** 30,33 ****
--- 30,36 ----
  
  # if PTHREAD_IN_USE_DETECTION_HARD
+ #include <strings.h>
+ #include <errno.h>
+ #include <sys/utsname.h>
  
  /* The function to be executed by a dummy thread.  */
***************
*** 44,47 ****
--- 47,83 ----
    static int result; /* 1: linked with -lpthread, 0: only with libc */
  
+   /* dynamic detection for running on Solaris 5.10 or higher; starting
+    * with Solaris 10 the libc resolves correctly the POSIX threads
+    * symbols. */
+   if (!tested)
+   {
+ 	  struct utsname un;
+ 	  if(uname(&un) != -1)
+ 	  {
+ 		  if(strcmp(un.sysname, "SunOS") == 0)
+ 		  {
+ 			  char* dot = strchr(un.release, '.');
+ 			  errno = 0;
+ 			  if(dot != (char*)0)
+ 			  {
+ 				  int minor = atoi(dot + 1);
+ 				  *dot = '\0';
+ 				  if(!errno)
+ 				  {
+ 					  int major = atoi(un.release);
+ 					  if(!errno)
+ 					  {
+ 						  if(major >= 5 && minor >= 10)
+ 						  {
+ 							  tested = 1;
+ 							  result = 1;
+ 						  }
+ 					  }
+ 				  }
+ 			  }
+ 		  }
+ 	  }
+   }
+   
    if (!tested)
      {
diff --recursive '--context=2' --unidirectional-new-file '--exclude=CVS' gettext-0.18.1-reference/gettext-tools/libgettextpo/glthread/threadlib.c gettext-0.18.1-modified/gettext-tools/libgettextpo/glthread/threadlib.c
*** gettext-0.18.1-reference/gettext-tools/libgettextpo/glthread/threadlib.c	Tue Feb 16 22:33:14 2010
--- gettext-0.18.1-modified/gettext-tools/libgettextpo/glthread/threadlib.c	Sun Jan  9 19:36:18 2011
***************
*** 30,33 ****
--- 30,36 ----
  
  # if PTHREAD_IN_USE_DETECTION_HARD
+ #include <strings.h>
+ #include <errno.h>
+ #include <sys/utsname.h>
  
  /* The function to be executed by a dummy thread.  */
***************
*** 44,47 ****
--- 47,83 ----
    static int result; /* 1: linked with -lpthread, 0: only with libc */
  
+   /* dynamic detection for running on Solaris 5.10 or higher; starting
+    * with Solaris 10 the libc resolves correctly the POSIX threads
+    * symbols. */
+   if (!tested)
+   {
+ 	  struct utsname un;
+ 	  if(uname(&un) != -1)
+ 	  {
+ 		  if(strcmp(un.sysname, "SunOS") == 0)
+ 		  {
+ 			  char* dot = strchr(un.release, '.');
+ 			  errno = 0;
+ 			  if(dot != (char*)0)
+ 			  {
+ 				  int minor = atoi(dot + 1);
+ 				  *dot = '\0';
+ 				  if(!errno)
+ 				  {
+ 					  int major = atoi(un.release);
+ 					  if(!errno)
+ 					  {
+ 						  if(major >= 5 && minor >= 10)
+ 						  {
+ 							  tested = 1;
+ 							  result = 1;
+ 						  }
+ 					  }
+ 				  }
+ 			  }
+ 		  }
+ 	  }
+   }
+   
    if (!tested)
      {

-- 
Peter
_______________________________________________
maintainers mailing list
[email protected]
https://lists.opencsw.org/mailman/listinfo/maintainers
.:: This mailing list's archive is public. ::.

Reply via email to